필터 지우기
필터 지우기

Simple For Loop Problem

조회 수: 2 (최근 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