Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Problems with inputdlg!

Subject: Problems with inputdlg!

From: harrison fast

Date: 28 Sep, 2010 18:44:03

Message: 1 of 3

I am getting an index exceeds matrix dimensions error I do not understand.

Here is the code in question:

prompt = {'Enter element number:'};
    dlg_title = 'Element input for strain calculation';
    num_lines = 1;
    def = {'1'};
    global answer;
    answer = inputdlg(prompt,dlg_title,num_lines,def);
    xl = answer{1};
    disp(['The strain on element ' answer{1} ' is: '])
    disp(num2str(strain_output(xl,2)));

I am inputting 1 while strain_output is 2x3 and I still receive this error. I assume it has something to do with answer being a cell array but I have no idea how to fix it. Any help is greatly appreciated. Thanks.

Subject: Problems with inputdlg!

From: dpb

Date: 28 Sep, 2010 18:47:47

Message: 2 of 3

harrison fast wrote:
> I am getting an index exceeds matrix dimensions error I do not understand.
>
> Here is the code in question:
>
> prompt = {'Enter element number:'};
> dlg_title = 'Element input for strain calculation';
> num_lines = 1;
> def = {'1'};
> global answer;
> answer = inputdlg(prompt,dlg_title,num_lines,def);
> xl = answer{1};
> disp(['The strain on element ' answer{1} ' is: '])
> disp(num2str(strain_output(xl,2)));
>
> I am inputting 1 while strain_output is 2x3 and I still receive this
> error. I assume it has something to do with answer being a cell array
> but I have no idea how to fix it. Any help is greatly appreciated. Thanks.

xl = str2num(answer{1}); % inputdlg returns string, not numeric value

--

Subject: Problems with inputdlg!

From: Sean

Date: 28 Sep, 2010 18:55:07

Message: 3 of 3

"harrison fast" <hjfast@gmail.com> wrote in message <i7td1j$hb8$1@fred.mathworks.com>...
> I am getting an index exceeds matrix dimensions error I do not understand.
>
> Here is the code in question:
>
> prompt = {'Enter element number:'};
> dlg_title = 'Element input for strain calculation';
> num_lines = 1;
> def = {'1'};
> global answer;
> answer = inputdlg(prompt,dlg_title,num_lines,def);
> xl = answer{1};
> disp(['The strain on element ' answer{1} ' is: '])
> disp(num2str(strain_output(xl,2)));
>
> I am inputting 1 while strain_output is 2x3 and I still receive this error. I assume it has something to do with answer being a cell array but I have no idea how to fix it. Any help is greatly appreciated. Thanks.

It must be that the number x1 is greater than the first dimension of strain_output or that strain_output is a column vector.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us