Operation with components of a vector and for loop
1 view (last 30 days)
Vittorio Locatelli on 3 May 2022
Good morning everyone,
given a vector of n components, I would need to perform the following operation: dist = n- (n-1) for all n.
Since the size of the vector is an unknown I interrogated the software to derive this and then I thought of building a for loop as described below. I think I understand the problem, I think that in the first matlab cycle I can't identify the second component to subtract and does not identify the component "n-1 = 0" but I can't think of anything alternative.
for i = 1:nlocsrif
picco = sprintf("locsrif(%d)", i)
I trust in your solution and thank you in advance for the answers