How can I create multiple arrays from 2 separate arrays?

1 view (last 30 days)
I want to create arrays from A and B, from A(1):B(1), A(2):B(2), A3(B),....... I have never done this before and I don't know how to make it work?

Accepted Answer

Kevin Holly
Kevin Holly on 17 Oct 2022
Is this what you were trying to do?
A = [1,3,5,7];
B = [2,4,6,8];
for i = 1:length(A)
array(i,:) = A(i):0.1:B(i);
end
array
array = 4×11
1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000 3.0000 3.1000 3.2000 3.3000 3.4000 3.5000 3.6000 3.7000 3.8000 3.9000 4.0000 5.0000 5.1000 5.2000 5.3000 5.4000 5.5000 5.6000 5.7000 5.8000 5.9000 6.0000 7.0000 7.1000 7.2000 7.3000 7.4000 7.5000 7.6000 7.7000 7.8000 7.9000 8.0000

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products


Release

R2016a

Community Treasure Hunt

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

Start Hunting!