Sorting out an entire table with index

조회 수: 4 (최근 30일)
Yannick Tabot Njami
Yannick Tabot Njami 2019년 3월 15일
댓글: Yannick Tabot Njami 2019년 3월 15일
Dear ALL,
Basically i want to generate 4 figure windows each having 8 graphs on it corresponding to the cases when y=[20 50 80 110 140 170 200 230]
For each case i need to get the index of y pass it to each of the last four columns of the table to get the corressponding values and the x coorinate at which they occure. making them now pairs of( x,y) and then make a plot for each 4 columns. I.e plot (x, mean velocity), (x,stdvelocity), (x,mean_pd), (x,std_pd)
I did that for the first case for y=20 and the resulting grapgh was good see attachment.
Please how do i extend that to the remaining columns? perhaps a for loop and how can i pass the yindex to the the table?
attached is my data,first figure and below is my code :
many thanks in advancedataplot.png
Generating the table of average values
Average_Table = table(xcoordinate,ycoordinate,mean_velocity,std_velocity, mean_pd ,std_pd);
for jj = 20 :30 :230
yindex=find(ycoordinate == jj);
% Deleting the first index to eliminat the offset value at y=20
if jj ==20
yindex(yindex==1)=[];
end
% getting the indices corresponding to each case.
newX=(xcoordinate(yindex));
newY =mean_velocity(yindex);
% table of newx and newY
tableXY =[newX newY];
% soting out the table in descending order
sortedtable =zeros(length(tableXY),2);
sortedtable(:,1)=sort(tableXY(:,1));
sortedX = sortedtable (:,1);
for N =1:length(tableXY)
sortedtable(N,2) =tableXY(find(ismember(tableXY(:,1),sortedtable(N))),2);
% sorted Y coordinates
sortedY = sortedtable(:,2);
end
hold on
plot(sortedX,sortedY,'color',rand(1 ,3),'marker','*','DisplayName',['Y =',num2str(jj)]);
xlabel('x position');
ylabel('mean velocity');
legend show
%
drawnow;
end
  댓글 수: 2
Guillaume
Guillaume 2019년 3월 15일
Is this in any way different to your previous question?
Yannick Tabot Njami
Yannick Tabot Njami 2019년 3월 15일
Hello Guillaume, its the same question. the code you proded did run but the out put was not what i expected. i expected 4 plots each with 8 lines. please i guuess not its more understandable since i have my data,first plot and entire code uploaded....

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by