Simple For Loop Problem

1 次查看(过去 30 天)
Sarah
Sarah 2011-10-15
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??

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by