The following code is showing me matrix dimension error....please help,
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Khushboo Patel
le 25 Mar 2018
Commenté : Khushboo Patel
le 25 Mar 2018
clc
clear all
close all
figure(1)
axis([1 12 1 12])
x=1:8;
for i=1:8
line([x(i) x(i+1)],[3 4],'linewidth',2,'color','black')
end
0 commentaires
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 25 Mar 2018
You initialize x=1:8 so the last entry in x is x(8)
You loop for i=1:8, and inside your loop you refer to x(i) and x(i+1) . When i = 8, that is x(8) and x(8+1) = x(9). However, there is no x(9) in your array.
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements 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!