Solving queue problem iterating through array

조회 수: 1 (최근 30일)
em_++
em_++ 2021년 5월 25일
댓글: em_++ 2021년 5월 25일
Hello!
I have a small problem and i think it is quiet easy to solve but i struggle.
I've got an array Lock19 = 86371*1 double... this array consists of a lot of -5 and other various random numbers.
My Variable is Lock19 = data(:,7)
now i want to overwrite those numbers ... so every -5 should become 3 and every other number should become 0.
It shouldn't be that hard, I tried it like this:
if(Lock19 == -5)
Lock19 = 3
end
if(Lock19 ~= -5)
Lock19= 0
end
plot etc....
Thanks for your help !!!

답변 (1개)

Alan Stevens
Alan Stevens 2021년 5월 25일
Try
Lock19(Lock19~=-5)=0;
Lock19(Lock19==-5)=3;
  댓글 수: 1
em_++
em_++ 2021년 5월 25일
this worked!!! thank you very much!!!!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by