Filter löschen
Filter löschen

whats the problem in error 11

2 Ansichten (letzte 30 Tage)
gowshya
gowshya am 8 Sep. 2023
Kommentiert: Les Beckham am 8 Sep. 2023
clc
clear all
s=[0 0.2 0.4 0.6 0.8 1];
y=[0 0.74 0.96 0.98 0.81 0];
x=[0 0.63 0.77 0.86 0.93 1];
t=[ 3.12 1.91 1.43 1.17 1];
m=[ 1.70 1.22 0.88 0.57 0];
yyaxis left
plot(s,y,':bo',s,x,':ro');
yyaxis right
plot(s,t,':go',s,m,':yo');
Error using plot
Vectors must be the same length.

Antworten (1)

Walter Roberson
Walter Roberson am 8 Sep. 2023
Your t and m have fewer elements than your s, so you cannot plot t against s or m against s. You could plot t against m
  2 Kommentare
Walter Roberson
Walter Roberson am 8 Sep. 2023
guessing
s=[0 0.2 0.4 0.6 0.8 1];
y=[0 0.74 0.96 0.98 0.81 0];
x=[0 0.63 0.77 0.86 0.93 1];
t=[ 3.12 1.91 1.43 1.17 1];
m=[ 1.70 1.22 0.88 0.57 0];
yyaxis left
plot(s,y,':bo',s,x,':ro');
yyaxis right
smid = (s(1:end-1)+s(2:end))/2;
plot(smid, t, ':go', smid, m, ':mo');
Les Beckham
Les Beckham am 8 Sep. 2023
Here's another guess
clc
clear all
s=[0 0.2 0.4 0.6 0.8 1];
y=[0 0.74 0.96 0.98 0.81 0];
x=[0 0.63 0.77 0.86 0.93 1];
% t=[ 3.12 1.91 1.43 1.17 1];
% m=[ 1.70 1.22 0.88 0.57 0];
t=[0 3.12 1.91 1.43 1.17 1]; % << added a datapoint at zero
m=[0 1.70 1.22 0.88 0.57 0]; % << added a datapoint at zero
yyaxis left
plot(s,y,':bo',s,x,':ro');
yyaxis right
plot(s,t,':go',s,m,':yo');
grid on

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by