Adding Labels to PDE Graph
Show older comments
I was wondering how to add a label to a graph of multiple PDEs.
I want to label each line of the graph differently.
The functions I have are as follows:
function [pl,ql,pr,qr] = heatbc(xl,ul,xr,ur,t)
pl = ul;
ql = 0;
pr = ur;
qr = 0;
end
function u0 = heatic(x)
u0 = x.*(1-x);
end
function [c,f,s] = heatpde(x,t,u,dudx)
c = 1;
f = dudx;
s = 0;
end
With the main code being as such:
x = linspace(0,1,10);
t = [0 0.1 0.2 0.3];
m = 0;
sol = pdepe(m,@heatpde,@heatic,@heatbc,x,t)
u = sol(:,:,1);
plot(x,u);
hold on;
So far the graph looks as such:

I would just like to know how I would code a legend that labels the purple, orange, red and blue lines individually.
Thanks in advance!
Accepted Answer
More Answers (0)
Categories
Find more on General PDEs 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!