how to import the output of a function displayed

2 ビュー (過去 30 日間)
segun
segun 2017 年 10 月 5 日
コメント済み: Walter Roberson 2017 年 10 月 5 日
How do one import the output of a function simulated in MATLAB 2015 that is about 250 number outputs displayed vertically. I need to put it into MSexcel for further analysis.
  1 件のコメント
KSSV
KSSV 2017 年 10 月 5 日
編集済み: KSSV 2017 年 10 月 5 日
doc xlswrite to write the data into excel file. By the way why you want to go to excel, when you can analyze everything and anything in MATLAB.

サインインしてコメントする。

採用された回答

John BG
John BG 2017 年 10 月 5 日
編集済み: John BG 2017 年 10 月 5 日
Hi segun
Let be your data for instance
A=randi([-1e4 1e4],5,1)
1. choose the Excel file
xls_file_name='Book1.xlsx'
2. define what sheet to write on, for instance 2nd page
sheet=2
3. define the start point of the range to write in the Excel file
range1='B2'
4. write it
xlswrite(xls_file_name,A,sheet,range1)
if you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance
John BG

その他の回答 (2 件)

Marco
Marco 2017 年 10 月 5 日
Hello, to export a table in the workspace to a Microsoft® Excel® spreadsheet file, use the writetable function. You can export data from the workspace to any worksheet in the file, and to any location within that worksheet.

Walter Roberson
Walter Roberson 2017 年 10 月 5 日
Assign the output to a variable if possible.
If the output is just be displayed, such as through disp() or fprintf(), then best is to modify the function to return the information.
If it is just being displayed and modifying the function is not practical, then use evalc() to capture the output as text, after which you can split it into lines and str2double() it.
  2 件のコメント
segun
segun 2017 年 10 月 5 日
There are 250 numbers with decimals displayed as the output after the Run of the Mfile. How to copy this numbers and transfer them to MSExcel is the problem.
Walter Roberson
Walter Roberson 2017 年 10 月 5 日
Example:
S = evalc('MyBlackBoxFunction()');
Slines = regexp(S, '\n', 'split');
Slines(1:3) = []; %remove a text header
Slines( cellfun(@isempty, Slines) ) = []; %delete empty lines
data = str2double(Slines);
xlswrite('MyOutput.xlsx', data);

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by