MATLAB不支持将脚本作为函数执行

MATLAB不支持将脚本 thita 作为函数执行怎末解决啊

U=[463.9 459 454.1 659.2 883.8 1069.3 1225.6 1372.1 1440.4 1455.1 1469.7 1411.1 1342.8 1084 932.6 708 507.8 341.8 156.2 ];
U1=max(U);
U2=U/U1;
yuxuan=sin(thita);
U3=abs(yuxuan);
U4=U3.U3;
U5=linspace(0.89,0.91,19);
figure(1)
plot(thita,U2,'-O',thita,U3,'r--','linewidth',2.5)
hold on
%plot([0,pi,0.9,0.9])
grid on
axis([0,pi,0,1])
figure(2)
GraphicHandle=polar(thita,U2,'r-
')
set(GraphicHandle,'LineWidth',2.5)
hold on
GraphicHandle1=polar(thita,U3,'b-')
set(GraphicHandle1,'LineWidth',2.5)

运行结果及报错内容

img

我在目录下找了找不到这个thita.m文件

thita不是脚本,你想肯定是一个角度变量,thita = linspace(0,pi,19); 这样吧。可以加上这句试试

sin( ) 括号里是“弧度”量,所以thita是一个表示弧度大小的变量,但是你没定义,sin的使用方法如下:


>> sin(30*pi/180)
 
ans =
 
    0.5000


thita未定义

thita可能与内部函数重名,你换个名称试试
thita.m必须定义成

function a = thita(b) % b是输出参数,a是输出参数
% 这里面是你的函数主体
end