Info

This question is closed. Reopen it to edit or answer.

in gui matlab?

1 view (last 30 days)
hadi mostafavi amjad
hadi mostafavi amjad on 21 Jul 2018
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi. I have a value that I want to calculate, and another value must be calculated from this value (the second one calculated from the first value). But the problem is I work by “gui” and the first values are calculated from 2 edit boxes, and it must saved for the next calculation! But when I want to calculate the second one, because I should turn that edit boxes to zero, the first calculation change to zero and all of the calculation going to “NaN”!!!!!!
How should I save the values for my calculations?! Without changing by set the edit boxes values?!

Answers (1)

Image Analyst
Image Analyst on 21 Jul 2018
Use them BEFORE you set them to zero of course. For example
value1 = str2double(handles.edit1.String);
value2 = str2double(handles.edit2.String);
firstValue = 2 * value1 + 5 * value2; % or whatever your formula is.
% Now use this first value to compute a "second" value.
secondValue = 9 * firstValue; % or whatever your formula is.
% Now set edit box strings (that were used in the
% calculation of the firstValue) equal to zero.
handles.edit1.String = '0';
handles.edit2.String = '0';

Community Treasure Hunt

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

Start Hunting!