MATLAB Answers

Contour plot error using a while code

6 views (last 30 days)
asd ad
asd ad on 18 Aug 2020
Commented: Rena Berman on 12 Oct 2020 at 17:22
Hello everyone,
I would like to plot a contour plot with t(a) as my z axis (colourbar), RLL as my y axis and R as my x axis. I'm getting an error showing:
" Error using contourf (line 57)
Number of values in 'XData' and 'YData' must equal the number of columns and rows in 'ZData',
respectively."
How do I fix this error? I have attached my code below.
Thanks
clear all
close all
clc
%% Input Variables
R1 = 0; R2 = 125; R3 = 130; R4 = 140; R5 = 150; R6 = 160; R7 = 170; R8 = 180;
R9 = 190; R10 = 200; R11 = 210; R12 = 220; R13 = 230; R14 = 240; R15 = 250; R16 = 260; R17 = 270;
L1 = 0; L2 = 1.25; L3 = 2.5; L4 = 3.75; L5 = 5; L6 = 6.25; L7 = 7.5; L8 = 8.75; L9 = 10;
L10 = 11.25; L11 = 12.5; L12 = 13.75; L13 = 15; L14 = 16.25; L15 = 17.5; L16 = 18.75; L17 = 20;
R = [R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17];
tInitial = 0; % initial time [s]
tStep = 1; %time step [s]
IWR = R/2; %initial wetted radius [m]
IV = (4/3)*IWR^3; %initial droplet volume[m^3]
Rho = 1000; %density [kg/m^3]
T = 23.5; %temperature [celsius]
RH = [73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00;
71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50;
70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17;
68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70;
67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34;
64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19;
61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36;
58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53;
55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38;
49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72;
43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74;
37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76;
32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09;
23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60;
15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73;
7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87;
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00];; %relative humidity
RL = [R1*L1 R2*L1 R3*L1 R4*L1 R5*L1 R6*L1 R7*L1 R8*L1 R9*L1 R10*L1 R11*L1 R12*L1 R13*L1 R14*L1 R15*L1 R16*L1 R17*L1;
R1*L2 R2*L2 R3*L2 R4*L2 R5*L2 R6*L2 R7*L2 R8*L2 R9*L2 R10*L2 R11*L2 R12*L2 R13*L2 R14*L2 R15*L2 R16*L2 R17*L2;
R1*L3 R2*L3 R3*L3 R4*L3 R5*L3 R6*L3 R7*L3 R8*L3 R9*L3 R10*L3 R11*L3 R12*L3 R13*L3 R14*L3 R15*L3 R16*L3 R17*L3;
R1*L4 R2*L4 R3*L4 R4*L4 R5*L4 R6*L4 R7*L4 R8*L4 R9*L4 R10*L4 R11*L4 R12*L4 R13*L4 R14*L4 R15*L4 R16*L4 R17*L4;
R1*L5 R2*L5 R3*L5 R4*L5 R5*L5 R6*L5 R7*L5 R8*L5 R9*L5 R10*L5 R11*L5 R12*L5 R13*L5 R14*L5 R15*L5 R16*L5 R17*L5;
R1*L6 R2*L6 R3*L6 R4*L6 R5*L6 R6*L6 R7*L6 R8*L6 R9*L6 R10*L6 R11*L6 R12*L6 R13*L6 R14*L6 R15*L6 R16*L6 R17*L6;
R1*L7 R2*L7 R3*L7 R4*L7 R5*L7 R6*L7 R7*L7 R8*L7 R9*L7 R10*L7 R11*L7 R12*L7 R13*L7 R14*L7 R15*L7 R16*L7 R17*L7;
R1*L8 R2*L8 R3*L8 R4*L8 R5*L8 R6*L8 R7*L8 R8*L8 R9*L8 R10*L8 R11*L8 R12*L8 R13*L8 R14*L8 R15*L8 R16*L8 R17*L8;
R1*L9 R2*L9 R3*L9 R4*L9 R5*L9 R6*L9 R7*L9 R8*L9 R9*L9 R10*L9 R11*L9 R12*L9 R13*L9 R14*L9 R15*L9 R16*L9 R17*L9;
R1*L10 R2*L10 R3*L10 R4*L10 R5*L10 R6*L10 R7*L10 R8*L10 R9*L10 R10*L10 R11*L10 R12*L10 R13*L10 R14*L10 R15*L10 R16*L10 R17*L10;
R1*L11 R2*L11 R3*L11 R4*L11 R5*L11 R6*L11 R7*L11 R8*L11 R9*L11 R10*L11 R11*L11 R12*L11 R13*L11 R14*L11 R15*L11 R16*L11 R17*L11;
R1*L12 R2*L12 R3*L12 R4*L12 R5*L12 R6*L12 R7*L12 R8*L12 R9*L12 R10*L12 R11*L12 R12*L12 R13*L12 R14*L12 R15*L12 R16*L12 R17*L12;
R1*L13 R2*L13 R3*L13 R4*L13 R5*L13 R6*L13 R7*L13 R8*L13 R9*L13 R10*L13 R11*L13 R12*L13 R13*L13 R14*L13 R15*L13 R16*L13 R17*L13;
R1*L14 R2*L14 R3*L14 R4*L14 R5*L14 R6*L14 R7*L14 R8*L14 R9*L14 R10*L14 R11*L14 R12*L14 R13*L14 R14*L14 R15*L14 R16*L14 R17*L14;
R1*L15 R2*L15 R3*L15 R4*L15 R5*L15 R6*L15 R7*L15 R8*L15 R9*L15 R10*L15 R11*L15 R12*L15 R13*L15 R14*L15 R15*L15 R16*L15 R17*L15;
R1*L16 R2*L16 R3*L16 R4*L16 R5*L16 R6*L16 R7*L16 R8*L16 R9*L16 R10*L16 R11*L16 R12*L16 R13*L16 R14*L16 R15*L16 R16*L16 R17*L16;
R1*L17 R2*L17 R3*L17 R4*L17 R5*L17 R6*L17 R7*L17 R8*L17 R9*L17 R10*L17 R11*L17 R12*L17 R13*L17 R14*L17 R15*L17 R16*L17 R17*L17];
RLL = RL/2;
%% Initialising
h = ((sqrt(pi^2*IWR^6 + 9*IV^2) + 3*IV)^(2/3) - pi^(2/3)*IWR^2)/(pi^(1/3)*(sqrt(pi^2*IWR^6 + 9*IV^2) + 3*IV)^(1/3)); %height of the droplet [m]
ICAR = 2*atan(h/IWR); % initial contact angle [radians]
ICAD = ICAR*180/pi; % initial contact angle [degrees]
D_T = 2.5e-4*exp(-684.15/(T+273.15)); %diffuson coefficient [m^2/s]
c_sat = (9.99e-7)*T^3 - (6.94e-5)*T^2 + (3.2e-3)*T - 2.87e-2; %saturation concentration [kg/m^3]
%% Calculation
t = tInitial; %initial time [s]
CAR = ICAR; %contact angle for the start of while loop [radians]
CAD = ICAD; %contact angle for the start of while loop[degrees]
M = IV*Rho; %initial mass flow rate [kg/m^3]
V = IV; %initial droplet volume for start of while loop [m^3]
Vmm3 = V*1e9; %initial droplet volume for start of while loop [mm^3]
WR = IWR; %initial droplet wetted radius [m]
WRmm = WR*1000; %initial droplet wetted radius [mm]
a=1;
while V(a) > 0
t(a+1) = a*tStep;
M_dot(a) = -pi*WR(a)*D_T*(1 - RH)*c_sat*(0.27*CAR(a)^2+1.30); %mass flow rate [kg/s]
M(a+1) = M(a) + M_dot(a)*tStep; %mass loss at each time step [kg]
V(a+1) = M(a+1)/Rho; %new volume [m^3]
Vmm3(a+1) = V(a+1)*1e9; %new volume [mm^3]
WR(a+1) = IWR; %constant wetted radius [m]
WRmm(a+1) = WR(a+1)*1000; %constant wetted radius [mm]
h(a+1) = ((sqrt(pi^2*WR(a+1)^6 + 9*V(a+1)^2) + 3*V(a+1))^(2/3) - pi^(2/3)*WR(a+1)^2)/(pi^(1/3)*(sqrt(pi^2*WR(a+1)^6 + 9*V(a+1)^2) + 3*V(a+1))^(1/3)); %height of the droplet [m]
CAR(a+1) = 2*atan(h(a+1)/WR(a+1)); %new contact angle [radians]
CAD(a+1) = CAR(a+1)*180/pi; %new contact angle [degrees]
a = a + 1; %increasing time by 1 second for every loop
end
%% Plotting
a = 1:a-1;
contourf(RLL,R,t(a))
k = colorbar;
cmap = colormap;
ax = gca;
ax.Color = cmap(1, :);
k.Label.String = 'Evaporation Time (s)';
xlabel('Length (\mum)')
ylabel('Diameter (\mum)')

  6 Comments

