How can I write equation?

2 Ansichten (letzte 30 Tage)
Eylül Erol
Eylül Erol am 12 Okt. 2018
Bearbeitet: madhan ravi am 13 Okt. 2018
r (y ) =(1-x^2)/(1-x*cos(y) where y= 0 to 2pi and x=(0,0.1,0.5,0.9)
  1 Kommentar
Rik
Rik am 12 Okt. 2018
Should r be a vector for a given value of x?
And what have you tried so far yourself?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

madhan ravi
madhan ravi am 12 Okt. 2018
Bearbeitet: madhan ravi am 12 Okt. 2018
x=[0,0.1,0.5,0.9]
y=linspace(0,2*pi,numel(x))
r=(1-x.^2)./(1-x.*cos(y))
plot(y,r,'-*b')
  2 Kommentare
Eylül Erol
Eylül Erol am 13 Okt. 2018
thanks
madhan ravi
madhan ravi am 13 Okt. 2018
Bearbeitet: madhan ravi am 13 Okt. 2018
make sure to accept the answer if it worked

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Stephan
Stephan am 12 Okt. 2018
Hi,
y= linspace(0,2*pi);
x=[0, 0.1, 0.5, 0.9];
[a,b] = meshgrid(x,y);
r = (1-a.^2)./(1-a.*cos(b));
contourf(x,y,r)
  3 Kommentare
Rik
Rik am 12 Okt. 2018
Because r depends on the value of x and y. You can either have a single value for each combination of x and y, or you will have a vector of values as the output for any y. The meshgrid function can be used to generate a grid with all combinations of values.
Note that the call to linspace generates a vector of 100 values. You can change this by adding a third input with your desired number of inputs.
Stephan
Stephan am 12 Okt. 2018
Thanks Rik

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by