Get handles as a number in order to apply function and operate mathematicaly

49 Views Asked by At

The program asks for input in gui editbox as a value, then it takes this value and applies the equation to get the pressure. I haven't been able to do so and I heard from some classmates that matlab takes the input as a string and doesn't operate strings.

get(handles.spl,'String') this is how I get the value, I tried get(handles.spl,'Double') instead but it didn't work, also tried str2double.

I don't know what else to try, I'm also pretty new in programming. I'd appreciate the help, thanks.

1

There are 1 best solutions below

0
Suever On

You are correct that the uicontrol String property returns...a string. So you'll need to convert it to a number using str2double.

u = uicontrol('style', 'edit', 'String', '42');

strvalue = get(u, 'String');
numvalue = str2double(strvalue);
%   42