How to create excel sheet for developed model using MATLAB
2 次查看(过去 30 天)
显示 更早的评论
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
回答(1 个)
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!
0 个评论
另请参阅
类别
在 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!