extractin values from a struct that is in a table

3 ビュー (過去 30 日間)
Luca Tognetti
Luca Tognetti 2023 年 1 月 31 日
コメント済み: Luca Tognetti 2023 年 1 月 31 日
Hi, I have a table with some data in it and some of them are struct (the table is attached below). I need to extract the value in the column rain, but when I try I'm not able to extract the value because it saves as a struct.
for i = 1:length(data.rain)
if isempty(data.rain{i})
rain(i,1) = {0};
else
rain(i,1) = data.rain(i).x3h;
end
end
this is my script. As you can see from the picture I still have structs instead of the value that is inside it.
Thanks

採用された回答

KSSV
KSSV 2023 年 1 月 31 日
rain = data.rain ;
iwant = zeros(length(rain),1) ;
for i = 1:length(rain)
if ~isempty(rain{i})
iwant(i) = rain{i}.x3h
end
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by