How to solve file not found error in matlab

38 ビュー (過去 30 日間)
okoth ochola
okoth ochola 2024 年 10 月 30 日 2:59
コメント済み: okoth ochola 2024 年 10 月 30 日 9:40
Hi, I have been trying to make a simple GUI using the App Designer in Matlab. But I keep running into problems. This is my first innitial attempt to use GUI, kindly be patient with me sir/madam. I have two inquiries to make;
1) I wanted my app to be able to load both excel and csv files, depending on the choice of the files chosen, then use that data to some operation based on the functions shared in the separate code. The name of the file chosen would then be displayed in th Filename as shared in small code below. Note that I have only shared part of the code that I programmed (load data push button), I never touched anyother place. But I keep getting the errors which have shared in the screen short plus the errror havve coppied from the command window. I well aware the excell file is there, becuase have beee using it. I have also attached the file.
2) Suppose I have a separate code, an example diplayed in the las code, the seperate code is basically what I would want to do with tha pplication, how would I intergrate it in just designed GUI? If there be any ideas would be much welcomed. Thank you in advance great and kind people.
function LoadDataButtonPushed(app, event)
file = uigetfile('*.xlsx');
app.FilenameEditField.Value = file;]
T = load(file);
plot(T(:,1),T(:,2));
end
%Am getting is written below
Error using load
Unable to find file or directory 'Location1_imported.xlsx'.
Error in app1gui/LoadDataButtonPushed (line 18)
T = load(file);
Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
newCallback = @(source, event)executeCallback(ams, ...
Error while evaluating Button PrivateButtonPushedFcn.
Error using load
Unable to find file or directory 'Location4_imported.xlsx'.
Error in app1gui/LoadDataButtonPushed (line 18)
T = load(file);
Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
newCallback = @(source, event)executeCallback(ams, ...
Error while evaluating Button PrivateButtonPushedFcn.
The scondCode That I wwould like to integret is given below
% Where A is the the second colunmn of the loaded data
[Overal_parameters]= wblfit(A);
Weibull_cdf=wblcdf(sort(A),Overal_parameters(1),Overal_parameters(2));
Power_density_overall=0.5*density*((Overal_parameters(1)).^3)*gamma((Overal_parameters(2)+3)/Overal_parameters(2));

採用された回答

Walter Roberson
Walter Roberson 2024 年 10 月 30 日 3:46
file = uigetfile('*.xlsx');
That call returns only the name of the selected file, without returning any information about the directory it is in. You need that information as well.
You need something closer to
[file, folder] = uigetfile('*.xlsx');
if isnumeric(file); return; end %user cancel
file = fullfile(folder, file);
  1 件のコメント
okoth ochola
okoth ochola 2024 年 10 月 30 日 9:40
@Walter Roberson Thank you for ypur answer, but I am still unable to load the data

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by