How to create excel sheet for developed model using MATLAB

2 Ansichten (letzte 30 Tage)
Maya
Maya am 22 Feb. 2023
Bearbeitet: Shaunak am 16 Mai 2025
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

Antworten (1)

Shaunak
Shaunak am 16 Mai 2025
Bearbeitet: Shaunak am 16 Mai 2025
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!

Kategorien

Mehr zu Data Import from MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by