Author Topic: making a while loop  (Read 724 times)

Offline TheGame0135

  • Newbie
  • *
  • Posts: 1
  • Matlab Forum
    • View Profile
making a while loop
« on: July 06, 2010, 05:40:59 PM »
I'm fairly new to MATLAB, and I've been trying to make an m file. What I want this to do is the following...
 
I have a data sheet (effectively could be infinite columns and rows long)
I need to find weighted average of my data.
So for example say I have this data sheet
 
A   B   C
2   0   43
2   0    45
3   2    56
1   3    22
1   4    20
2   5    45
2   7    46
2   8    45
2   9    42
 
Okay so column A is the group they're catagorized in, IE, 0-25 is 1, 25-50 is 2, etc...
column B is seconds notice readings were sometimes taken during the same second therefore it is counted as one.
So what I need to do. Is make a code where I can find weighted average of C compared with time, But i need total time and not just max time minus min time because that doesn't work. and since they have breaks I wanted to be able to do something ot the extent of, in accordance with my fake data sheet, take the first 2 values subtract their time then multiple by the average of the first 2 C's. then go down to the next set of 2's and do the same thing? does this make sense? if not I can try to explain further thanks.
 

Offline hero_hont

  • Newbie
  • *
  • Posts: 12
  • Matlab Forum
    • View Profile
Re: making a while loop
« Reply #1 on: September 07, 2010, 10:11:40 AM »
hello guys.
You need add your data in the excel.
When run matlab, we can call excel processing. That's run good in code long and difficult.
If while loop, you can write code in the function, call up it.

Matlab and SimuLink Development Forum

Re: making a while loop
« Reply #1 on: September 07, 2010, 10:11:40 AM »