Plotting multiple lines with a for loop: only last plot shows
Hello everyone!
I am trying to plot my results following Temperatures for a Transient Thermal Model on a Square on https://www.mathworks.com/help/pde/ug/pde.steadystatethermalresults.interpolatetemperature.html. However, the only plot that shows is the one at the end of the t array (t = 952), plus an unlabelled one: could anybody please help me understand what I am doing differently?
X = cell2mat(num2cell(linspace(-3,3,1001)))
class(X)
Y = cell2mat(num2cell(ones(size(X))));
class(Y)
Tintrp = interpolateTemperature(results,X,Y,1:length(tlist))
class(Tintrp)
tf = isvector(Tintrp)
tf = ismatrix(Tintrp)
tf = isnumeric(Tintrp)
Xs = (linspace(-3,3,1001))
Xs = reshape(Xs,[],1)
tf = isvector(Xs)
tf = isnumeric(Xs)
figure
xlabel("x")
ylabel("Tintrp")
t = [2:50:1001]
% for i = t
% Tintrp(:,i)
% tf = isnumeric(Tintrp(:,i))
% p(i) = plot(Xs,Tintrp(:,i),"DisplayName", …
% strcat("t=",num2str(tlist(i))));
% hold on
% end
for i = t
p(i) = plot(Xs,Tintrp(:,i),"DisplayName", …
strcat("t=",num2str(tlist(i))));
legend(p(i))
hold on
end
legendHello everyone!
I am trying to plot my results following Temperatures for a Transient Thermal Model on a Square on https://www.mathworks.com/help/pde/ug/pde.steadystatethermalresults.interpolatetemperature.html. However, the only plot that shows is the one at the end of the t array (t = 952), plus an unlabelled one: could anybody please help me understand what I am doing differently?
X = cell2mat(num2cell(linspace(-3,3,1001)))
class(X)
Y = cell2mat(num2cell(ones(size(X))));
class(Y)
Tintrp = interpolateTemperature(results,X,Y,1:length(tlist))
class(Tintrp)
tf = isvector(Tintrp)
tf = ismatrix(Tintrp)
tf = isnumeric(Tintrp)
Xs = (linspace(-3,3,1001))
Xs = reshape(Xs,[],1)
tf = isvector(Xs)
tf = isnumeric(Xs)
figure
xlabel("x")
ylabel("Tintrp")
t = [2:50:1001]
% for i = t
% Tintrp(:,i)
% tf = isnumeric(Tintrp(:,i))
% p(i) = plot(Xs,Tintrp(:,i),"DisplayName", …
% strcat("t=",num2str(tlist(i))));
% hold on
% end
for i = t
p(i) = plot(Xs,Tintrp(:,i),"DisplayName", …
strcat("t=",num2str(tlist(i))));
legend(p(i))
hold on
end
legend Hello everyone!
I am trying to plot my results following Temperatures for a Transient Thermal Model on a Square on https://www.mathworks.com/help/pde/ug/pde.steadystatethermalresults.interpolatetemperature.html. However, the only plot that shows is the one at the end of the t array (t = 952), plus an unlabelled one: could anybody please help me understand what I am doing differently?
X = cell2mat(num2cell(linspace(-3,3,1001)))
class(X)
Y = cell2mat(num2cell(ones(size(X))));
class(Y)
Tintrp = interpolateTemperature(results,X,Y,1:length(tlist))
class(Tintrp)
tf = isvector(Tintrp)
tf = ismatrix(Tintrp)
tf = isnumeric(Tintrp)
Xs = (linspace(-3,3,1001))
Xs = reshape(Xs,[],1)
tf = isvector(Xs)
tf = isnumeric(Xs)
figure
xlabel("x")
ylabel("Tintrp")
t = [2:50:1001]
% for i = t
% Tintrp(:,i)
% tf = isnumeric(Tintrp(:,i))
% p(i) = plot(Xs,Tintrp(:,i),"DisplayName", …
% strcat("t=",num2str(tlist(i))));
% hold on
% end
for i = t
p(i) = plot(Xs,Tintrp(:,i),"DisplayName", …
strcat("t=",num2str(tlist(i))));
legend(p(i))
hold on
end
legend plotting, pde, for loop MATLAB Answers — New Questions