Email Questions

Recently, someone asked us some questions by email.  I thought that the questions would be interesting to a wider Matlab programming audience, so I decided to post them here.  The questions relate to GUIDE, arrays, and Matlab speed.

Here is the original email:

1st, is the coding for the function of all GUIDE tool linking? For
instance, the coding wrote in pushbutton_callback is connected with coding
wrote in pushbutton1_callback. Is that possible? Or I have to write in
separate .m file, each .m file consists of each function?

2nd, I want to display multiple images in uipanel as you can see in my
coding. So, is it possible to use subplot in uipanel?

3rd, I am totally new in Matlab, so basically immitate source code from
FileExchange or Matlab blogs. There are few errors quite often occurred
and I still can’t clear my doubt thru wiki/google.
For example 1: Attempted to access cell(2,1); index out of bounds because
size(cell)=[1,22]. for preallocate the database.
For example 2: ??? Undefined function or variable ‘Nfile. What does it
means? As I had “defined” it as Nfiles = numel(fnam); Is it something
wrong with my concept?

4th, I found that when run more often .m file, more slower the
performance. Is this the software problem or my computer problem?

Here are my answers to her questions:

1. You should be able to declare the callback function when you create
the pushbutton. Therefore, you should be able to use the same callback
function for different pushbuttons. If you want the pushbuttons to do
different tasks but use the same function, you could put a parameter in
your function call that specifies which task you want the function to
perform. You would then put a “switch” statement into your function to
use the parameter.

2. You should be able to use subplot in the UI panel.

3. I am not sure about your errors, because I can’t see your code.
However, I have some ideas about what might be wrong. Matlab uses arrays
for everything. The first index in an array specifies the row, and the
second index specifies the column. If you wanted row 4 and column 7 from
array A, you would type A(4,7). For the first error, it looks like you
are trying to access a location in the cell array that doesn’t exist. If
an array A is 1×22, then you can’t access location A(2,1), because that
array has only one row, and the location that you want is in the second
row. Additionally, be careful not to give any of your variables the name
of a data type or function. If you name a variable “cell”, which is data
type, then you may get strange effects in your code. For the second
error, it seems like you just have a typo. You are trying to use Nfile,
but you had already created a variable named Nfiles.

4. If I understand you correctly, Matlab on your computer runs more
slowly after you have opened it and run several m-files. You should make
sure that you clear your Matlab workspace with the “clear” command after
you run a script. Try to get rid of all the variables that you don’t need
to use, as they can slow down Matlab. If Matlab still runs slow, then try
to restart Matlab. If that doesn’t fix the problem, then try to restart
your computer.

7 thoughts on “Email Questions

  1. Hello,
    Could you please tell me how to read a matlab struct into java using jmatio library.There are no examples online and the documentation is very confusing.
    Thank you

  2. Hello,
    Could you please tell me how to read a maylab truct from java using jmatio library there are no examples of this online and the jmatio documentation is very confusing.
    Thank you

  3. hello
    My English is not good
    my question is:
    with this data,3. X=[1 1 2 3 4 4 4 4; 0 2 0 4 1 4 -1];
    Linear Perceptron algorithm written for them and best of show
    do and iteration with c=3 ,c=1, c=0.1
    batch perceptron with this c.

  4. Dear Matlab Geeks and Matlab Users,

    I trust you are well and all is good. I would like to know if the Matlab Community can assist me in the following problem I encounter when trying to run my simulation.

    I am using Matlab to run a scientific model over South Africa using GNSS network, and this involves MATLAB GUI’s. Below is the errors I encounter.

    ??? Error using —-> checkgrid
    LatIntersect () – Internal parameter exceeds bounds

    Error in –> initgrid at 23
    [Grid.Voxel, Grid.Dim] = checkgrid ( Grid );

    Error in –> @(hObject,eventdata)gmagic(‘Process_Callback,’ hObject,eventdata,guidata(hObject))

    ??? Error while evaluating uicontrol Callback

    There is other m – files that works together to give the GUI. If anyone can be of any assistance it will be highly appreciated.

    I Thank You in advance for the above.

    Kindest Regards,


  5. I would be interested in your over rated/underrated analysis using the last AP vote list just BEFORE the bowl season. After the bowl season, I believe there is much more rigging of votes by area of the country to raise or lower teams. (e.g. Texas and southern voters will raise Big12/SEC schools on final ballots, and lower out of school teams even when they win). Plus there is some forced voting built into the final AP vote which might not necesarily reflect what people really think (i.e. see LSU national champions with 2 losses).

Leave a Reply

Your email address will not be published. Required fields are marked *