特定の値(欠損値)を削除する方法
42 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
健気 大川
el 17 de Sept. de 2021
Comentada: 健気 大川
el 17 de Sept. de 2021
イメージ画像を下に載せます。
例えばmatlab上(画像はexcelですが)で左のような5行7列の行列があったとします。これを右のように0の部分を削除したものを作りたいです。
どなたかお時間がある方助言をお願いしたいです。(ただし、今回は例として5行7列ですがほかの行列パターンでも用いたいです。また、0は欠損値のような扱いで途中で現れることはありません。)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/741144/image.png)
0 comentarios
Respuesta aceptada
Hernia Baby
el 17 de Sept. de 2021
ゼロ値をNaN値にすればいけます
file = 'Sample.xlsx';
A = readmatrix(file,"OutputType","double");
ここがミソです
A(A==0) = NaN
書き出します
writematrix(A,file,'Range','K2');
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!