to calculate minimum or maximum value of dataset
Show older comments
I want to calculate minimum or maximum value of three divisions of set as shown by separation line or described by diff value of fifth coloumn. please help
x_train= [5.1 3.5 1.4 0.2 1
4.9 3.0 1.4 0.2 1
4.7 3.2 1.3 0.2 1
%...........................
6.5 2.8 4.6 1.5 2
5.7 2.8 4.5 1.3 2
6.3 3.3 4.7 1.6 2
4.9 2.4 3.3 1.0 2
%..............................
7.3 2.9 6.3 1.8 3
6.7 2.5 5.8 1.8 3
7.2 3.6 6.1 2.5 3
6.5 3.2 5.1 2.0 3]
[u1,u2,u3,u4,y]=x_train;
x=[u1 u2 u3 u4 y];
for k=1:3
while x(:,5)==k
w_low(k)=min(x(:,1));
w_up(k)=max(x(:,1));
end
end
2 Comments
Azzi Abdelmalek
on 7 Sep 2013
What is x?
Image Analyst
on 7 Sep 2013
He says what x is, but more importantly, what is u1,u2,u3,u4, & y ??? That's not standard MATLAB code. Do you want each of those to be the 2D array x_train?
Accepted Answer
More Answers (1)
Andrei Bobrov
on 7 Sep 2013
Edited: Andrei Bobrov
on 7 Sep 2013
x_s = sortrows(x_train,[5,1]);
c = accumarray(x_s(:,5),x_s(:,1),[],@(x){x([1,end])});
out = cat(2,c{:});
or
c = accumarray(x_train(:,5),x_train(:,1),[],@(x){[min(x) max(x)]});
out = cat(1,c{:});
Categories
Find more on 2-D and 3-D Plots 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!