Adding files to a GUI without using brakcets

조회 수: 1 (최근 30일)
Tom
Tom 2012년 10월 9일
I have a GUI that imports a .mat file full of data, and i have a function that i enter at the moment to call the file into the GUI from a command window - it is simply Add(Volts) where volts is the file name. Is there any way of getting round having the brackets or using a different call command? It has to use the file name (with my current configuration) as it then calls on matrices within Volts (eg Volts.Light etc).
Thanks

답변 (2개)

Walter Roberson
Walter Roberson 2012년 10월 9일
편집: Walter Roberson 2012년 10월 9일
If you are calling with a literal string, such as
Add('Volts')
then you can take advantage of Command/Function duality and code this as
Add Volts
with no ()
This cannot be (easily) used if Volts is instead a variable that contains a string, such as
Volts = uigetfile('Which Volts file?');
Add(Volts)
  댓글 수: 2
Tom
Tom 2012년 10월 9일
Should have clarified, it is a variable that contains a string!
Walter Roberson
Walter Roberson 2012년 10월 9일
It is not impossible but it is not good programming. You would have to have the Add routine evalin('caller') the string it received, in order to get the name of the file that it was to load.

댓글을 달려면 로그인하십시오.


Sachin Ganjare
Sachin Ganjare 2012년 10월 9일
Refer below link;
Hope it helps!!!!

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by