Vector inside another vector
이전 댓글 표시
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 Sune
2019년 5월 21일
Your problem is not difficult. You just need to take a look to logical indexing in Matlab. For example:
José Campelo
2019년 5월 21일
채택된 답변
추가 답변 (1개)
madhan ravi
2019년 5월 21일
편집: madhan ravi
2019년 5월 21일
0 개 추천
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
Adam Danz
2019년 5월 21일
My homework detectors didn't go off on this one.
madhan ravi
2019년 5월 21일
XD sometimes it doesn’t even in mine, maybe a bug xd.
카테고리
도움말 센터 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!