Replace value with another value

Hi,
I have a list of data in a column
There are some values which are -1
How can I replace the -1 values in the column with 0.1 mm values?
Maybe I must use the find function?
Can you help me with the code?
Thank you.

댓글 수: 5

Turlough Hughes
Turlough Hughes 2019년 12월 16일
How can I replace the -1 values in the column with the between 0 and 0.1 mm values?
What do you mean by this? Do you have a rule for which value you want it to become?
Sarah Yun
Sarah Yun 2019년 12월 16일
Hi,
I mean, there are -1 values in the column.
These values represent snowfall between 0 and 0.1 mm
So, to make the column accurate, I must substitute the -1 unit with the 0 - 0.1 mm values.
Can you help? Thank you.
Turlough Hughes
Turlough Hughes 2019년 12월 16일
Can you attach the original data?
Adam Danz
Adam Danz 2019년 12월 16일
It's unlcear how you want to repace a single value (-1) with range of values (0:0.1). If you're working with a matrix, you cannot replace a single value with multiple values. If you're working with a cell array it's possible but it's still not clear how -1 whould be replaced.
Sarah Yun
Sarah Yun 2019년 12월 16일
Hi,
I would like to replace -1 with 0.1 in the column
What code can do this?
Thank you!

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

답변 (1개)

Adam Danz
Adam Danz 2019년 12월 16일

4 개 추천

M(M==-1) = 0.1;

댓글 수: 2

Sarah Yun
Sarah Yun 2019년 12월 16일
편집: Sarah Yun 2019년 12월 16일
Hello,
To change -1 values to 0.1 in a table, I write this code:
Table.Variable = A;
B = A((M==-1) = 0.1);
% Insert new values back into table
Table.Variable = B;
Something is not right.
Can you help?
Adam Danz
Adam Danz 2019년 12월 16일
편집: Adam Danz 2019년 12월 18일
If you are replacing values in Table.Variable, then M should be repaced with Table.Variable.
Table.Variable(Table.Variable == -1) = 0.1;

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

태그

질문:

2019년 12월 16일

편집:

2019년 12월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by