filename = 'TestF2.xlsx';
opts = detectImportOptions(filename);
testresults = readtable(filename, opts);
Measured = testresults.Measured;
Trend = testresults.Mea_Trend;
RMSE_value = sqrt(mean((Measured - Trend).^2));
testresults.RMSE = NaN(height(testresults), 1);
testresults.RMSE(1) = RMSE_value;
writetable(testresults, filename, 'Sheet', 1, 'Range', 'A1');
This code snippet assumes that the Excel file 'TestF2.xlsx' is in the MATLAB current directory. It will read the file, calculate the RMSE, add the new column, and then save the table back to the same Excel file, starting at cell E1 which corresponds to the new fifth column. If your 'Measured' and 'Mea_Trend' columns have different names, make sure to replace them in the code with the actual names used in your Excel file.
---------------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
- Technical Services and Consulting
- Embedded Systems | Firmware Developement | Simulations
- Electrical and Electronics Engineering
Feel free to contact me.