jeudi 1 décembre 2016

In MATLAB, is it possible to have a 'for' loop straight after an 'elseif', and if not, how do I circumvent this?

Say I have the following:

vector = [1,2,3];

if length(vector) > 5
error ('Vector too long')
elseif
 for k = 1:length(vector)
 vector(1,k) < vector(1,k+1)
error ('Elements in vector not in ascending order')
else
...

I cannot seem to get this to work, nor can I see an obvious way to get around this problem.

Aucun commentaire:

Enregistrer un commentaire