Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to link pushbotton and a m file(script)

조회 수: 1 (최근 30일)
Vincenzo
Vincenzo 2011년 11월 9일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi I don't know how to call a m file(script) through a pushbotton...I know that i have to do do something in the function pushbotton_Callback(......) but i don't Know what.. I tried this..
but nothing.
It appears me the following warning:

답변 (6개)

Walter Roberson
Walter Roberson 2011년 11월 9일
addpath() is only for use with directories, not individual files.
If you just want to execute the script, use run() -- but note that run() changes directories, so addpath() is better if you need to execute in the current directory.
Remember there is no point in using addpath() twice with the same path, so you may wish to check whether the target path is already on the path.

Vincenzo
Vincenzo 2011년 11월 9일
run namefile only works from command window...if i put in function callback i have this error whe i click on botton:

Vincenzo
Vincenzo 2011년 11월 10일
Someone can help me? I have this script but with run namefile doesn't start, unless i put it in command window...why?
  댓글 수: 1
Walter Roberson
Walter Roberson 2011년 11월 10일
Your script confuses base workspace with function workspace.

Vincenzo
Vincenzo 2011년 11월 10일
With run namefile something start because i can see an image:
but the Workspace remains blank while i'm aspecting all the values that are in the script...like this
why it happens?

Vincenzo
Vincenzo 2011년 11월 10일
  댓글 수: 3
Walter Roberson
Walter Roberson 2011년 11월 10일
The variables *are* being created, in the workspace of pushbutton2_Callback, and so they disappear again as soon as that callback finishes executing.
If you need your script to put the variables in the base workspace, then have it specifically put them there, such as by using assignin()
By the way, your code uses constructs that haven't been necessary since MATLAB 5.
Vincenzo
Vincenzo 2011년 11월 10일
I solved that problem because before I had to do >>load (SEQ001.MAT) but now it's dynamic ,in fact there's no error in command window when i click on button.

Vincenzo
Vincenzo 2011년 11월 11일
I solved the problem with run namefile by doing the following thing:
Go to: D:\Programs\Matlab\toolbox\matlab\lang\run.m
#line 74 I change 'caller' to 'base'...I don't know if it's something very wrong but it works!!
I proved with assignin() but in my case i don't what i have to pass assignin('base','var',v) but if i want poi5??
By the way it works...now i would like to put (always in base Workspace) a variable from edit text through a push button..it doesn't work:
that's my gui:
what i did in edit_callback:
and in pushbutton_Callback:
What else miss?

이 질문은 마감되었습니다.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by