Ryan Simmons
Ryan Simmons

Reputation: 883

Return .m file help text in figure window

I have this function in a script:

function exp(source,eventdata,indx)
global h;
global d;
global myslash;
global experiment;
global description;
mddefaults = ([cd myslash 'parameters']);

if exist(mddefaults, 'dir')
    defaults = [mddefaults ,myslash];
else
    defaults = [cd ,myslash 'parameters' myslash];
end

mh = guihandles(gcf);

filesel = d(indx).name ;

experiment = filesel(1:length(filesel)-2);
set(mh.ExpLabel,'String', experiment);
descr = help(experiment);
set(mh.description,'String', descr);

It is embedded in an .m file with a bunch of other functions to run my experiment. As you can see, this one goes into a directory and sets the experiment name and description based on the files in that directory (there are multiple possible experiments that can be selected between). However, it doesn't work, and I can't figure out why. To be more precise, the "ExpLabel" works, and the name of the experiment is displayed; however, the "description" does not work for every file. The confusing thing is it works for some files but not others, even though they are all formatted exactly the same.

Any ideas? Do you need more of my script?


EDIT1:

Here is the code for the text uicontrols that the code in the OP is feeding:

uicontrol(mainfigure, 'Style', 'text',...
    'String', experiment,...
    'FontSize',10,'FontWeight','bold',...
    'Position',[hpcont vpcont-30  hpcont+hsizecont*6 15],...
    'Tag', 'ExpLabel');

uicontrol(mainfigure, 'Style', 'text',...
    'String', description,...
    'Max',2,'Min',0,...
    'HorizontalAlignment','left',...
    'Position',[hpcont vpcont-vsizecont*11.5  hpcont+hsizecont*6 275],...
    'Tag', 'description');

The first one works, the second one only sometimes works. Can't figure out why. And, again, no error message, it just doesn't display the text that it is supposed to. (Don't worry about the position stuff, that all works fine; I know it looks rather odd but that's irrelevant to this).

Upvotes: 1

Views: 134

Answers (1)

yuk
yuk

Reputation: 19870

Your problem is setting correct Position property. The text is just outside of the figure. Check Units property of mainfigure to make sure your numbers for the position match the figure units.

Show us what is hpcont, vpcont, hsizecont and vsizecont and how you define them.

Upvotes: 1

Related Questions