フィルターのクリア

Vector element replacement by specified variables

2 ビュー (過去 30 日間)
Olawale Oyewole
Olawale Oyewole 2023 年 6 月 16 日
コメント済み: Voss 2023 年 6 月 17 日
I am currently having issues with this code. I want to replace each entry of a vector with specified values.
for i=1:3
x=[1 2 5];
y=zeros(1,3);
y(1:1:3)=1+log(x(i));
end
That is I want y=[0 0 0] replaced by y=[1+log(x(1)) 1+log(x(2)) 1+log(x(3))].
Thanks in anticipation.

採用された回答

Voss
Voss 2023 年 6 月 16 日
x = [1 2 5];
y = 1+log(x);
x,y
x = 1×3
1 2 5
y = 1×3
1.0000 1.6931 2.6094
  2 件のコメント
Olawale Oyewole
Olawale Oyewole 2023 年 6 月 16 日
Thanks for your response
Voss
Voss 2023 年 6 月 17 日
You're welcome! Any questions, let me know. Otherwise, please "Accept This Answer". Thanks!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLanguage Support についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by