How to create a matrix with a for- loop
显示 更早的评论
Hi, i'm trying to create a matrix using a for-loop and conditional.
I want to create
B= 1 1 1
0 0 0
1 1 1
回答(2 个)
A = zeros(3) ;
A(1,:) = 1 ;
A(3,:) = 1 ;
A
Amit Bhowmick
2021-7-1
Check with this
n=3;
B=zeros(n);
for ii=1:n
for jj=1:n
B(ii,jj)=rem(ii,2);
end
end
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!