필터 지우기
필터 지우기

i want to translate this vector to a formal syntax that i can use always

조회 수: 1 (최근 30일)
clc
clear all
n=4;
t=0.25;
h=n*t
for i=1:n+1
if i==1
k(i)=-h/2;
else
k(i)=-h/2+(i-1)*t;
end
end
b=[k(2)-k(1) k(3)-k(2) k(4)-k(3) k(5)-k(4)];
the code works fine, howvever i want to obtain vector b with using the right syntax. Meaning that i want to write it as a syntax form that will give me same results that vector b gives me (without manualy plotting the values of k everytime).

채택된 답변

Matt J
Matt J 2022년 5월 10일
편집: Matt J 2022년 5월 10일
  댓글 수: 3
Matt J
Matt J 2022년 5월 10일
편집: Matt J 2022년 5월 10일
Because k(i) is a linear function of i with slope t,
k(i)=-h/2+(i-1)*t;

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by