How can I load lots of files with a for loop and then multiply them by a vector

Hello all,
I've got three .mat files each with size 100x1
variable1_data.mat
variable2_data.mat
variable3_data.mat
I also have those files in an xlsx format
(variable1_data.xlsx, variable2_data.xlsx, variable3_dta.xlsx)
********************************
I want
1. to load them simultaneously with a for loop into my code and
2. to multiply them with a known vector called fr
***********************************
My code until now is:
N=3
for i=1:N
fr = fraction(:,1)/sum(fractions(:,1:N),2) % where fractions is a 100x 3 matrix
for j=1:100
??????? unknown part
end
end
***********************************
At the end I'd like to have a matrix called variable with size 100x1
Any ideas on that?
Many thanks!

 채택된 답변

Dasharath Gulvady
Dasharath Gulvady 2015년 5월 28일
편집: Dasharath Gulvady 2015년 5월 29일
Assuming that all the MAT files have same data(let's say "mydata"):
N=3
for i=1:N
toLoad = sprintf('variable%d_data.mat',i);
load(toLoad);
fr*mydata
end
If this does not answer your question, explain what exactly you are looking for

댓글 수: 1

Thank you for your response.
Actually, this not not exactly what I'm looking for, because my fr changes as well within the for loop, but it's close to what I was looking for.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2015년 5월 27일

편집:

2015년 5월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by