Cant read data from a structure

6 ビュー (過去 30 日間)
divya r
divya r 2012 年 6 月 18 日
s_c_1 is a 1*96 row vector.It is stored as a structure variable of 1*1. How do i access the data in the vector? I have tries to do so using a loop in line 8, but its giving an error :" reference to non-existent field name".
folder='C:\Users\Divya\Desktop\matfiles\';
s=dir(folder);
s([s.isdir])=[];
rows=length(s);
s_c=fullfile(folder,'1_1_1.mat');
s_c_1=load(s_c);
disp(s_c_1);
for i=1:1:96
disp(s_c_1(i).name);
end
  2 件のコメント
divya r
divya r 2012 年 6 月 18 日
I think s_c_1 is stored as a cell array of 1*1
divya r
divya r 2012 年 6 月 18 日
s_c_1 is stored as a cell array of 1*96 not 1*1

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

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 6 月 18 日
"s" is the structure that has the field named "name".
The fieldnames for "s_c_1" are the names of the variable that are in the .mat file. "s_c_1" will not be a cell array.
After the load() statement, examine
class(s_c_1)
fieldnames(s_c_1)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by