how to reduce its computing time?
1 次查看(过去 30 天)
显示 更早的评论
u=[30 40 50 70];
b=u;
[~,C]=size(b);
P=C/2;
M=10;
xo=zeros(1,M);
yo=zeros(1,M);
zo=zeros(1,M);
for k=1:M
for i=1:P
xo(1,k)=xo(1,k)+exp(-1i*(k-1)*pi*sind(u(i))*cosd(u(P+i)));
yo(1,k)=yo(1,k)+exp(-1i*(k-1)*pi*sind(u(i))*(cosd(u(P+i))+sind(u(P+i))));
zo(1,k)=zo(1,k)+exp(-1i*(k-1)*pi*sind(u(i))*cosd(u(P+i))+cosd(u(i)));
end %end of i
end
xe=zeros(1,M);
ye=zeros(1,M);
ze=zeros(1,M);
for k=1:M
for i=1:P
xe(1,k)=xe(1,k)+exp(-1i*(k-1)*pi*sind(b(i))*cosd(b(P+i)));
ye(1,k)=ye(1,k)+exp(-1i*(k-1)*pi*sind(b(i))*(cosd(b(P+i))+sind(b(P+i))));
ze(1,k)=ze(1,k)+exp(-1i*(k-1)*pi*sind(b(i))*cosd(b(P+i))+cosd(b(i)));
end %end of i
end %end of k
abc=0.0;
abcd=0.0;
abcde=0.0;
for m1=1:M
abc=abc+(abs(xo(1,m1)-xe(1,m1))).^2;
abcd=abcd+(abs(yo(1,m1)-ye(1,m1))).^2;
abcde=abcde+(abs(zo(1,m1)-ze(1,m1))).^2;
end%end of m1
err=abc+abcd+abcde;
err=err/(3*M);
0 个评论
采纳的回答
Torsten
2022-12-31
Here is the code for the first loop. You can do it for the other loops in the same manner.
u=[30 40 50 70];
b=u;
[~,C]=size(b);
P=C/2;
M=10;
MM =(0:(M-1)).';
PP=1:P
xo = sum(exp(-1i*MM*pi.*sind(u(PP)).*cosd(u(P+PP))),2).'
yo = sum(exp(-1i*MM*pi.*sind(u(PP)).*(cosd(u(P+PP))+sind(u(P+PP)))),2).'
zo = sum(exp(-1i*MM*pi.*sind(u(PP)).*cosd(u(P+PP))+cosd(u(PP))),2).';
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!