MATLAB Answers

Create a excel file (named as Input) in Matlab App designer and write variables in it.

조회 수: 109(최근 30일)
Ajiket Patil
Ajiket Patil 2021년 2월 23일
댓글: Ajiket Patil 2021년 5월 20일
Respected All,
I want to create an excel file with "named as the input", and pass on variables into it from the app designer.
Aim is to create a file named "Test.xlsx" in the folder "Excel_Folder" and write variables "variable1", and "variable2" into the excel file after pressing the "Export data" pushbutton.
I have tried the following:
% Value changed function: NameEditField
function NameEditFieldValueChanged(app, event)
value = app.NameEditField.Value;
end
% Button pushed function: ExportdataButton
function ExportdataButtonPushed(app, event)
folder = app.Excel_Folder; % create a new folder with name Excel_Folder
filename = app.NameEditField.Value; % name of the file
writetable(fullfile(folder, filename), app.variable1, app.variable2); % write variables 1 and 2 into in the file
end
The above is neither creating a file in the folder nor displaying any error.
Thanking You.
Ajiket

채택된 답변

Jemima Pulipati
Jemima Pulipati 2021년 2월 26일
Hello,
From my understanding, you want to create an excel file and write some data into it.
The writetable() function expects the first argument to be a table containing some data followed by the filename. You may consider modifying the function call in your code according to the syntax.
Also, you may consider using writematrix() and writecell() as per your need.
  댓글 수: 3
Ajiket Patil
Ajiket Patil 2021년 5월 20일
The Question is about how to create an excel file and write data/variables into it (from matlab app designer)?
Answer:
1) Create a named entry to type in the name of the file you want to create with the appropriate extension.
As in above example
type in "test.txt" OR "test.xlsx" OR "test.csv" etc formats.
2) The variables var1 and var2 are written in the test file by write matrix command.
Reference :
https://in.mathworks.com/help/matlab/ref/writematrix.html
Kindly share your code and exact problem if it still persists.

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

추가 답변(0개)

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by