I am trying to get subtraction from the strain data of all channels to the strain data of channel 1. But the following codes give me the subtraction only from channel 2 to channel 1. I don't get the other channels. Please help me to correct the codes.
data1 = Dasdata.Strain(channels,1)';
for i = 2:53
data2 = Dasdata.Strain(channels,i);
y = data2-data1;
plot(y)
end

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 18 Nov. 2021

0 Stimmen

data1 = Dasdata.Strain(channels,1)';
for i = 2:53
data2 = Dasdata.Strain(channels,i);
y = data2-data1;
plot(y, 'DisplayName', "channel " + i);
hold on
end
hold off
legend show

2 Kommentare

Iffat Arisa
Iffat Arisa am 29 Nov. 2021
Thanks.
I have 53 columns and 40000 rows in a matrix. I need to subtract from column 2 to column 1, column 3 to column 1,.. To get all columns including all elements - column 1, which Matlab command should be used?
Use implicit expansion.
A = randi(10, 5, 10) % sample data between 1 and 10
A = 5×10
9 5 6 10 5 5 1 5 1 7 9 5 9 4 4 1 10 3 1 6 8 9 7 1 1 2 1 7 7 8 3 10 6 7 10 7 5 6 10 8 3 3 10 10 1 10 7 10 7 10
B = A - A(:, 1)
B = 5×10
0 -4 -3 1 -4 -4 -8 -4 -8 -2 0 -4 0 -5 -5 -8 1 -6 -8 -3 0 1 -1 -7 -7 -6 -7 -1 -1 0 0 7 3 4 7 4 2 3 7 5 0 0 7 7 -2 7 4 7 4 7

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by