Effacer les filtres
Effacer les filtres

whats the problem in error 11

2 vues (au cours des 30 derniers jours)
gowshya
gowshya le 8 Sep 2023
Commenté : Les Beckham le 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.

Réponses (1)

Walter Roberson
Walter Roberson le 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 commentaires
Walter Roberson
Walter Roberson le 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 le 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

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by