I want to change specific values in a table

12 ビュー (過去 30 日間)
Martin Krippl
Martin Krippl 2021 年 2 月 16 日
編集済み: langrg 2021 年 2 月 16 日
Hello,
I imported data into matlab, and because it does not take UTF-16 ascii format, I have a file with UTF-8, but with "-1" values , where I would like to have NaN.
My data are in a table called "oneEyeValue1".
I then wrote the following loop:
[row col]= size (oneEyeValue1);
for i=1:row % reihen
for j=2:col % spalten ginge auch mit size (oneEyevalue, 2)
if oneeyearray(i,j)==-1
oneeyearray(i,j)=NaN;
end
end
end
I get the following error:
"Error in testrepplacement (line 4)
if oneeyearray(i,j)==-1"
Can anyone help me there? What is the right syntax to go through every value in the table and check it for being a "-1" and then replacing it with "NaN"?
Best, Martin.

回答 (1 件)

langrg
langrg 2021 年 2 月 16 日
Hi,
I think you forgot to define "oneeyearray" before using it.
You can not do
if oneeyearray(i,j)==-1
if "oneeyearray" doesn't exist.
I'm not sure to well understand what you try to do, but may this code could help you:
oneeyearray = oneEyeValue1(:, 2:end);
oneeyearray(oneeyearray==-1) = NaN;
  4 件のコメント
langrg
langrg 2021 年 2 月 16 日
編集済み: langrg 2021 年 2 月 16 日
What is the difference between "oneEyeValue1" and "oneeyearray"?
Martin Krippl
Martin Krippl 2021 年 2 月 16 日
the first is a table which was generated by importing an ascii-file (.txt), and the second is an array which was generated from the first one (it has no variable names).

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by