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

New to MATLAB?

Thread Subject:
loop problem

Subject: loop problem

From: Isabel

Date: 3 Nov, 2012 19:56:10

Message: 1 of 2

Even though I can guess the problem here is about the definition of "a", I don't know how to solve the following error:

for i = datenum(2012,9,18,7,08,00):datenum(0,0,0,0,0,1):datenum(2012,9,18,7,28,00); a=1:1200
        RE_7h23_T(a,:) = [i sum(RE_7h23_ID_T_timesorted(find (RE_7h23_ID_T_timesorted(:,1) == RE_7h23_ID_T_timesorted(1,1)),3))];

I can manage to do one line, but I don't know how to fix my matrix for every value of a!

help please! thank you

Subject: loop problem

From: Roger Stafford

Date: 3 Nov, 2012 21:34:13

Message: 2 of 2

"Isabel " <> wrote in message <k73ssq$o6$>...
> for i = datenum(2012,9,18,7,08,00):datenum(0,0,0,0,0,1):datenum(2012,9,18,7,28,00); a=1:1200
> RE_7h23_T(a,:) = [i sum(RE_7h23_ID_T_timesorted(find (RE_7h23_ID_T_timesorted(:,1) == RE_7h23_ID_T_timesorted(1,1)),3))];
> end
- - - - - - - - - -
  It isn't clear what result you expect in RE_7h23_T. As your code is at present, at each step in the for-loop you have a two-element vector on the right to be assigned simultaneously to a matrix on the right with 1200 rows. This won't work. The sum on the right side will always be the same so it isn't clear why you need the for-loop. How many rows is RE_7h23_T expected to have?

Roger Stafford

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