フィルターのクリア

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

1 回表示 (過去 30 日間)
Mahmoud Chawki
Mahmoud Chawki 2022 年 5 月 10 日
コメント済み: Mahmoud Chawki 2022 年 5 月 10 日
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 日
b=repelem(t,n)
  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;
Mahmoud Chawki
Mahmoud Chawki 2022 年 5 月 10 日
wow quick thinking great job.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop 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