how to fetch data from excel and store it in another excel file
14 ビュー (過去 30 日間)
古いコメントを表示
I have a data in excel table, I want to fetch some data from that table and then store it in anaother table. How to do that please guide me
1 件のコメント
dpb
2023 年 4 月 25 日
No big deal, but you've got to start...the basics with plenty of examples for specifically the problem you're asking about are at the <following top level link>; the most pertinent specific functions will undoubtedly be readtable and writetable
回答 (2 件)
Ankit
2023 年 4 月 26 日
% Read data from input Excel file
[data, headers] = xlsread('input_file.xlsx');
% Manipulate the data as required
new_data = data + 1;
% Write the manipulated data to output Excel file
xlswrite('output_file.xlsx', [headers; num2cell(new_data)]);
0 件のコメント
Nithin Kumar
2023 年 4 月 26 日
編集済み: Nithin Kumar
2023 年 4 月 26 日
Hi Aiman,
I understand that you are trying to fetch the data from an excel file and then store it into another excel file.
To fetch the data from the input Excel file into a table, use the “readtable” function.
- To read the data from a sheet named “sheet1” in an Excel file named “in.xlsx”, use the following command.
inTab=readtable('in.xlsx','Sheet','Sheet1');
Here, “inTab” contains the data from the Sheet in the form of a MATLAB table.
For more information regarding “readtable” function, refer the following link:
To write the data to another Excel file, use the “writetable” function.
- To write the data to a sheet named “sheet1” in a new excel file named “out.xlsx”, use the following command.
writetable(inTab,'out.xlsx','Sheet','Sheet1');
For more information regarding “writetable” function, refer the following link:
I hope this answer will be helpful.
6 件のコメント
Walter Roberson
2023 年 5 月 1 日
all_cures = ["fusarium_cure1", "fusarium_cure2", "bacterial_cure1", "bacterial_cure2"]
all_diseases = ["Fusarium wilt"; "Fusarium wilt"; "Bacterial Blight"; "Bacterial Blight"]
Notice the first one, the one you used commas for, is one single row with four columns
Notice the second one, the one you used semi-colons for, is one single column with four rows.
table() requires that all the variables have the same number of rows .
So be consistent: either use commans for both arrays, or use semi-colons for both arrays.
参考
カテゴリ
Help Center および File Exchange で Data Import from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!