How to use SUM of Series in Matlab with .txt files?

3 ビュー (過去 30 日間)
Julio Alvarado
Julio Alvarado 2020 年 1 月 24 日
回答済み: Walter Roberson 2020 年 1 月 24 日
Hi everyone!
I have 2 files with 2 cols each one( time vs Voltage or X vs Y), I try to calculate the following series but the result is always Zero (0) , What is the mistake ?
x(n) is the input vector signal
x´(n) is the output vector signal
CODE:
ECG=csvread('ecgfile1.txt');%INPUT SIGNAL
t1 = ECG(:, 1);%TIME COL 100000X1 double DATA
v1 = ECG(:, 2);%VOLTAGE COL
Prom=csvread('ecgfile2.txt');%OUTPUT SIGNAL
t2 = Prom(:, 1); %T2 100000x1double DATA
v2 = Prom(:, 2);
N=length(t1);%
for n=1:N
PRD=(sqrt( ( (t1(n)-mean(t2(n))).^2) ./ (t1(n).^2) ))*100;
end

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 1 月 24 日
num = 0;
denom = 0;
for n=1:N
num = num + (v1(n) - v2(n)).^2;
denom = denom + v1(n).^2;
end
PRD = sqrt(num ./ denom) .* 100;
Or in vectorized form:
PRD = sqrt( sum( (v1-v2).^2 ) ./ sum(v1.^2) ) .* 100;

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by