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

1 view (last 30 days)
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')

Answers (2)

Dyuman Joshi
Dyuman Joshi on 18 Mar 2024
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 on 18 Mar 2024
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.

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!