MATLAB中未定义的变量 [英] undefined variable in MATLAB

查看:50
本文介绍了MATLAB中未定义的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是MATLAB的新手.我编写了代码对数据进行上采样.执行时总是会出现特定的错误(如下)

I am newbie to MATLAB .I have written a code to upsample a data.when executed always shrows the particular error(below)

<强>???输入参数"n"未定义.==> 7的升频错误mm = min(n)

但是当我只是写文章时.输出[n1,y] = upsamp([1,2,3,4,5,6],-1:4,3)命令窗口,它会以图形显示正确的上采样数据.

but when i just write the foll. output [n1,y]=upsamp([1,2,3,4,5,6],-1:4,3) command window ,its shows me the correct upsampled data with its figure.

那为什么会出现这个错误呢?或者我只单击运行"按钮,错误就会显示在命令窗口中.

then why the error is popping up? Or i just click on run button,and error is shown in command window.

请帮助我调试该错误:

我的代码是

function[n1,y]=upsamp(n,x,I)

mm=min(n)
mx=max(n)
n1=mm*I:(mx*I+I-1)
x1=x'
x1=[x1,zeros(length(x),I-1)]
x1=x1'
y=(x1(:))'

subplot(2,1,1)
stem(n,x)
title('original sequence ')
xlabel('Range')
ylabel('sequence')

subplot(2,1,2)
stem(n1,y)
title(' unsampling')
xlabel('Range')
ylabel('sequence')

end

推荐答案

正如其他人指出的那样,如果要运行一个带有输入参数的函数,则必须从命令提示符中手动调用带有任何必需参数的函数.

As others have noted, if you want to run a function that takes input arguments, you have to call it manually from the command prompt with any required arguments.

否则,如果您想使用编辑器中的运行按钮(F5),请考虑创建一个

Otherwise, if you like to use the Run button (F5) from the editor, consider creating a run configuration (they can be used in smart ways)

这篇关于MATLAB中未定义的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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