forcing the final column in a matrix to be zero

1 次查看(过去 30 天)
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