matlab中atan2问题h1 = linspace(0,2*pi,1000); % 输入h的值for i = 1:length(h1)h = h1(i);t=linspace(0,2*pi,50);y=sqrt((cos(t)-0.1*cos(t+h)+0.3*(1+0.25*0.3^2)*cos(2*t)).^2+(0.1*sin(t+h)).^2);imax=find(max(y)==y);fy=-0.1*sin(t+h);fx=cos(t)-0.1*cos(

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/04 15:59:04
matlab中atan2问题h1 = linspace(0,2*pi,1000); % 输入h的值for i = 1:length(h1)h = h1(i);t=linspace(0,2*pi,50);y=sqrt((cos(t)-0.1*cos(t+h)+0.3*(1+0.25*0.3^2)*cos(2*t)).^2+(0.1*sin(t+h)).^2);imax=find(max(y)==y);fy=-0.1*sin(t+h);fx=cos(t)-0.1*cos(

matlab中atan2问题h1 = linspace(0,2*pi,1000); % 输入h的值for i = 1:length(h1)h = h1(i);t=linspace(0,2*pi,50);y=sqrt((cos(t)-0.1*cos(t+h)+0.3*(1+0.25*0.3^2)*cos(2*t)).^2+(0.1*sin(t+h)).^2);imax=find(max(y)==y);fy=-0.1*sin(t+h);fx=cos(t)-0.1*cos(
matlab中atan2问题
h1 = linspace(0,2*pi,1000); % 输入h的值
for i = 1:length(h1)
h = h1(i);
t=linspace(0,2*pi,50);
y=sqrt((cos(t)-0.1*cos(t+h)+0.3*(1+0.25*0.3^2)*cos(2*t)).^2+(0.1*sin(t+h)).^2);
imax=find(max(y)==y);
fy=-0.1*sin(t+h);
fx=cos(t)-0.1*cos(t+h)+0.3*(1+0.25*0.3^2)*cos(2*t);
theta=atan2(fy(imax),fx(imax));
hh(i)=h1(i)
yy(i)=theta;
end
plot(hh*180/pi,yy*180/pi,'k')
运行后显示?In an assignment A(I) = B,the number of elements in B and
I must be the same.
而将atan2换成atan就可以运行出来,不知道什么原因,

matlab中atan2问题h1 = linspace(0,2*pi,1000); % 输入h的值for i = 1:length(h1)h = h1(i);t=linspace(0,2*pi,50);y=sqrt((cos(t)-0.1*cos(t+h)+0.3*(1+0.25*0.3^2)*cos(2*t)).^2+(0.1*sin(t+h)).^2);imax=find(max(y)==y);fy=-0.1*sin(t+h);fx=cos(t)-0.1*cos(
imax=find(max(y)==y);%% 这一步求出来的imax有两个值,是个1X2的矩阵[1 50]
theta=atan2(fy(imax),fx(imax));%%所以这一步求出来的theta也是个1X2的矩阵
yy(i)=theta;%%这一步等号两侧维度不匹配,所以出错
%%换成atan也不行啊,atan输入变量只能有一个呀?