Info
この質問は閉じられています。 編集または回答するには再度開いてください。
Loading multiple .mat or Excel files and maniplulate them in a double for loop
2 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I've got 3 .mat files, saved in an excel format as well with a size each 4x1.
These are var1, var2 and var3.
I'd like to load those three .mat files within a for loop and then multiply them by a vector with changing values (hence the double for loop) and at the end create a single .mat file.
My code until now looks like
n=3
A=4
for i=1:n
fr= fractions(:,i)./sum(fractions(:,1:n),2) %%where the fractions matrix is a 4*3 matrix
load(['var' int2str(i)]) %%%I assume I need something additional here
for j=1:A
Var = ???
% I want to multiply fr(j) by each var, i.e. I'd like to
multiply fr(j) for i=1 with var1, then for the second
external loop I want to multiply fr(j) for i=2 with var2
and so on
end
end
--------------------------------------------------
Any thoughts please?
0 件のコメント
回答 (1 件)
dpb
2015 年 5 月 28 日
編集済み: dpb
2015 年 5 月 28 日
fr=bxsfun(@rdivide,fractions,sum(fractions,2)); % ratios
for i=1:N % get the three arrays
load ['var' int2str(i)]];
end
res=[var1 var2 var3].*fr;
save res
ADDENDUM This illustrates the problem inherent in using variable names of the type VarN; once you get 'em that way, it's not easy to do anything with 'em. See the FAQ on ways around it; for the immediate case with a limited number I just went ahead brute force, but it's a bad habit to get into...
0 件のコメント
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!