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');endtempi = 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');endtempf = 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); endelseif 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); endelse 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); endendc_ice = 2060;c_water = 4180;c_steam = 2020;Hf = 332000;Hv = 2260000;% Inputmass = 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');endtempi = 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');endtempf = str2double(tempf); % Processif 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); endelseif 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); endelse 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); endend
Best Answer