finding nth elements in multiple arrays
이전 댓글 표시
I have multiple cell arrays: [93x2 double] [216x2 double] [128x2 double][121x2 double] [ 90x2 double] ...so on. These correspond to XY plots,
plot(a{i}(:,1),a{i}(:,2))
opens a plot which looks as fig attached. I want to get the Y values at 1/4th, 1/2 and 3/4th of X for all cells. How can I go about doing this?
Thanks
댓글 수: 4
KSSV
2016년 11월 7일
Why don't you merge all the cells into single matrix and get what you want?
Walter Roberson
2016년 11월 7일
So for the 93x2 double array, would the "1/4 of X" be at index (round(93/4),2), or would it be a matter of determining where min(X) + (max(X)-min(X))/4 is in the vector and taking the corresponding Y?
If the X coordinates are equally spaced then the two are equivalent; if the X coordinates are not equally spaced then we need to know whether you mean 1/4 by position or 1/4 by range.
BoIs
2016년 11월 7일
BoIs
2016년 11월 7일
채택된 답변
추가 답변 (1개)
KSSV
2016년 11월 7일
a = {rand(93,2) ;rand(216,2) ; rand(128,2) ; rand(121,2) ; rand(90,2)} ;
data = cell2mat(a) ;
% plot(data(:,1),data(:,2),'r') ;
N = length(data) ;
%%1/4th value
data(N/4,:)
%%1/2 value
data(N/2,:)
%%3/4th value
data(3*N/4,:)
Note that N should be divisible by 1/4,1/2 and 3/4. In this case it was. If not you should use fix. For Ex. data(fix(N/4),:) etc.
카테고리
도움말 센터 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!