Undefined function 'times' for input arguments of type 'cell'.
Show older comments
I am trying to write a function that will determine the heat needed to change the temperature of water between two given temperatures and I keep getting this error. Anybody know how to fix it?
c_ice = 2060;
c_water = 4180;
c_steam = 2020;
Hf = 332000;
Hv = 2260000;
% Input
mass = inputdlg('What is the mass of the H2O?','Mass of H20');
statei = listdlg('PromptString', 'What is the initial state of the H2O?',...
'SelectionMode','Single',...
'ListString',{'Ice','Liquid','Gas'},...
'Name', 'Initial State',...
'ListSize',[230 100]);
statef = listdlg('PromptString', 'What is the final state of the H2O?',...
'SelectionMode','Single',...
'ListString',{'Ice','Liquid','Gas'},...
'Name', 'Final State',...
'ListSize',[230 100]);
switch statei
case 1
tempi = inputdlg('What is the initial temperature of the H2O between -273-0ºC',...
'Initial Temperature');
case 2
tempi = inputdlg('What is the initial temperature of the H2O between 0-100ºC',...
'Initial Temperature');
case 3
tempi = inputdlg('What is the initial temperature of the H2O between 100-300ºC',...
'Initial Temperature');
end
tempi = str2double(tempi);
switch statef
case 1
tempf = inputdlg('What is the final temperature of the H2O between -273-0ºC',...
'Final Temperature');
case 2
tempf = inputdlg('What is the final temperature of the H2O between 0-100ºC',...
'Final Temperature');
case 3
tempf = inputdlg('What is the final temperature of the H2O between 100-300ºC',...
'Final Temperature');
end
tempf = str2double(tempf);
% Process
if tempi < 0
if tempf < 0
heat = mass*c_ice*(tempf - tempi);
elseif tempf < 100
heat = mass*c_ice*(tempi) + mass*Hf + mass*c_water*(tempf);
else tempf > 100
heat = mass*c_ice*(tempi) + mass*Hf + mass*c_water*(100) + mass*Hv + mass*c_steam*(tempf - 100);
end
elseif tempi > 0 && tempi < 100
if tempf < 0
heat = mass*c_water*(-tempi) + mass*Hf + mass*c_ice*(-tempf);
elseif tempf < 100
heat = mass*c_water*(tempf - tempi);
else tempf > 100
heat = mass*c_water*(100 - tempi) + mass*Hv + mass*c_steam*(tempf - 100);
end
else
if tempf < 0
heat = mass*c_steam*(tempi - 100) + mass*Hv + mass*c_water*(100) + mass*Hf + mass*c_ice*(-tempf);
elseif tempf < 100
heat = mass*c_steam*(tempi - 100) + mass*Hv + mass*c_water*(tempf - 100);
else tempf > 100
heat = mass*c_ice*(tempf - tempi);
end
endc_ice = 2060;
c_water = 4180;
c_steam = 2020;
Hf = 332000;
Hv = 2260000;
% Input
mass = inputdlg('What is the mass of the H2O?','Mass of H20');
statei = listdlg('PromptString', 'What is the initial state of the H2O?',...
'SelectionMode','Single',...
'ListString',{'Ice','Liquid','Gas'},...
'Name', 'Initial State',...
'ListSize',[230 100]);
statef = listdlg('PromptString', 'What is the final state of the H2O?',...
'SelectionMode','Single',...
'ListString',{'Ice','Liquid','Gas'},...
'Name', 'Final State',...
'ListSize',[230 100]);
switch statei
case 1
tempi = inputdlg('What is the initial temperature of the H2O between -273-0ºC',...
'Initial Temperature');
case 2
tempi = inputdlg('What is the initial temperature of the H2O between 0-100ºC',...
'Initial Temperature');
case 3
tempi = inputdlg('What is the initial temperature of the H2O between 100-300ºC',...
'Initial Temperature');
end
tempi = str2double(tempi);
switch statef
case 1
tempf = inputdlg('What is the final temperature of the H2O between -273-0ºC',...
'Final Temperature');
case 2
tempf = inputdlg('What is the final temperature of the H2O between 0-100ºC',...
'Final Temperature');
case 3
tempf = inputdlg('What is the final temperature of the H2O between 100-300ºC',...
'Final Temperature');
end
tempf = str2double(tempf);
% Process
if tempi < 0
if tempf < 0
heat = mass*c_ice*(tempf - tempi);
elseif tempf < 100
heat = mass*c_ice*(tempi) + mass*Hf + mass*c_water*(tempf);
else tempf > 100
heat = mass*c_ice*(tempi) + mass*Hf + mass*c_water*(100) + mass*Hv + mass*c_steam*(tempf - 100);
end
elseif tempi > 0 && tempi < 100
if tempf < 0
heat = mass*c_water*(-tempi) + mass*Hf + mass*c_ice*(-tempf);
elseif tempf < 100
heat = mass*c_water*(tempf - tempi);
else tempf > 100
heat = mass*c_water*(100 - tempi) + mass*Hv + mass*c_steam*(tempf - 100);
end
else
if tempf < 0
heat = mass*c_steam*(tempi - 100) + mass*Hv + mass*c_water*(100) + mass*Hf + mass*c_ice*(-tempf);
elseif tempf < 100
heat = mass*c_steam*(tempi - 100) + mass*Hv + mass*c_water*(tempf - 100);
else tempf > 100
heat = mass*c_ice*(tempf - tempi);
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Identification 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!