How can I create multiple arrays from 2 separate arrays?

1 vue (au cours des 30 derniers jours)
Sang Duong
Sang Duong le 17 Oct 2022
Commenté : Kevin Holly le 17 Oct 2022
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?

Réponse acceptée

Kevin Holly
Kevin Holly le 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
  2 commentaires
Sang Duong
Sang Duong le 17 Oct 2022
Thanks Kevin. This is perfect
Kevin Holly
Kevin Holly le 17 Oct 2022
Please accept the answer then.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits


Version

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by