Adding Labels to PDE Graph
显示 更早的评论
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!
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 General PDEs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!