multiple r values for multiple theta values

17 Ansichten (letzte 30 Tage)
Allan Asturias
Allan Asturias am 6 Mär. 2021
Kommentiert: Allan Asturias am 7 Mär. 2021
theta=[pi,3,2.8,2.5,2,pi/2,1.3,1.0,0.75,0.5];
r=(pi-theta)/(sin(theta))
x=r*cos(theta)
y=r*sin(theta)
plot(x,y)
I was wondering how I can get it to give a different r value for each theta value. For example
theta=pi r=0 x=0 y=0
theta=3 r=1.0033 x=-0.9933 y=0.1416
theta=2.8 r=1.0197 x=-0.9608 y=0.3416
each theta value is used to get a differnt r value that is then used to get a different x and y point. Currently it only gives one r value and keeps using it for the differnt inputs. It should give a different r values for each theta value. Thank you.

Antworten (1)

David Goodmanson
David Goodmanson am 6 Mär. 2021
Bearbeitet: David Goodmanson am 6 Mär. 2021
Hi Allan
For an element-by-element calculation, use ./ and .* rather than / and *
theta=[pi,3,2.8,2.5,2,pi/2,1.3,1.0,0.75,0.5];
r=(pi-theta)./(sin(theta))
x=r.*cos(theta);
y=r.*sin(theta);
plot(x,y)
r =
0 1.0033 1.0197 1.0721 1.2555 1.5708 1.9112 2.5451 3.5086 5.5099

Kategorien

Mehr zu Spatial Search finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by