How to create excel sheet for developed model using MATLAB
조회 수: 6 (최근 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!