f



GUI will looks like different, if GUI is executed on different MATLAB Versions

Hello!

I've programmed a MATLAB GUI. On my PC there is a release version 7.0.0.1... 
and I'm working at the Technical University Berlin with a 7.4.0.287. On both 
versions plotting into an axes object will not change the axes dimensions. 
Unfortunately, on the PC of a friend of mine (7.0.1.15) and at the HMI (Hahn 
Meitner Institut) (7.1.0.246), plotting into the axes object affects the 
axes dimensions (is bigger, looses the squared size). (plotting command: 
imagesc, and the image is a squared matrix)

Futhermore, there is a problem in one version, when a function call has 
empty brackets -> error. If you leave the brackets away, everything is ok!?


Does anybody knows how to prevent such strange effects?


Greetings, Michael! 


0
tanzloewe (9)
6/5/2007 9:13:03 PM
comp.soft-sys.matlab 211266 articles. 22 followers. lunamoonmoon (257) is leader. Post Follow

8 Replies
507 Views

Similar Articles

[PageSpeed] 51

There are a number of ways you can fix it. One of the ways I can
think of is to have the GUI get the axis bounds before it plots.
After the GUI plots you can then have it set the axis bounds to what
they were before the plot.

I'm not sure what you mean by when a function call has empty brackets
so I can't help you with that. Post a quick example and it might
make more sense.
0
smit17291 (242)
6/6/2007 2:53:04 PM
For example, there might be a function defined like this (filename 
'test.m'):

% start
function [] = test()
% some commands
% end

If I call this function from a callback GUI function with 'test();' there 
will be an error. If I leave the brackets away and the call looks like 
'test;' everything is ok!?

Maybe a position resetting (of the axes) after plotting may fix it, ok, but 
way do I have to expect such a strange behaviour under different Matlab 
versions!? The thing is, that I have to develop a program that should run on 
all the different Matlab versions, at least under the 7.x versions! And you 
cannot expect, that I fix all the strange effects for different Matlab 
versions - then, my work would cost double the time (and I must have always 
access to the different Matlab versions)! ....So, some scientists around me 
get dissatisfied with these aspects of Matlab (me too).




"Jeremy Smith" <smit1729@umn.NOSPAM.edu> schrieb im Newsbeitrag 
news:ef5905e.0@webcrossing.raydaftYaTP...
> There are a number of ways you can fix it. One of the ways I can
> think of is to have the GUI get the axis bounds before it plots.
> After the GUI plots you can then have it set the axis bounds to what
> they were before the plot.
>
> I'm not sure what you mean by when a function call has empty brackets
> so I can't help you with that. Post a quick example and it might
> make more sense. 


0
tanzloewe (9)
6/6/2007 3:49:31 PM
If you set the callback like the following line of code, it will
work.

set(object_handle,'Callback','test')

If you set the callback like the following line of code, it will NOT
work.

set(object_handle,'Callback',{@test})

In the second line of code there is an assumption by the GUI that
there will be at LEAST two inputs. Your function definition would
have to look like the following line of code.

function test(h,eventdata)

h is the handle of the calling GUI object and eventdata is very
rarely used (put there by Matlab for future compatibility).

I understand your irritation in dealing with different versions of
Matlab. I am also programming a GUI which needs to work on as many
versions as possible.

Hopefully this helps.
0
smit17291 (242)
6/6/2007 4:03:12 PM
Oh, it looks like that you described me a callback function!? But I just 
want to execute a function from within the callback function! A function 
that could be as simple as the sum(x) or mean(x) function just without 
parameters!

Thx, Micha*



"Jeremy Smith" <smit1729@umn.NOSPAM.edu> schrieb im Newsbeitrag 
news:ef5905e.2@webcrossing.raydaftYaTP...
> If you set the callback like the following line of code, it will
> work.
>
> set(object_handle,'Callback','test')
>
> If you set the callback like the following line of code, it will NOT
> work.
>
> set(object_handle,'Callback',{@test})
>
> In the second line of code there is an assumption by the GUI that
> there will be at LEAST two inputs. Your function definition would
> have to look like the following line of code.
>
> function test(h,eventdata)
>
> h is the handle of the calling GUI object and eventdata is very
> rarely used (put there by Matlab for future compatibility).
>
> I understand your irritation in dealing with different versions of
> Matlab. I am also programming a GUI which needs to work on as many
> versions as possible.
>
> Hopefully this helps. 


0
tanzloewe (9)
6/6/2007 4:41:59 PM
"Michael" <tanzloewe@gmail.com> wrote in message 
news:5co6euF2vt2e3U1@mid.dfncis.de...
> Oh, it looks like that you described me a callback function!? But I just 
> want to execute a function from within the callback function! A function 
> that could be as simple as the sum(x) or mean(x) function just without 
> parameters!

Define your function as:


function y = myfun
y = 2;


Call this function like:


y = myfun;


No parentheses needed, and this should work back as far back as you care to 
go.

-- 
Steve Lord
slord@mathworks.com 


0
slord (13689)
6/6/2007 6:12:18 PM
Yeah, this can I do, but it looks a bit inconvenient (compared to some other 
known languages as c++ & co.)  Moreover it is more understandable for the 
programmer to see at once, if it is a function or a variable!

And I still do not know, why it works on some Matlab 7.x versions and on 
some versions it will fail!



"Steven Lord" <slord@mathworks.com> schrieb im Newsbeitrag 
news:f46te2$khb$1@fred.mathworks.com...
>
> "Michael" <tanzloewe@gmail.com> wrote in message 
> news:5co6euF2vt2e3U1@mid.dfncis.de...
>> Oh, it looks like that you described me a callback function!? But I just 
>> want to execute a function from within the callback function! A function 
>> that could be as simple as the sum(x) or mean(x) function just without 
>> parameters!
>
> Define your function as:
>
>
> function y = myfun
> y = 2;
>
>
> Call this function like:
>
>
> y = myfun;
>
>
> No parentheses needed, and this should work back as far back as you care 
> to go.
>
> -- 
> Steve Lord
> slord@mathworks.com
> 


0
tanzloewe (9)
6/6/2007 8:01:17 PM
On Jun 6, 11:49 am, "Michael" <tanzlo...@gmail.com> wrote:
> For example, there might be a function defined like this (filename
> 'test.m'):
>
> % start
> function [] = test()
> % some commands
> % end
>
> [snip]



========================================================
If you don't plan on returning anything, why put [] in the function
definition?  Just leave them out.  The function probably exits but
since you didn't use any output arguments in between the [] it thinks
it doesn't have to return anything but because you did put [] it
thinks it should.  What is it supposed to think?  My only guess would
be that it should return NULL or an empty array of zero length.  Why
bother?  It's confusing to me so it's probably confusing to MATLAB as
well.

Could the plot size issue be related to different video adapters,
similar to how fonts get messed up if computers have different size
fonts (at least in Windows, such as one has medium and another has
extra large)?

0
imageanalyst (7621)
6/8/2007 12:40:53 AM
I)
    There are two reasons, why I like empty brackets as ouput argument:

    1. I like to have similar function headers :-)   (looks fine!)
    2. In the Matlab documentation (p 4.10, in "Programming"):


        "If there is no ouput, leave the ouput blank
                function printresults(x)
        or use empty square brackets:
                function [] = printresults(x)"

        ...so this should be ok.

II)
    Yes, I have also thought of problems related to different video
adapters, but because I have set the "Units" of the (gui) figure as well as
axes "Units" to "pixels" and set the "Position"  to a tied value, I wouldn't
expect this! 


0
tanzloewe (9)
6/8/2007 7:54:20 AM
Reply: