Custom excel formulas/functions in matlab
2 views (last 30 days)
Show older comments
Chun Fai Leung
on 15 Jul 2022
Commented: Chun Fai Leung
on 15 Jul 2022
I used other's matlab coding to generate data's of some tracked particles and I would like to calculate the mean square displacement. The following are the excel data sheet.
and I would like to use matlab for further handling the datas, in column K, I would like to input the excel formulas of =((H1)^2+(I1)^2+(J1)^2)/3 and loop til the end for each row respectively. and for column L, I would like to input the excel formulas of =max(column F). However, I am new to matlab and unable to write the code for the excel functions.
I understand that i need to use xlsread and xlswrite. So importing the excel file should be like this, right?
clear
dataset = xlsread("12.35mW-cm22_gray.xlsx",'5')
Then write code for the excel formulas.
Then use xlswrite to read a new excel file.
Could someone please help? I would appreciate your help a lot. Thank you.
0 Comments
Accepted Answer
Amritesh
on 15 Jul 2022
You can import your .xls file in variable dataset, then make changes to it and finally export that in .xls file.
dataset = xlsread("12.35mW-cm22_gray.xlsx",'5')
for i=1:length(dataset)
dataset(i,11) = (dataset(i,8)^2 + dataset(i,9)^2 + dataset(i,10)^2)/3; % H -> 8, I -> 9, J ->10, K ->11
end
writetable(dataset,'modifiedDataset.xlsx');
Hope this solves your problem.
More Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!