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 次查看(过去 30 天)
显示 更早的评论
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 个评论
Stephen23
2016-12-3
编辑:Stephen23
2016-12-3
"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
采纳的回答
James Tursa
2016-11-30
编辑:James Tursa
2016-11-30
It is not clear to me what you really want. Maybe this?
for a=[0:1:180,179:-1:-180]
% whatever
end
更多回答(1 个)
Star Strider
2016-11-30
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)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!