使用matlab中的函数,我得到错误“索引必须是实数正整数或逻辑". [英] Using a function in matlab, I get the error `indices must either be real positive integers or logicals.`

查看:54
本文介绍了使用matlab中的函数,我得到错误“索引必须是实数正整数或逻辑".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码的目的是绘制 RGB 图像的 SNR(好吧,代码说明了灰度的 id,因为我无法为最终目标 RGB 做),y axix 绘制干净和嘈杂之间的平均误差图像除以干净图像的标准偏差(以缩小误差).代码产生错误

The objective of the following code is to plot SNR of RGB image(well,the code illustrated id for gray scale since I could not do for RGB which is the ultimate goal) and y axix plots the mean error between clean and noisy image divided by the standard deviation of the clean image (in order to scale the error). The code generates error

??? Subscript indices must either be real positive
integers or logicals.

==> cr_t在34时出错

Error in ==> cr_t at 34

varra=var(var(CleanImg_normalized)); 

  1. 请帮助纠正代码,因为我得到的是一个点,一个点作为图而不是线图
  2. 如何修改RGB图像的代码
  3. 是否存在整数倍的有效值,用于计算db中的SNR,我已经看到10,20个最常用的数字.

推荐答案

正如@Chris所说,根据您的错误消息,似乎matlab相信 var 是一个变量.因此,也许您已经分配了此变量.要检查,请执行以下操作:

As said by @Chris, according to your error message, it seems like matlab believe that var is a variable. So maybe you have already assigned this variable. To check that do:

whos var

如果输出不为空,则表示确实分配了 var .

If the output is not empty it means that indeed var is assigned.

在这种情况下,请执行以下操作:

In that case, do:

clear var

此后,就不应再分配变量 var 了.因此,再次运行您的脚本.但是,您还应该检查在脚本执行期间是否未分配 var .

After that the variable var should not be assigned any more. So run again your script. However you should also check that var is not assigned during your script.

这篇关于使用matlab中的函数,我得到错误“索引必须是实数正整数或逻辑".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