MATLAB: I have an input which saves previous answers that have been given, how can i set initial values that only apply once

definput

This is my code (for this part)
% To be inputted by user
prompt = {'Mass:','Angle of Slope:','Car Wheelbase:','Car Width:','Car Length:','Car Height:'};
title = 'Input';
dims = [1 35];
definput = {Mass,Degrees,Wheelbase,Width,Length,Height};
Answer = inputdlg(prompt,title,dims,definput);
Mass = Answer{1};
Degrees = Answer{2};
Wheelbase = Answer{3};
Width = Answer{4};
Length = Answer{5};
Height = Answer{6};
I've tried using isempty and exist but both return errors (Might be doing it wrong)
Any help is much appreciated 🙂

Best Answer

if exist('Mass','var') == 1
Mass = Mass;
else
Mass = char(1);
end
This seems to do the trick