help with this problem

38 ビュー (過去 30 日間)
Abdelmalek Benaimeur
Abdelmalek Benaimeur 2019 年 4 月 26 日
回答済み: Ruba 2023 年 6 月 27 日
hello,
i'm working on appdesigner
i want to add a push button which allow me to load mat file and show its elements in the workspace
for example i have ''example.mat" it conatins 03 matrix A,B and C
i did this
[file,path] = uigetfile('*.mat', 'Select a File');
if isequal(file,0)
disp('User selected Cancel')
else
load(fullfile(path,file))
assignin('base',file)
end
but i got this error
Error using assignin
Not enough input arguments.
Error in app1/LoadButtonPushed (line 18)
assignin('base',file)
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 335)
Error while evaluating Button PrivateButtonPushedFcn.
how can i solve this problem

採用された回答

Jan
Jan 2019 年 4 月 26 日
The error message is clear: See doc assignin to see, that it requires 3 arguments:
data = load(fullfile(path,file))
assignin('base', 'data', data)
It is much safer to catch the imported data in a variable instead of polluting the workspace. Imagine the MAT file contains a variable called "assignin". Then the line: assignin('base', 'data', data) shows the evil problem.
By the way, do not use the important Matlab function "path" as name of a variable. This can cause serious problems, when you debug the code.
  1 件のコメント
Abdelmalek Benaimeur
Abdelmalek Benaimeur 2019 年 4 月 26 日
i did this and i got a struct which contains all the matrix
is there a way to obtain all the matrix in the workspace and not a struct wchich contain them ?

サインインしてコメントする。

その他の回答 (1 件)

Ruba
Ruba 2023 年 6 月 27 日
how the solvw a problem (Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback
Error while evaluating Button PrivateButtonPushedFcn.)?

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by