Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski 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
Joined
May 5, 2003
Messages
7
Location
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??
 
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