How can I modify this contour plot and add arrows?

So I currently have this:
x=0:0.01:1.5;
y=0:0.01:1.5;
T1=100;T0=0;
[X,Y]=meshgrid(x,y);
Z=(T1-T0)*2.*X.*Y+T0;
[cs1,h1]=contour(X,Y,Z,'LevelList',T0:25:T1)
clabel(cs1,h1)
hold on
Z2=(T0-T1).*(X.^2-Y.^2);
[cs2,h2]=contour(X,Y,Z2,'LineColor','#EDB120','LevelStep',10)
The first contour are the isotherms; which is already done and finished.
The second contour are the flow lines, and I want to add small arrowheads on them to indicate the direction. Another thing is that I want to do is to erase the part not needed (in this case above T1 and below T0. How can I do this?

3 Comments

Here is the visualization you forgot to post:
x=0:0.01:1.5;
y=0:0.01:1.5;
T1=100;T0=0;
[X,Y]=meshgrid(x,y);
Z=(T1-T0)*2.*X.*Y+T0;
[cs1,h1]=contour(X,Y,Z,'LevelList',T0:25:T1)
clabel(cs1,h1)
hold on
Z2=(T0-T1).*(X.^2-Y.^2);
[cs2,h2]=contour(X,Y,Z2,'LineColor','#EDB120','LevelStep',10)
I believe you can add arrowheads with the annotation() or quiver() functions.
I already got the part of putting arrowheads using quiver thanks to Star Strider, but the part of erasing the orange lines above the T=100 line is still unclear.
Actually the two funtions are not independent because they're harmonic conjugates. I don't know if this will help at all, but just in case.

Sign in to comment.

 Accepted Answer

Is this what you want to do?
x=0:0.01:1.5;
y=0:0.01:1.5;
T1=100;T0=0;
[X,Y]=meshgrid(x,y);
Z=(T1-T0)*2.*X.*Y+T0;
[cs1,h1]=contour(X,Y,Z,'LevelList',T0:25:T1);
clabel(cs1,h1);
hold on
Z2=(T0-T1).*(X.^2-Y.^2);
Z2(Z > T1 | Z < T0) = NaN;
[cs2,h2]=contour(X,Y,Z2,'LineColor','#EDB120','LevelStep',10);

4 Comments

Yes! And is it possible to put the numeric labels above the orange lines?
Like this (just creating the "Z2" contour first)?
x=0:0.01:1.5;
y=0:0.01:1.5;
T1=100;T0=0;
[X,Y]=meshgrid(x,y);
Z=(T1-T0)*2.*X.*Y+T0;
Z2=(T0-T1).*(X.^2-Y.^2);
Z2(Z > T1 | Z < T0) = NaN;
[cs2,h2]=contour(X,Y,Z2,'LineColor','#EDB120','LevelStep',10);
hold on
[cs1,h1]=contour(X,Y,Z,'LevelList',T0:25:T1);
clabel(cs1,h1);

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2021b

Asked:

on 18 Mar 2022

Commented:

on 18 Mar 2022

Community Treasure Hunt

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

Start Hunting!