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/07/20 04:23:49
![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(](/uploads/image/z/993362-50-2.jpg?t=matlab%E4%B8%ADatan2%E9%97%AE%E9%A2%98h1+%3D+linspace%280%2C2%2Api%2C1000%29%3B+%25+%E8%BE%93%E5%85%A5h%E7%9A%84%E5%80%BCfor+i+%3D+1%3Alength%28h1%29h+%3D+h1%28i%29%3Bt%3Dlinspace%280%2C2%2Api%2C50%29%3By%3Dsqrt%28%28cos%28t%29-0.1%2Acos%28t%2Bh%29%2B0.3%2A%281%2B0.25%2A0.3%5E2%29%2Acos%282%2At%29%29.%5E2%2B%280.1%2Asin%28t%2Bh%29%29.%5E2%29%3Bimax%3Dfind%28max%28y%29%3D%3Dy%29%3Bfy%3D-0.1%2Asin%28t%2Bh%29%3Bfx%3Dcos%28t%29-0.1%2Acos%28)
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输入变量只能有一个呀?