three difference vectors and plots
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to plot three difference vector in one figure.
this is sample data. I keep error "vectors must be the same length".
how should I change it?
x = [ 1, 2, 3, 4, 5]
x1 = [ 1.1, 2.2, 3.4, 4, 4.5]
x2 = [0.9, 1.9, 3, 3.9, 4.3]
y= [1, 2, 3, 4, 5];
y1=[2, 3, 4, 5, 6];
y2 = [1, 3, 6, 7, 8]
hold on
plot(x,y)
plot(x1,y1)
plot(x2,y2)
hold off
0 Kommentare
Antworten (1)
Steve Eddins
am 18 Mär. 2021
I have copy-pasted your code below, exactly as entered in your question. It runs and produces the plot with no error. I suggest that you double-check your code carefully. If you still get an error, then copy your code from MATLAB directly into a comment here, along with the exact text of any error message, so that we can take a look.
x = [ 1, 2, 3, 4, 5]
x1 = [ 1.1, 2.2, 3.4, 4, 4.5]
x2 = [0.9, 1.9, 3, 3.9, 4.3]
y= [1, 2, 3, 4, 5];
y1=[2, 3, 4, 5, 6];
y2 = [1, 3, 6, 7, 8]
hold on
plot(x,y)
plot(x1,y1)
plot(x2,y2)
hold off
Siehe auch
Kategorien
Mehr zu Annotations 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!