create empty row inside a vector
古いコメントを表示
Hi. I need to analyze the rows of the vector 'value_GS_test' and transform only the numbers 254 and 255 (if any) into '[]' while keeping the same number of rows as in the original vector. Here is an example:

Right now I am using this code, but it only deletes one row (at 255) for me. How can I get the desired result?
value_GS = importdata("value_GS_test.mat"); % 6 elements
for rows_value_GS = 1 %:height(value_GS)
analysis_number = value_GS(rows_value_GS);
if analysis_number == 255
value_GS(rows_value_GS) = [];
elseif analysis_number == 254
value_GS(rows_value_GS) = [];
else
value_GS(rows_value_GS) = value_GS(rows_value_GS);
end
end
5 件のコメント
Chunru
2023 年 7 月 18 日
How about using nan instead of []?
Stephen23
2023 年 7 月 18 日
"How can I get the desired result?"
Numeric arrays cannot have empty elements or "holes" in them: every element is one value.
You could use a marker value, e.g. NaN, or store a separate logical mask.
Walter Roberson
2023 年 7 月 18 日
Note however that uint8 cannot represent NaN or inf
Simon Chan
2023 年 7 月 18 日
What is the final purpose of making a bracket to those positions? For display only? Or you will write it as blank on a text file?
Alberto Acri
2023 年 7 月 18 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Numeric Types についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!