setting y axis to specific values
이전 댓글 표시
UPDATE FROM MY QUESTION BELOW: I should have done a bit of research before posting. Don't know why i didn't assume matlab would have an automatic way to link axes. I have used the linkaxes function to link the left and right axes together and it worked. However, i still would like to apply the (-50,50) as my standard y min and y max. So for example i have the billateral muscles that are linked and have y min and ymax values as (-20,20).
I have a tiled plot and the two plots in question are tiles 1 and 2 with corresponding ax1 and ax2 variables:
% Tile 1
ax1=nexttile
p1=plot(ChannelTitle,LUTbandpass);
xlim([xlim1 xlim2])
% Tile 2
ax2=nexttile
p2=plot(ChannelTitle,RUTbandpass);
xlim([xlim1 xlim2])
linkaxes([ax1 ax2],'y')
The column vectors LUTbandpass and RUTbandpass are what i want to find the max and min of and figure out if either is below the +/- 50 and if so, want to set the y axis to (-50,50)
Hope that makes sense.
Thank you
END EDIT
Hi,
I am curious if my below code can be made more efficent/streamlined. I have two EMG plots from a muscle, one from the right side and one from the left. I want my code to look at the y max and min of both plots and determine which is higher and then set that scale for both plots.
I currently have this for the y max and y min determination:
%ymax
if max(left)<50 && max(right)<50
ymax=50
elseif max(right)>max(left)
ymax=max(right)+.15*(max(right))
else
ymax=max(left)+.15*(max(left))
end
%ymin
if min(left)>-50 && min(right)>-50
ymin=-50
elseif min(right)<min(left)
ymin=min(right)+.15*(min(right))
else
ymin=min(left)+.15*(min(left))
end
I have a set of 8 billateral muscles and don't want to repeat this code over and over.
Once i have the ymax and ymin values i will use them in my overall plot with code:
ylim([ymin ymax])
Any help would be apprecated!
Thank you in advance
댓글 수: 2
Ines Shekhovtsov
2023년 1월 4일
편집: Ines Shekhovtsov
2023년 1월 4일
Voss
2023년 1월 6일
@Ines Shekhovtsov: Have you seen my answer? Do you think it will work for you? Is there anything that doesn't make sense about it?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!