How to generate and store in different sizes vectors or cells in a loop?

1 view (last 30 days)
Good morning,
I have an initial vector:
A=[0.01, 0.12, 0.017, ....] %100 elemets
Vneg=[v1;v2;v3...v6];
Vpos=[v1;v2;v3...v6];
I want to genereate new vectors (according to number of Vneg) between two limites Vneg and Vpos.
In this example I expect to get 06 vectors with values of A between each Vneg and Vpos
I tried this code:
for con=1:length(Vneg);
interval(con)=A(A(:,1)>=Fneg(con2) & A(:,1)<=Fpos(con2));
end
And keep getting an error message.
I tried with cell arrays. can't figure it out.
any help please?

Accepted Answer

Matt J
Matt J on 31 Jul 2022
Edited: Matt J on 31 Jul 2022
Use cell arrays.
interval=cell(1,length(Vneg));
for con=1:length(Vneg);
interval{con}=A(A(:,1)>=Fneg(con2) & A(:,1)<=Fpos(con2));
end

More Answers (0)

Community Treasure Hunt

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

Start Hunting!