フィルターのクリア

Function Save() and optimizzation

2 ビュー (過去 30 日間)
Salvatore Turino
Salvatore Turino 2011 年 11 月 18 日
Hello i want to optimize my code. i have these 3 matrix:
save H_scorr
save Hscorr_abs
save Hscorr_ang
in exit from a for() cicle, that are all 7x7. Does exist a way to save them in 1 file .mat? Next step is that these three matrix became 12 (4x3matrix all 7x7) and i need to save all of them. Actually the only idea i had to save them all is a simply:
if i==1
H_scorr=Hscorr;
H_scorr_abs=Hscorr_abs;
H_scorr_ang=Hscorr_ang;
save H_scorr
save Hscorr_abs
save Hscorr_ang
end
with the if that is repeated four times but of course i don't like this way....can you help me to optimize this part of my code?
the idea i've had is:
H_scorr(i)=Hscorr;
but i've got this error:
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> prova at 103 H_scorr(i)=Hscorr;
thank you
  2 件のコメント
Swarooph
Swarooph 2011 年 11 月 18 日
Let me reiterate the question to see if I understand this correctly.
1. You want to know how to save 3 different variables in a single MAT file
2. Do you want to save all the 12 matrices separately so that finally your MAT file will have 12 matrices?
Salvatore Turino
Salvatore Turino 2011 年 11 月 19 日
1. yes
2. i want to save the 12 matrices separately so that finally i'll have 4 .mat file with 3 matrices inside (like in point 1), without using 4 "if" cases but only, if it is possibile, the indice i of the for() like a vector/matrix

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

回答 (1 件)

Image Analyst
Image Analyst 2011 年 11 月 18 日
It can be quite informative if you look up the help for functions. That way you'd see how what you want is there in black and white as an example:
save(yourFullMatFileName, 'H_scorr',...
'Hscorr_abs', 'Hscorr_ang');
  1 件のコメント
Salvatore Turino
Salvatore Turino 2011 年 11 月 19 日
Attempt to reference field of non-structure array.
Error in ==> prova at 110
save(Hscorr.mat,'H_scorr','Hscorr_abs', 'Hscorr_ang');
doesn't work.....

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

カテゴリ

Help Center および 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