Opening a Textfile in MATLAB Appdesigner Online

I wrote data in matlab online and saved it as a textfile and I want to open that data in appdesigner online.
function InputDataButtonPushed(app, event)
[filename, path] = uigetfile('*.txt'); % Choose the file to open
if isequal(filename,0);
return
end
figure(app.UIFigure);
T = fopen(filename);
I am not getting an error code, but this is what it says for T
T =
3
and this is what I have for T in the file:
1 1 1
I do not have an error message, so I really do not know what I am doing wrong.
I just want to open up the data into my numeric edit fields.

답변 (1개)

Voss
Voss 2022년 4월 27일

0 개 추천

fopen merely opens a file so that subsequent code can read from or write to the file.
To read the contents of a file into a variable, you might try readmatrix or another function, depending on the contents of your file.

댓글 수: 3

I tried it and it did nothing. I tried it again on desktop and got an error that I do not understand how to deal with
Here is my code
function InputDataButtonPushed(app, event)
[filename, path] = uigetfile('*.txt'); % Choose the file to open
figure(app.UIFigure);
T = readmatrix(filename); % Input data set 1
end
end
I just want to open the file with the data to read in to my value edit fields.
1 1 1
T = readmatrix(filename); % Input data set 1
reads the file filename into the variable T.
If you want your GUI to update somehow after this happens, you have to tell it to do so. For instance:
T = readmatrix(filename); % Input data set 1
% use your edit field's name.
% use what you want from T.
app.my_edit_field.Value = T(1);
I
I 2022년 5월 1일
편집: I 2022년 5월 1일
Right, well I added these lines and then I have this error for it.
Are you able to explain why I am not able to just directly read in the data from the textfile using this function?
app.Var1EditField.Value = T(1,1);
'Value' must be a double scalar within the range of 'Limits'.
app.Var1EditField.Value = T(1);
'Value' must be a double scalar within the range of 'Limits'.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2020a

질문:

I
I
2022년 4월 27일

편집:

I
I
2022년 5월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by