필터 지우기
필터 지우기

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 CenterFile Exchange에서 Language Support에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by