实际上,我有两个m文件:一个是主文件,另一个是次文件。
primary
m文件现在只包含一个公式。我试图通过secondary
m文件向它传递4个输入参数,但是当我运行secondary
程序时,我收到的参数太多了。
function[]=primary(A,omega,t,angle)
A.*sin(omega*t+angle);
end
对于中学:
function[n]=secondary(A,omega,t,angle)
A=input('enter the value of amplitude\n');
omega=input('enter the value of omega\n');
t=input('enter the value of time interval\n');
angle=input('enter the value of angle\n');
angle=(angle*pi)/180;
n=primary(A,omega,t,angle);
T=-t:t;
plot(T,n);
end
答案 0 :(得分:1)
函数primary
不声明任何输出参数;因此,由于输出参数太多,n=primary(A,omega,t,angle);
中的行secondary
将抛出错误。
更改primary的定义以包含输出:
function [n] = primary(A,omega,t,angle)
n = A.*sin(omega*t+angle);
end