Vector inside another vector
2 次查看(过去 30 天)
显示 更早的评论
Hi! I have a vector S = [0 1 2 3 4 ... 30]' and now i want to create another vector U that is equal to 0 if K<S and equal to S if K>=S. In my exercise K=15.
I did this:
U1=zeros(30,1);
U1(15,30)=S;
Can you please help me? Thanks
3 个评论
Alex Mcaulley
2019-5-21
Your problem is not difficult. You just need to take a look to logical indexing in Matlab. For example:
采纳的回答
更多回答(1 个)
madhan ravi
2019-5-21
编辑:madhan ravi
2019-5-21
People don’t do homeworks here. Index K>=S to U1 lhs and S rhs by equating against each other. Since it’s your homework see Alex’s links above and experiment.
2 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!