Building a matrix inside a for loop
Show older comments
Hi guys, can anyone help me with this please. Thanks.
So i have this Excel file. I filtered a column and then did some operations on the filtered data .
in the end, I wanna create a new matix, A, with the following characteristics. The matrix should have dimension: partID rows* 5 columns. First colum should contain the partID number (from 3 to 15), second column should contain the value of M associated with the partID, third column S, fourth m and fifth s.
how do i build A inside the cycle?
6 Comments
Turlough Hughes
on 15 May 2020
Can you share the file?
Murstoe
on 15 May 2020
Turlough Hughes
on 23 May 2020
Murstoe, it's bad form to remove your question after being given an answer. Can you put it back?
Stephen23
on 23 May 2020
Original question from Google Cache:
"Building a matrix inside a for loop"
Hi guys, can anyone help me with this please. Thanks.
So i have this Excel file. I filtered a column and then did some operations on the filtered data .
in the end, I wanna create a new matix, A, with the following characteristics. The matrix should have dimension: partID rows* 5 columns. First colum should contain the partID number (from 3 to 15), second column should contain the value of M associated with the partID, third column S, fourth m and fifth s.
how do i build A inside the cycle?
xlsData = xlsread('PartS_all.csv');
partID=xlsData(:,4);
for partID=3:15
tenpm=xlsData(xlsData(:,4)==partID,:);
part=sortrows(tenpm, 2); %Sort second column
M(partID)=mean(part(:,8));
S(partID)=std(part(:,8));
m(partID)=mean(part(:,11));
s(partID)=std(part(:,11));
A=
end
Murstoe
on 23 May 2020
Rena Berman
on 1 Jun 2020
(Answers Dev) Restored edit
Accepted Answer
More Answers (0)
Categories
Find more on Data Import from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!