Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

input dialog box

Status
Not open for further replies.

korby

Electrical
May 5, 2003
7
DE
I want to use the input dialog box.
The user has to enter some parameters for the simulation(numbers).
How can I transform the single elements of the cell array into numbers ( double arrays) so that I can calculate with them??
 
Replies continue below

Recommended for you

Hi,
that was a problem for me too. But I found a solution.
I needed two entries:

%%input dialog box%%%
prompt = {'Enter gain:','Enter range:'};
dlg_title = 'Enter values';
num_lines= 1;
def = {'20','256'}; %default
answer = inputdlg(prompt,dlg_title,num_lines,def);

%%%to get the two entered values%%%%
A = getfield(answer,{1}); %first input field
A = str2double(A);

B = getfield(answer,{2}); %second input field
B = str2double(B);

Hope I could help

sui
 
Hi Suigeneris,
thanks a lot for your tip!!

actually the 'getfield' causes a erroermessage:

??? Error using ==> getfield
Error using ==> subsref
Index exceeds matrix dimensions.

Error in ==> C:\Programme\Matlab\work\Untitled.m
On line 9 ==> A = getfield(answer,{1}); %first input field

but if I just take the content of the array with
'a=answer{1}' for example --> it works.

str2double was the expression I was looking for !!

Thanks again

cheers Korby
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top