What kind of loop for this equation?
1 view (last 30 days)
Show older comments
Hii, In a part of my calculation i have cos (theta) /L. Theta ranges from 0 to 360 deg and L ranges from 300 to 800. But i need a calculation of l=300 ranging from0 to 360 deg,L=301 ranging from 0 to 360 deg............... L=800rangin from 0 to 360 deg.this matrix kind of calculation brings wrong loop for me.could anyone help in this regard?!
0 Comments
Accepted Answer
Image Analyst
on 16 Nov 2014
I have no idea if you want fixed, specified values of 300 for (the badly-named) l, and fixed specified values of 301 and 800 for L, OR if you want I to take on many (perhaps 361) values between 0 and 300, and the badly-named l to take on similar values between 0 and 360. Why does L have units of degrees anyway when it is in the denominator? Do you want this
L = 301; % Or 800 or whatever.
l = 300; % Not sure where this is even used!!!
for theta = 0 : 360
result(theta) = cosd(theta) / L;
end
2 Comments
More Answers (1)
Thorsten
on 17 Nov 2014
theta = 0:360; l = 300:800;
[Theta, L] = meshgrid(theta, l);
Z = cos(Theta/180*pi)./L;
mesh(theta, l, Z)
0 Comments
See Also
Categories
Find more on Historical Contests in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!