forcing the final column in a matrix to be zero

조회 수: 1 (최근 30일)
A Poyser
A Poyser 2023년 3월 31일
댓글: A Poyser 2023년 3월 31일
I want to make the final column to go to zero once I go past a certain flag number
k = 10
a = zeros(1:k)
if b < 1
a = (end 0)
end
I think it looks something like this but I know it isn't exactly right
please help
Alex

채택된 답변

VBBV
VBBV 2023년 3월 31일
편집: VBBV 2023년 3월 31일
k = 10
k = 10
a = ones(3,k)
a = 3×10
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
b = -1;
if b < 1
a(:,end) = 0;
end
a
a = 3×10
1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by