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 CenterFile Exchange에서 Develop 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