9 views (last 30 days)

Hello saviors,

I am struggling with a structural health monitoring project. I'm expected to code the RMSD between two signals (one reference signal and another signal calculated by a sensor).

I did a first attempt but it didn't work. I'm a beginner at matlab so maybe my mistake is dumb but I would appreciate any help or clue. This is my code :

clc

clear

close all

load ('probewithwithout.mat')

RMSd = []

time = 1:1:1;

positions = 1:1:2;

for i = time

for j = positions

RMSd(i,j) = sqrt(sum((time(i).probewith(:,j)-time(i).probewithout(:,j)).^2)/sum(time(i).probewithout(:,j).^2));

end

end

With the file "probewithwithout" (means probe with crack and without crack), I have this in which I stored my data in the form of vectors :

I'm so confused I don't even know what I don't know anymore.

Thanks in advance!

Jon
on 17 Sep 2020

Edited: Jon
on 17 Sep 2020

Looking at your variables in the workspace I see the signals probeWith and probeWithout. Each arrays with two columns. I assume each column is for a position of the sensors. Think of each array as two column vectors side by side.

You could compute rmsd as:

% compute deviations

deviation = probeWith - probeWithout % column vector of deviation values

% compute covariance

cov = deviation'*deviation % note ' on first term makes it a row vector

% compute rmsd (don't need the cross terms)

rmsd = diag(sqrt(cov))

Note the inner product (row vector time column vector) above computes the sum of the squared deviation

Jon
on 17 Sep 2020

Jon
on 17 Sep 2020

Since I assume you are only interested in the deviations between the signals at the same location (column in your probe matrices) you could also loop over the locations. This would perhaps make it more obvious what you were calculating, but usually in MATLAB it is nice to take advantage of its ability to handle matrix vector operations without loops. Just to illustrate this would look like:

rmsd = zeros(2,1); % preallocate array to hold result

for k = 1:2 % loop over positions

deviation = probeWith(:,k) - probeWithout(:,k);

rmsd(k) = sqrt(deviation'*deviation);

end

Jon
on 17 Sep 2020

Opportunities for recent engineering grads.

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

Start Hunting!
## 1 Comment

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/595438-rmsd-between-two-signals#comment_1013029

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/595438-rmsd-between-two-signals#comment_1013029

Sign in to comment.