Replace first number of matrix with the next larger value
1 次查看(过去 30 天)
显示 更早的评论
I have the following matrix:
StrikeMatrix11= [1:10]
Now I want to replace the first number of StrikeMatrix11 with "2" since the second number of StrikeMatrix11 is larger than its first number.
Unfortunatley, my code is a) too complex and b) not working.
Does anyone have an idea how to fix this?
if StrikeMatrix11(2)>StrikeMatrix11(1)
StrikeMatrix11(1)=StrikeMatrix11(2);
else
for n=1:10
while StrikeMatrix11(n+1)<=StrikeMatrix11(1)
StrikeMatrix11(1)=StrikeMatrix11(1);
if StrikeMatrix11(n+1)>StrikeMatrix11(1)
StrikeMatrix11(1)=StrikeMatrix11(n+1);
break
end
end
end
end
Best!
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 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!