Simple For Loop Problem

1 view (last 30 days)
Sarah
Sarah on 15 Oct 2011
Hey guysss,
I have a relatively simple problem related to For Loops. Let us say I have this bit of code:
[TPV1.Sig, TPV1.Str] = xlsread('CHAMBER TEST TEMP 4 5 6.xlsx',3);
TPV1.Num = datenum(TPV1.Str);
TPV1.Vec = datevec(TPV1.Num);
The thing is, I have about 10-15 signals that I have to process. Rather than spend a lot of time copying/pasting the code 15 times, I want to write a simple for loop that runs this function over and over again, but stores into different variables. For example:
1st Iteration: Returns: TPV1.Sig, TPV1.Str, TPV1.Num, TPV1.Vec
2nd Iteration Returns: TPV2.Sig, TPV2.Str, TPV2.Num, TPV2.Vec
etc etc
I was thinking setting up the for loop to be like:
for N = 1:15,
[TPV*N*.Sig, TPV*N*.Str] = xlsread('CHAMBER TEST TEMP 4 5 6.xlsx',3);
TPV*N*.Num = datenum(TPV*N*.Str);
TPV*N*.Vec = datevec(TPV*N*.Num);
The following code is obviously wrong...and I am not sure if I can successfully do this. Any thoughts, anyone??

Accepted Answer

the cyclist
the cyclist on 15 Oct 2011
The second example in the accepted answer to this question
(cell arrays) should allow you to do what you want.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!