converting an excel formula into matlab

35 ビュー (過去 30 日間)
C.G.
C.G. 2021 年 8 月 16 日
コメント済み: C.G. 2021 年 8 月 16 日
I've written the formulas out that I require in excel, but now I want to put these into matlab.
The current matlab code I have is below, but I am struggling to convert column D in my excel file to code in matlab. Could anybody help?
resV = sqrt(vel(:,1).^2 +vel(:,2).^2 + vel(:,3).^2);
time = 1:1935804;
time = time';
GT = resV-mean(resV);
GT2 = GT.^2;
RMS = sqrt(

採用された回答

Wan Ji
Wan Ji 2021 年 8 月 16 日
Hi, friend, I have translated your excel function to matlab command line.
clc;clear
a = readtable('C-RMSfluctuation.xlsx','PreserveVariableNames',true);
cols = a.Properties.VariableNames;
a{:,cols{3}} = a{:,cols{2}}.^2;
a{:,cols{4}} = sqrt(cumsum(a{:,cols{3}})./a{:,cols{1}});
writetable(a,'C-RMSfluctuation_New.xlsx') % strore the result in a new xlsx file
The result table is shown like this
  2 件のコメント
Wan Ji
Wan Ji 2021 年 8 月 16 日
If you want to totally implement your idea with matlab, then:
resV = sqrt(vel(:,1).^2 +vel(:,2).^2 + vel(:,3).^2);
time = 1:1935804;
time = time';
GT = resV-mean(resV);
GT2 = GT.^2;
col_4 = sqrt(cumsum(GT2)./time);
a = table(time, col_4);
writetable(a,'NewTable.xlsx')
C.G.
C.G. 2021 年 8 月 16 日
Thank you, your code worked well!

サインインしてコメントする。

その他の回答 (1 件)

dpb
dpb 2021 年 8 月 16 日
resV = vecnorm(vel,2,2); % 2-norm by row
time = 1:1935804.'; % dunno what time represents, use a timetable instead, maybe?
GT = detrend(resV); % again, use MATLAB-supplied function
RMS = rms(GT); % and yet again, builtin guessing is what wanted rms of...
It's daunting to find all the functions that are available initially, granted...just takes some time.
The venerable lookfor command is still valuable if you have an idea of what you want but don't know the name...
  1 件のコメント
C.G.
C.G. 2021 年 8 月 16 日
Thank you for your response, but thats not what I need.
I want to be able to write this formula in matlab: =SQRT(((SUM(C$2:C4)/A4)))

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by