How can I replace data on the axis to become u horizontal and y vertical?

조회 수: 1 (최근 30일)
Shreen El-Sapa
Shreen El-Sapa 2024년 3월 18일
답변: Hassaan 2024년 3월 18일
y = 0:0.01:5;
t1=0.1; t2=3;t3=5;t4=10;
nu = 5;
u0=1;
figure(1)
hold on
u1 = u0.*erfc(y./2.*sqrt(nu*t1));
u2 = u0.*erfc(y./2.*sqrt(nu*t2));
u3 = u0.*erfc(y./2.*sqrt(nu*t3));
u4 = u0.*erfc(y./2.*sqrt(nu*t4));
plot(y,u1,'-',y,u2,'--',y,u3,'-.',y,u4,':','LineWidth',2)
grid on
xlabel('y');
ylabel('u(y,t)');
legend('t = 0.1','t = 3','t = 5','t = 10','Location','best')
%title('Velocity distributions at different t')

답변 (2개)

Dyuman Joshi
Dyuman Joshi 2024년 3월 18일
Use -
plot(u1,y,'-',u2,y,'--',u3,y,'-.',u4,y,':','LineWidth',2)
Note the syntax for plotting x and y data using plot is -
plot(x_data, y_data)

Hassaan
Hassaan 2024년 3월 18일
y = 0:0.01:5;
t1=0.1; t2=3; t3=5; t4=10;
nu = 5;
u0=1;
figure(1)
hold on
u1 = u0.*erfc(y./2.*sqrt(nu*t1));
u2 = u0.*erfc(y./2.*sqrt(nu*t2));
u3 = u0.*erfc(y./2.*sqrt(nu*t3));
u4 = u0.*erfc(y./2.*sqrt(nu*t4));
% Switch the order of u and y in the plot function
plot(u1, y, '-', u2, y, '--', u3, y, '-.', u4, y, ':', 'LineWidth', 2)
grid on
% Update labels accordingly
xlabel('u(y,t)');
ylabel('y');
legend('t = 0.1', 't = 3', 't = 5', 't = 10', 'Location', 'best')
title('Velocity distributions at different t')
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
It's important to note that the advice and code are based on limited information and meant for educational purposes. Users should verify and adapt the code to their specific needs, ensuring compatibility and adherence to ethical standards.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
Feel free to contact me.

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by