Hi there i have a question
n=10;
x=rand(n,1)
for i=1:n-1
h(i)=x(i+1)-x(i);
iter_h=iter_h+1;
end
I get the ouput which is in array is this right? If so how can i change to a vector?

 채택된 답변

Jan
Jan 2021년 3월 19일

0 개 추천

Vectors are arrays.
Your code does not use iter_h anywhere. It can be simplified to:
n = 10;
x = rand(n, 1);
h = diff(x);

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2020a

질문:

2021년 3월 18일

답변:

Jan
2021년 3월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by