# Changing 2D line graph into 3D graph by adding an axes from a condition

1 view (last 30 days)
Meva on 19 May 2015
Commented: Nalini Vishnoi on 20 May 2015
Hi,
I have my main script with a nested function. p2 is array valued and it is calculated in the main script and nested function as well. To find corresponding p2 array values I use specific time using if condition. My main script is like this:
...
dt =0.0001;
dx=0.001;
ii= (1/dx) +1 *% = 1001;*
for nt=1:30001;
...
for i=1:ii
x(i) = (i-1)*dx;
end
t=(nt-1)*dt; *% TIME !!!*
..
[p2] = p_thick(ii,dx,dt,...); % THIS IS P2. IT IS AN ARRAY VALUED FUNCTION (1*ii)
...
if nt==1001 *% TIME CONDITION*
[p2smallregion] = small_time();
k=2*(t/dx) +1;
figure(1) *% PLOTTING IN TIME 0.1*
plot(x(1:k),p2(1:k),'LineWidth', 1.5);
hold on
plot(x(1:k),p2smallregion(1:k),'r--','LineWidth',1.5)
xlabel('x')
% ylabel('p2s')
..
end
end
And my nested function like this:
function [p2smallregion] = small_time()
dx = 0.001;
ii=(1/dx)+1;
...
...
for nt = 1:30001; % SAME THE NUMBER OF TIME STEPS
t=(nt-1)*dt;
if nt ==1001; % SAME TIME CONDITION GOES HERE
k=2*(t/dx) +1;
for j=1:k
m(j) = (j-1)*dx;
if m(j)<t
p2smallregion(j)=beta1*m(j))+t*2*beta1*alphabar;
else
p2smallregion(j) = t^2*alphabar*m(j);
end
end
end
THE QUESTION IS: As you can see I can plot p2 values from main script and nested function in the same plot in a specific time say=0.1. But How can I plot this in different time values in the same plot? 3D plot with colourbar time range between 0.01 and 0.1 with 11 time values??? Please see attached. I would like to get exactly like attached.
Nalini Vishnoi on 20 May 2015
Your question is not clear and the attachment is missing. Can you attach the desired figure? Also, if possible, attach a figure of what you have been able to accomplish so far.