How to create excel sheet for developed model using MATLAB

2 ビュー (過去 30 日間)
Maya
Maya 2023 年 2 月 22 日
編集済み: Shaunak 2025 年 5 月 16 日
I have subsystem which is having few input/output. I want to do testing using excel sheet.
How to create excel using script which generate input and output inside excel.
or any other way to test the model.
Please let me know the solution
  2 件のコメント
KSSV
KSSV 2023 年 2 月 22 日
What is that input and output?
Maya
Maya 2023 年 2 月 22 日
user inputs as shown in figure

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

回答 (1 件)

Shaunak
Shaunak 2025 年 5 月 16 日
編集済み: Shaunak 2025 年 5 月 16 日
Hi Maya,
It is my understanding that you want to generate an Excel sheet containing both input and output data for your Simulink system to facilitate testing. You can use MATLAB’s built-in functions to programmatically create and write data to an Excel file. This approach lets you automate the process and ensures your test data is well organized for later analysis.
Here is an example of how you can generate some sample input data, simulate the model to get outputs, and write both to an Excel sheet:
% Example: Generate test input data
N = 100; % Number of test cases
input1 = randn(N,1); % Example input 1
input2 = rand(N,1); % Example input 2
% Combine inputs into a table
inputTable = table(input1, input2);
% (Optional) Simulate your model here to get outputs
% For demonstration, let's create some dummy outputs
output1 = 2*input1 + 3*input2; % Replace with your model's output
output2 = input1 - input2; % Replace with your model's output
% Combine inputs and outputs into one table
testData = table(input1, input2, output1, output2);
% Write the table to an Excel file
writetable(testData, 'model_test_data.xlsx');
% Now, 'model_test_data.xlsx' contains both input and output data
You can use this Excel file for further testing or as a test harness for your Simulink model.
For more details on writing data to Excel in MATLAB, you can refer to the following documentation:
Hope this helps!

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by