Apply an array to an equations variable?

I have an equation say theta2 = 100 * cosd(theta1). I want to set theta1 = [0:1:360], then have an array output for theta2, then somehow graph the theta2 result over the degree interval of 0 to 360. I am unsure how to do this as when I set theta1 this way it just gives me a constant value for theta2. So how would I apply this array and how would I graph the results for the period? Thanks for any help!

2 Kommentare

Are you sure you are entering this correctly? When I do
theta1 = 0:1:360;
theta2 = 100 * cosd(theta1)
I get a 1x361 double array of calling cosd on each element of theta1
Scott Bone
Scott Bone am 27 Jun. 2018
Well my equation is thetad = atand((r1*sind(theta1)+E)/(r1*cosd(theta1)-rO))+180; where r1,E,and rO are knowns. It gives me a constant as a result. Not the array like I am seeking.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Rik
Rik am 27 Jun. 2018

0 Stimmen

Make sure your multiplications are element-wise (and your divisions) by including the dot before your product sign and your division sign. Compare the differences between the calculations below.
a=rand(1,3);
b=rand(1,3);
a*(b')
a.*(b') %equivalent to [a;a;a].*[(b') (b') (b')] (or with |bsxfun|)
a.*b

1 Kommentar

Rik
Rik am 30 Jun. 2018
Bearbeitet: Rik am 2 Jul. 2018
Did my answer solve your problem (i.e. thetad = atand((r1.*sind(theta1)+E)./(r1.*cosd(theta1)-rO))+180)? If so, please consider marking it as accepted answer. It will make it easier for other people with the same question to find an answer. If this didn't solve your question, please comment with what problems you are still having.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2017b

Tags

Gefragt:

am 27 Jun. 2018

Bearbeitet:

Rik
am 2 Jul. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by