I want to send output values from MATLAB to an Excel file

26 ビュー (過去 30 日間)
Smriti Mohan Shetty
Smriti Mohan Shetty 2022 年 12 月 6 日
編集済み: Smriti Mohan Shetty 2022 年 12 月 7 日
I have added an example Excel file and the Matlab file from which the data is to be taken. For Background: I have multiple .mat files with a signal that I vary with 2 variables 1. Target position/t(in the matlab code) and 2. Gain values(again in the matlab code). For example when the .mat file opened by the matlab code reads"Newexp0.75Gain_0.5Target.mat", The target is at 0.5 and gain value is 0.75. I have .mat files ranging from 0.5 to 2.1 Target position/t with increment of 0.1. The gain value ranges from 0.5 to 0.8 with increment of 0.5.
The different outputs as you'll see in the excel file attached, that I want in an excel file are Amplitude, Error, Period, Frequency.
Is there any better way to do this? As it is taking a very long time totabulate them manually in excel

採用された回答

VBBV
VBBV 2022 年 12 月 6 日
FreqFinal = mean(freq)
PeriodFinal = mean(period)
error = midline-t
amplitudeFinal= mean(max(y)-midline)
Data_export = [FreqFinal PeriodFinal error amplitudeFinal]
writematrix(Data_export,'Filename.xlsx','Delimiter','tab') % check with writematrix
  4 件のコメント
Stephen23
Stephen23 2022 年 12 月 7 日
編集済み: Stephen23 2022 年 12 月 7 日
The "Delimiter" option is not valid for Excel files (because they are not text files and do not use delimiters).
You can see that the "Delimiter" option is listed under the section "Text Files Only":
Smriti Mohan Shetty
Smriti Mohan Shetty 2022 年 12 月 7 日
編集済み: Smriti Mohan Shetty 2022 年 12 月 7 日
Thank you! I removed demlimiter and space and just gave it a range so it worked.
Data_export = [FreqFinal PeriodFinal amplitudeFinal error]
writematrix(Data_export,'ExampleMatlab.xlsx','Range','CD9')

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

その他の回答 (1 件)

David
David 2022 年 12 月 6 日
data = [1 2 3; 4 5 6; 7 8 9]; % create some data to write to the file
% write the data to an Excel file named "myfile.xls"
xlswrite('myfile.xls', data);

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by