필터 지우기
필터 지우기

How can the code memorize the generated vector?

조회 수: 3 (최근 30일)
GEORGIOS BEKAS
GEORGIOS BEKAS 2018년 2월 12일
댓글: GEORGIOS BEKAS 2018년 2월 12일
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

답변 (1개)

KSSV
KSSV 2018년 2월 12일
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
GEORGIOS BEKAS
GEORGIOS BEKAS 2018년 2월 12일
error: p1080: A(I,J,...) = X: dimensions mismatch
GEORGIOS BEKAS
GEORGIOS BEKAS 2018년 2월 12일
out=[]
and then it needs to be reshaped

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by