Show 3 older comments
asd ad
asd ad on 18 Aug 2020
Okay thank you. I'll try again. Thanks for your suggestions.
Rik
Rik on 20 Aug 2020
Question body retrieved from Google Cache:
Hello everyone,
I would like to plot a contour plot with t(a) as my z axis (colourbar), RLL as my y axis and R as my x axis. I'm getting an error showing:
" Error using contourf (line 57)
Number of values in 'XData' and 'YData' must equal the number of columns and rows in 'ZData',
respectively."
How do I fix this error? I have attached my code below.
Thanks
clear all
close all
clc
%% Input Variables
R1 = 0; R2 = 125; R3 = 130; R4 = 140; R5 = 150; R6 = 160; R7 = 170; R8 = 180;
R9 = 190; R10 = 200; R11 = 210; R12 = 220; R13 = 230; R14 = 240; R15 = 250; R16 = 260; R17 = 270;
L1 = 0; L2 = 1.25; L3 = 2.5; L4 = 3.75; L5 = 5; L6 = 6.25; L7 = 7.5; L8 = 8.75; L9 = 10;
L10 = 11.25; L11 = 12.5; L12 = 13.75; L13 = 15; L14 = 16.25; L15 = 17.5; L16 = 18.75; L17 = 20;
R = [R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17;
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17];
tInitial = 0; % initial time [s]
tStep = 1; %time step [s]
IWR = R/2; %initial wetted radius [m]
IV = (4/3)*IWR^3; %initial droplet volume[m^3]
Rho = 1000; %density [kg/m^3]
T = 23.5; %temperature [celsius]
RH = [73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00 73.00;
71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50 71.50;
70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17 70.17;
68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70 68.70;
67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34 67.34;
64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19 64.19;
61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36 61.36;
58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53 58.53;
55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38 55.38;
49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72 49.72;
43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74 43.74;
37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76 37.76;
32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09 32.09;
23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60 23.60;
15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73 15.73;
7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87 7.87;
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00];; %relative humidity
RL = [R1*L1 R2*L1 R3*L1 R4*L1 R5*L1 R6*L1 R7*L1 R8*L1 R9*L1 R10*L1 R11*L1 R12*L1 R13*L1 R14*L1 R15*L1 R16*L1 R17*L1;
R1*L2 R2*L2 R3*L2 R4*L2 R5*L2 R6*L2 R7*L2 R8*L2 R9*L2 R10*L2 R11*L2 R12*L2 R13*L2 R14*L2 R15*L2 R16*L2 R17*L2;
R1*L3 R2*L3 R3*L3 R4*L3 R5*L3 R6*L3 R7*L3 R8*L3 R9*L3 R10*L3 R11*L3 R12*L3 R13*L3 R14*L3 R15*L3 R16*L3 R17*L3;
R1*L4 R2*L4 R3*L4 R4*L4 R5*L4 R6*L4 R7*L4 R8*L4 R9*L4 R10*L4 R11*L4 R12*L4 R13*L4 R14*L4 R15*L4 R16*L4 R17*L4;
R1*L5 R2*L5 R3*L5 R4*L5 R5*L5 R6*L5 R7*L5 R8*L5 R9*L5 R10*L5 R11*L5 R12*L5 R13*L5 R14*L5 R15*L5 R16*L5 R17*L5;
R1*L6 R2*L6 R3*L6 R4*L6 R5*L6 R6*L6 R7*L6 R8*L6 R9*L6 R10*L6 R11*L6 R12*L6 R13*L6 R14*L6 R15*L6 R16*L6 R17*L6;
R1*L7 R2*L7 R3*L7 R4*L7 R5*L7 R6*L7 R7*L7 R8*L7 R9*L7 R10*L7 R11*L7 R12*L7 R13*L7 R14*L7 R15*L7 R16*L7 R17*L7;
R1*L8 R2*L8 R3*L8 R4*L8 R5*L8 R6*L8 R7*L8 R8*L8 R9*L8 R10*L8 R11*L8 R12*L8 R13*L8 R14*L8 R15*L8 R16*L8 R17*L8;
R1*L9 R2*L9 R3*L9 R4*L9 R5*L9 R6*L9 R7*L9 R8*L9 R9*L9 R10*L9 R11*L9 R12*L9 R13*L9 R14*L9 R15*L9 R16*L9 R17*L9;
R1*L10 R2*L10 R3*L10 R4*L10 R5*L10 R6*L10 R7*L10 R8*L10 R9*L10 R10*L10 R11*L10 R12*L10 R13*L10 R14*L10 R15*L10 R16*L10 R17*L10;
R1*L11 R2*L11 R3*L11 R4*L11 R5*L11 R6*L11 R7*L11 R8*L11 R9*L11 R10*L11 R11*L11 R12*L11 R13*L11 R14*L11 R15*L11 R16*L11 R17*L11;
R1*L12 R2*L12 R3*L12 R4*L12 R5*L12 R6*L12 R7*L12 R8*L12 R9*L12 R10*L12 R11*L12 R12*L12 R13*L12 R14*L12 R15*L12 R16*L12 R17*L12;
R1*L13 R2*L13 R3*L13 R4*L13 R5*L13 R6*L13 R7*L13 R8*L13 R9*L13 R10*L13 R11*L13 R12*L13 R13*L13 R14*L13 R15*L13 R16*L13 R17*L13;
R1*L14 R2*L14 R3*L14 R4*L14 R5*L14 R6*L14 R7*L14 R8*L14 R9*L14 R10*L14 R11*L14 R12*L14 R13*L14 R14*L14 R15*L14 R16*L14 R17*L14;
R1*L15 R2*L15 R3*L15 R4*L15 R5*L15 R6*L15 R7*L15 R8*L15 R9*L15 R10*L15 R11*L15 R12*L15 R13*L15 R14*L15 R15*L15 R16*L15 R17*L15;
R1*L16 R2*L16 R3*L16 R4*L16 R5*L16 R6*L16 R7*L16 R8*L16 R9*L16 R10*L16 R11*L16 R12*L16 R13*L16 R14*L16 R15*L16 R16*L16 R17*L16;
R1*L17 R2*L17 R3*L17 R4*L17 R5*L17 R6*L17 R7*L17 R8*L17 R9*L17 R10*L17 R11*L17 R12*L17 R13*L17 R14*L17 R15*L17 R16*L17 R17*L17];
RLL = RL/2;
%% Initialising
h = ((sqrt(pi^2*IWR^6 + 9*IV^2) + 3*IV)^(2/3) - pi^(2/3)*IWR^2)/(pi^(1/3)*(sqrt(pi^2*IWR^6 + 9*IV^2) + 3*IV)^(1/3)); %height of the droplet [m]
ICAR = 2*atan(h/IWR); % initial contact angle [radians]
ICAD = ICAR*180/pi; % initial contact angle [degrees]
D_T = 2.5e-4*exp(-684.15/(T+273.15)); %diffuson coefficient [m^2/s]
c_sat = (9.99e-7)*T^3 - (6.94e-5)*T^2 + (3.2e-3)*T - 2.87e-2; %saturation concentration [kg/m^3]
%% Calculation
t = tInitial; %initial time [s]
CAR = ICAR; %contact angle for the start of while loop [radians]
CAD = ICAD; %contact angle for the start of while loop[degrees]
M = IV*Rho; %initial mass flow rate [kg/m^3]
V = IV; %initial droplet volume for start of while loop [m^3]
Vmm3 = V*1e9; %initial droplet volume for start of while loop [mm^3]
WR = IWR; %initial droplet wetted radius [m]
WRmm = WR*1000; %initial droplet wetted radius [mm]
a=1;
while V(a) > 0
t(a+1) = a*tStep;
M_dot(a) = -pi*WR(a)*D_T*(1 - RH)*c_sat*(0.27*CAR(a)^2+1.30); %mass flow rate [kg/s]
M(a+1) = M(a) + M_dot(a)*tStep; %mass loss at each time step [kg]
V(a+1) = M(a+1)/Rho; %new volume [m^3]
Vmm3(a+1) = V(a+1)*1e9; %new volume [mm^3]
WR(a+1) = IWR; %constant wetted radius [m]
WRmm(a+1) = WR(a+1)*1000; %constant wetted radius [mm]
h(a+1) = ((sqrt(pi^2*WR(a+1)^6 + 9*V(a+1)^2) + 3*V(a+1))^(2/3) - pi^(2/3)*WR(a+1)^2)/(pi^(1/3)*(sqrt(pi^2*WR(a+1)^6 + 9*V(a+1)^2) + 3*V(a+1))^(1/3)); %height of the droplet [m]
CAR(a+1) = 2*atan(h(a+1)/WR(a+1)); %new contact angle [radians]
CAD(a+1) = CAR(a+1)*180/pi; %new contact angle [degrees]
a = a + 1; %increasing time by 1 second for every loop
end
%% Plotting
a = 1:a-1;
contourf(RLL,R,t(a))
k = colorbar;
cmap = colormap;
ax = gca;
ax.Color = cmap(1, :);
k.Label.String = 'Evaporation Time (s)';
xlabel('Length (\mum)')
ylabel('Diameter (\mum)')
Rena Berman
Rena Berman on 12 Oct 2020 at 17:22
(Answers Dev) Restored edit

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 18 Aug 2020
t is a vector. t(a) is going to be a vector. You can never use a vector in the z coordinates for surf()
surf() is only for cases where you can define 2d arrays of x, y, and corresponding z, or at the very least vector x and y and 2d array z.
Under no circumstances can surf be used to ask to interpolate a surface from scattered x and y and z.

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!