I will appreciate any suggestion on this simple code. I want to substitute the elements of x >5 with 6 and x<5 with zero.
이전 댓글 표시
for j=1:1:8
x=[1 2 3 4 5 6 7 8];
if x(j)>5
x(j)=subs(x(j),x(j),6);
else
x(j)=subs(x(j),x(j),0);
end
end
채택된 답변
추가 답변 (1개)
matico
2015년 8월 16일
Also:
x=[1 2 3 4 5 6 7 8];
x(x>5) = 6;
x(x<=5) = 0;
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!