Hello all,
I am trying to plot a velocity profile at different locations as shown in the figure. Where I need x=1, x=25, ...x=150 at bottom x-axis and Dia at y-axis and the scale of the data at top x-axis as lables. I have tried to plot, but i am getting an error as 'Unrecognized function or variable 'X_1'.'. I am reading the data from Excel. I have tried with the following code:
data = readtable('Atq16.xlsx');
p1 = plot(X_1 + 1 , Dia ,'r', 'linewidth', 2); hold on; %grid on
p2 = plot(X_25 + 25 , Dia ,'g', 'linewidth', 2);
p3 = plot(X_50 + 50, Dia,'b', 'linewidth', 2);
p4 = plot(X_100 + 100, Dia,'k', 'linewidth', 2);
p5 = plot(X_150 + 150, Dia,'m', 'linewidth', 2);
ylabel('Dia(mm)');
xticks([1 25 50 100 150]);
xticklabels({'x=1','x=25','x=50','x=100','x=150'});
Please kindly do the needful. Thanks in advance.
With regards

 채택된 답변

KSSV
KSSV 2021년 9월 16일

0 개 추천

T = readtable('Atq16.xlsx') ;
data = table2array(T) ;
plot(data(:,2:end),data(:,1),'-or')

댓글 수: 4

Vishnuvardhan Naidu Tanga
Vishnuvardhan Naidu Tanga 2021년 9월 16일
Hello @KSSV,
Thank you for the answer. But I need to seperate each plot with some distance. Is it possible to do like that.
With regards
T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/740479/Atq16.xlsx') ;
p1 = plot(T.X_1 + 1 , T.Dia ,'r', 'linewidth', 2); hold on; %grid on
p2 = plot(T.X_25 + 25 , T.Dia ,'g', 'linewidth', 2);
p3 = plot(T.X_50 + 50, T.Dia,'b', 'linewidth', 2);
p4 = plot(T.X_100 + 100, T.Dia,'k', 'linewidth', 2);
p5 = plot(T.X_150 + 150, T.Dia,'m', 'linewidth', 2);
ylabel('Dia(mm)');
xticks([1 25 50 100 150]);
xticklabels({'x=1','x=25','x=50','x=100','x=150'});
Vishnuvardhan Naidu Tanga
Vishnuvardhan Naidu Tanga 2021년 9월 16일
Thank you so much @KSSV. I have one another doubt. How can i have scale range on top X-axis?
KSSV
KSSV 2021년 9월 16일
Read about text. Or you can do through .fig via gui.

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Annotations에 대해 자세히 알아보기

질문:

2021년 9월 16일

댓글:

2021년 9월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by