In a function we need to input the first element of matrix?
    조회 수: 5 (최근 30일)
  
       이전 댓글 표시
    
for say let the function be
function[d]=myFIRST(x,y)
for i=1:100
    y(i+1)=x+y(i)
    d=y;
end
end
myFIRST(1,2)
here y is iteratively changing and the first element is defined.
it doesnt read iteratively new values
댓글 수: 4
  Davide Masiello
      
 2023년 1월 10일
				That's not the case for me, all the iterations are displayed.
myFIRST(1,2)
function[d]=myFIRST(x,y)
for i=1:100
    y(i+1)=x+y(i)
    d=y;
end
end
답변 (1개)
  Mathieu NOE
      
 2023년 1월 23일
        hello 
simply this.  personnay I don't like to use the same variable name in both iput and output of a function . 
y = myFIRST(1,2)
function[y]=myFIRST(x,y)
    for i=1:100 
        y(i+1)=x+y(i);
    end
end
댓글 수: 2
  Stephen23
      
      
 2023년 1월 23일
				"I don't like to use the same variable name in both iput and output of a function."
  Dyuman Joshi
      
      
 2023년 1월 23일
				
      편집: Dyuman Joshi
      
      
 2023년 1월 23일
  
			Thank you for the comment, @Stephen23. This was something I was looking for, but couldn't word it properly when I asked this question - Replacing Arrays and Matrices
Can you edit your answer on my question to include this info? So I can accept your answer.
참고 항목
카테고리
				Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




