Effacer les filtres
Effacer les filtres

How can the code memorize the generated vector?

3 vues (au cours des 30 derniers jours)
GEORGIOS BEKAS
GEORGIOS BEKAS le 12 Fév 2018
Commenté : GEORGIOS BEKAS le 12 Fév 2018
Is there a quick way to memorize the generated out matrix in each iteration?
in1=[1 8 12]
in2=[4 5 9]
out=[]
counter = 1
for i =1 :length(in1)
if in1(i)<in2(i)
out=in1(i):in2(i)
else
out=in1(i):-1:in2(i)
end
end

Réponses (1)

KSSV
KSSV le 12 Fév 2018
in1=[1 8 12]
in2=[4 5 9]
out=zeros(length(in1),[]) ;
counter = 1
for i =1 :length(in1)
if in1(i)<in2(i)
out(i,:)t=in1(i):in2(i)
else
out(i,:)=in1(i):-1:in2(i)
end
end
  2 commentaires
GEORGIOS BEKAS
GEORGIOS BEKAS le 12 Fév 2018
error: p1080: A(I,J,...) = X: dimensions mismatch
GEORGIOS BEKAS
GEORGIOS BEKAS le 12 Fév 2018
out=[]
and then it needs to be reshaped

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB Coder dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by