How to plot the curve?

3 vues (au cours des 30 derniers jours)
Hang Vu
Hang Vu le 8 Août 2019
Commenté : Adam le 9 Août 2019
I have:
k=2, 2.1, 2.2, 2.3, …, 4.9, 5.0
B=[0.2,0.4,0.6,0.8,1];
R=B/(1+k/2)
How to plot R like this: Thank you!
vd.PNG

Réponse acceptée

Adam
Adam le 8 Août 2019
Modifié(e) : Adam le 8 Août 2019
R = B ./ ( 1 + k'/2 );
figure; plot( R )
or
R = bsxfun( @rdivide, B, ( 1 + k'/2 ) );
for earlier versions of Matlab that don't support implicit expansion
  2 commentaires
Hang Vu
Hang Vu le 9 Août 2019
Modifié(e) : Hang Vu le 9 Août 2019
Thank you^^. But can you help the x-axis is k and Y is R?
vd.PNG
Y is correct but X, k runs from 2:5 only, but in the graph, it is displayed 31 times of k
Adam
Adam le 9 Août 2019
plot( k, R )
doc plot
gives details of different ways to parameterise plots.
If you just do
plot( R )
then it just uses indices along the x axis (i,e. 1 to 31 in your case). If you give it both an x and a y then it will plot both.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by