Subtraction in For Loop not executing
Show older comments
So I have a Cell called "Messdaten" which has N furhter Cells with 6 nx2 doubles where the first column is the time and the second is my data.
I am trying to apend my data right after each other as the times of the N Cells are not sqeuntial - theres gaps.
Therefore I try to make my time_j(1) = 0 by substracting time_j(1) from the array time_j.
However this line of code does not execute.
for i=1:N
SW_uf = Messdaten{:,i};
for j = 1:length(SW_uf)
t_vs_phi_i = SW_uf{:,j};
time_j = t_vs_phi_i(:,1);
phi_i = t_vs_phi_i(:,2);
time_j = time_j - time_j(1);
time_j = time_j - time_j(1);
for m = 1:LW(i)
phi_i_bl = phi_i(1:length(phi_i) - 1);
time_i_bl = time_j(1:length(time_j) - 1) + t_l(j);
t_l(j) = time_i_bl(length(time_i_bl));
end
VD_j{j} = [time_i_bl phi_i_bl];
phi_i_bl = [];
time_i_bl = [];
end
Schwingungen{i} = [VD_j];
end
Heres an example of what my current results look like in a graph. It should start at zero and the second batch periods should start right after the first.

Thank you in advance!
Answers (1)
Walter Roberson
on 15 May 2022
for m = 1:LW(i)
phi_i_bl = phi_i(1:length(phi_i) - 1);
time_i_bl = time_j(1:length(time_j) - 1) + t_l(j);
t_l(j) = time_i_bl(length(time_i_bl));
end
for m but assign indexed at j??
By the way, consider using the index named "n", as in time_i_bl(end-1) instead of (length(time_i_bl)-1)
1 Comment
Manuel Weinhappl
on 16 May 2022
Categories
Find more on Introduction to Installation and Licensing 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!