Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
help with allocation of variables in for loop within another for loop

Subject: help with allocation of variables in for loop within another for loop

From: david

Date: 1 Jun, 2011 17:15:08

Message: 1 of 1


I'm trying to allocate different values for parameters in a for loop, but having serious problems implementing it, any help would be much appreciated.

The code is below, that is the code before the variables M and N are assigned, as assigning them is where the problem is arising.

for i=M:N:M+N
      if res ==1

The function ema is one of my own, however is not complicated, and not where the issue is arising.

The matrix "data" is a MxN matrix where the first column is of the format date,hour,minute,second in matlab numeric format.
I would like to assign M as being the all the values in data corresonding to 5 days of data before N which is 1 day of data.
 i.e. M=length(data(days(i:i+4)))
The above obviously doesn't work as there is data from multiple months, also I wish to exclude weekends.
The other problem is that the number of data points in a day are not uniform in this dataset, so I need to re-allocate values to M&N for the for loop above, however I cannot for the life of me figure out the best way to do this.
Any ideas? if you think you can help & need more info, just let me know.


Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us