Info

此问题已关闭。 请重新打开它进行编辑或回答。

in gui matlab?

1 次查看(过去 30 天)
hadi mostafavi amjad
关闭: MATLAB Answer Bot 2021-8-20
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?!

回答(1 个)

Image Analyst
Image Analyst 2018-7-21
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!

Translated by