フィルターのクリア

Storing values in cell instead of struct

1 回表示 (過去 30 日間)
Ayesha
Ayesha 2014 年 5 月 3 日
編集済み: per isakson 2014 年 5 月 3 日
Hello,
So I've been wondering about an alternate way to store a whole bundle of information as double instead of struct. This is what I did with struct and I just want to convert the datatype to double.
%Save Data information in a file
A(1).f3=f3;
A(2).f2=f2;
A(3).fL3=fL3;
A(4).fH3=fH3;
A(5).f1_fH3=f1_fH3;
A(6).f2_fH3=f2_fH3;
A(7).ffL3=ffL3;
A(8).fHL3=fHL3;
A(9).fH2_fHL3=fH2_fHL3;
A(10).ff3=ff3;
A(11).f13=f13;
A(12).fH2_fLH3=fH2_fLH3;
A(13).fHH2=fHH2;
A(14).fH1_fHH2=fH1_fHH2;
A(15).fH2_fHH2=fH2_fHH2;
save(Route, 'A');
I'm doing this since I've to pass Route as an argument to a function which I realized does not accept struct and is giving me the error while performing logic and arithmetic operations. Any suggestions?

採用された回答

per isakson
per isakson 2014 年 5 月 3 日
編集済み: per isakson 2014 年 5 月 3 日
Try something like
save( Route, '-regexp', '^f\w*\d$' );
this should save all variables, the name of which start with "f" and ends with a number. Or did I miss your question?
.
"convert the datatype to double" . f2, f3, etc. are they not already double? double(f3) converts to double.
.
"values in cell instead"
A = cell( 15, 1 );
A(1) = {f3};
A(2) = {f2};
A(3) = {fL3};
A(4) = {fH3};
A(5) = {f1_fH3};
A(6) = {f2_fH3};
A(7) = {ffL3};
A(8) = {fHL3};
A(9) = {fH2_fHL3};
A(10) = {ff3};
A(11) = {f13};
A(12) = {fH2_fLH3};
A(13) = {fHH2};
A(14) = {fH1_fHH2};
A(15) = {fH2_fHH2};
  2 件のコメント
Ayesha
Ayesha 2014 年 5 月 3 日
Yes, you did but Thanks for replying. There is nothing wrong with the code I've mentioned above. All the variables are double. But when you execute them, 'Route' gets saved as struct. I just want to save it as double. What do you think?
per isakson
per isakson 2014 年 5 月 3 日
編集済み: per isakson 2014 年 5 月 3 日
I think
save( Route, '-regexp', '^f\w*\d$' );
does that. Try
whos -file Route.mat
.
"'Route' gets saved as struct" . How do you know?
.
Maybe you should rephrase the question?

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

その他の回答 (0 件)

カテゴリ

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