How to solve file not found error in matlab

12 views (last 30 days)
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));

Accepted Answer

Walter Roberson
Walter Roberson on 30 Oct 2024
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);

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!