Effacer les filtres
Effacer les filtres

"Vectors must be same length" Please help with plotting!

1 vue (au cours des 30 derniers jours)
Stenila  Simon
Stenila Simon le 30 Août 2018
I'm trying to plot the following and it will not allow me to, because apparently the vectors are not the same length. What am I missing?
h = [0:1:11];
for i = 1:length(h);
T(i) = To - (6*h(i));
end
plot(h,T)
  1 commentaire
Stephen23
Stephen23 le 30 Août 2018
Modifié(e) : Stephen23 le 30 Août 2018
Is T defined anywhere previously in the code?
Note that the square brackets are superfluous:
You possibly do not need a loop, just use this:
h = 0:11;
T = To - 6*h;

Connectez-vous pour commenter.

Réponses (1)

Cesar Antonio Lopez Segura
Cesar Antonio Lopez Segura le 30 Août 2018
Hi,
What is the value of 'To'?
Is 'To' a scalar o vector?
The following code has not errors:
To = 0;
h = [0:1:11];
for i = 1:length(h);
T(i) = To - (6*h(i));
end
plot(h,T)

Catégories

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

Community Treasure Hunt

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

Start Hunting!

Translated by