importfile from a gui
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi! I have a question about Matlab GUI, and I would appreciate it if someone could help me.
I am trying to do the same thing with GUI and without GUI (in a normal m-file) and the result is different. I am exporting data from an excel sheet by means of the tool importfile, that lets me include the vectors from the excel sheet in my workspace so that I can later work with them.
Then, the program asks for the point (the element of the vector) to be used for the calculation (for GUI by means of get and without GUI by means of an input dialog). Whereas I have no problem for the calculation without GUI, I get a mistake by the GUI calculation when the program looks for the element of the vector:
I get vector i and then:
importfile file.xls
Element=Vector1(i)
And I become the mistake : "Undefined function or method 'Vector1' for input arguments of type 'double'"
Any idea?
Thanks!
Andrea
0 Kommentare
Antworten (2)
Fangjun Jiang
am 19 Jul. 2011
The error message says it all. Where is your variable "Vector1"? Put a break point at line "Element=Vector1(i)". Check the value of "Vector1" and "i".
Maybe your importfile function is generated from using uiimport. Since it doesn't have return argument, variable "Vector1" is created in the base workspace. That may be the reason that you can do it without GUI but you had error when calling it in your GUI function callback. Below is an excerpt from the document.
If you do not import into a structure array, the generated function creates variables in the base workspace. If you plan to call the generated function from within your own function, your function cannot access these variables. To allow your function to access the data, start the Import Wizard by calling uiimport with an output argument. Call the generated function with an output argument to create a structure array in the workspace of your function.
0 Kommentare
Walter Roberson
am 19 Jul. 2011
Is Vector1 somehow defined in your file.xls ? If so then it is being "poofed" in to the workspace of the function, and the JIT has determined ahead of time that it is an external function instead of a variable.
You should consult the documentation for the (third party) importfile() function to see if there is a way to get importfile() to return a structure that you then access the fields of (like load() works). Otherwise, you should initialize Vector1 (to any value) before you do the importfile()
0 Kommentare
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!