Effacer les filtres
Effacer les filtres

Simple For Loop Problem

2 vues (au cours des 30 derniers jours)
Sarah
Sarah le 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??

Réponse acceptée

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

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by