i want to make a for loop that goes like this for a=0:1:180 && 179:-1:-180 but it is not possible in matlab, any ideas how to do it?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
abbxucy11
am 30 Nov. 2016
Bearbeitet: Stephen23
am 3 Dez. 2016
i want to make a for loop that goes like this for a=0:1:180 && 179:-1:-180 but it is not possible in matlab, any ideas how to do it?
i cant use the && or the in matlab and i cant find any other way to do it!
3 Kommentare
Stephen23
am 3 Dez. 2016
Bearbeitet: Stephen23
am 3 Dez. 2016
"i mean it is not possible to use && or for the and expression"
The short circuit AND operator && works perfectly, exactly as per the documentation. Did you read it?
>> 1 && (1 || 0)
ans = 1
Akzeptierte Antwort
James Tursa
am 30 Nov. 2016
Bearbeitet: James Tursa
am 30 Nov. 2016
It is not clear to me what you really want. Maybe this?
for a=[0:1:180,179:-1:-180]
% whatever
end
Weitere Antworten (1)
Star Strider
am 30 Nov. 2016
You need to concatenate the vectors, not logically ‘and’. See if this does what you want:
q = [];
for a=[0:1:180 179:-1:-180]
q = [q a];
end
plot(q)
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!