how to plot three variables in a line graph with values ?

ax[1] = 0.98 ax[2] = 1.2 ax[3] = 0.23
bx[1] = 2.1 bx[2] = 0.236 bx[3] = 1.25
cx[1] = 0.01 cx[2] = 0.025 cx[3] = 0.52
plot(ax,bx,cx); is possible ?

 Réponse acceptée

Jan
Jan le 14 Mai 2013
Modifié(e) : Jan le 14 Mai 2013
ax = [0.98, 1.2, 0.23];
bx = [2.1, 0.236, 1.25];
cx = [0.01, 0.025, 0.52];
What do you expect now? Is ax the x-component of the line? Or should it be 1:3 implicitly?
x = 1:3;
plot(x, ax, x, bx, x, cx); % EDITED, Typo ay->ax
Or:
plot(x, [ax; bx; cx])

Plus de réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 14 Mai 2013
Modifié(e) : Azzi Abdelmalek le 14 Mai 2013
ax(1) = 0.98
ax(2) = 1.2
ax(3) = 0.23
bx(1) = 2.1
bx(2) = 0.236
bx(3) = 1.25
cx(1) = 0.01
cx(2) = 0.025
cx(3) = 0.52
plot(ax,bx,cx)
Use () instead of [ ]

2 commentaires

Jan
Jan le 14 Mai 2013
Modifié(e) : Jan le 14 Mai 2013
What do you expect as output, when you call plot() with three vectors?
I get this for your code:
??? Error using ==> plot
Data must be a single matrix Y or a list of pairs X,Y
you have incorrect code.
Error using plot
Data must be a single input of y --values or
one or more pairs of x -- and y--values.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Networks dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by