Structure Assignment to Non-Structure Object Error

I'm trying to reassign structs from a loaded .mat file to a new .mat file.
In a loop I have the new struct I would like to load the information into equating the struct from the older .mat file
The code looks something like this
files = dir('*.mat')
for i= 1:numel(files)
fileName=files(i).name
load (fileName)
newstruct(1).struct = oldstruct.data
save (newstruct)
end
any ideas why I am getting this error?

5 件のコメント

Matt J
Matt J 2013 年 6 月 11 日
編集済み: Matt J 2013 年 6 月 11 日
What error? Please post the error messages.
Kiran Sagar
Kiran Sagar 2016 年 8 月 10 日
I get a similar error while plotting
i_fig = i_fig +1 ;
f_h(i_fig) = figure ;
[axh, axh1, axh2] = plotyy( labeledTerms, PGDerror(labeledTerms),...
labeledTerms, iterV(labeledTerms),...
@semilogy, @plot );
set( axh, 'fontsize', 15, 'xtick', labeledTerms, 'ytickmode', 'auto' )
axh(1).YLabel.String = 'PGD error indicator';
axh(1).XLabel.String = 'Modes';
axh(2).YLabel.String = 'Iterations per mode';
axh(2).YTick = 1:max(iterV);
axh(1).XTick = 0:10:m+1;
Error occurs on the line
axh(1).YLabel.String = 'PGD error indicator';
Walter Roberson
Walter Roberson 2016 年 8 月 10 日
Kiran Sagar: which MATLAB release are you using? plotyy() suggests you might be using R2014a or earlier, which does not allow field reference notation for setting properties. If you are using R2014a or earlier, you would need to change those assignments into set() calls.
Sunil Kumar Patel
Sunil Kumar Patel 2017 年 4 月 4 日
編集済み: Walter Roberson 2017 年 4 月 4 日
if(C(i)<=(p/(1-p*mod(r,round(1/p)))))
countCHs=countCHs+1;
S(i).type=1;
C(cluster).type=S(i).type;
C(cluster).xd=S(i).xd;
C(cluster).yd=S(i).yd;
C(cluster).id=i;
C(cluster).E=S(i).E;
dis(cluster)=sqrt((S(n+1).xd-S(i).xd)^2+(S(n+1).yd-S(i).yd)^2);
cluster=cluster+1;
subplot(2,2,ss), plot(S(i).xd,S(i).yd,'r*');
X=[S(i).xd,S(n+1).xd]; Y=[S(i).yd,S(n+1).yd];
for j=1:1:n
if distance(i,j)<=R && j~=i && S(j).type==0
S(j).type=3;
end
end
I am also facing same problem in this code
Walter Roberson
Walter Roberson 2017 年 4 月 4 日
Sunil Kumar Patel:
In the line
if(C(i)<=(p/(1-p*mod(r,round(1/p)))))
the comparison involving C(i) can only work if C(i) is numeric.
Then a few lines later you use
C(cluster).type=S(i).type;
which tries to use C as a structure.

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

 採用された回答

Walter Roberson
Walter Roberson 2013 年 6 月 11 日

1 投票

The first argument to save() should be a filename. You are passing a structure instead.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by