how to fill in zeros in index not used?
1 回表示 (過去 30 日間)
古いコメントを表示
I need to create a vector B with length = 3;
And i know that B(2) = 5;
Then how to fill B(1) = 0 and B(3) = 0;
Output should be like : B = [0,5,0] ---> CASE 1
EXAMPLE CASE 2:
And i know that B(1) = 5;
Then how to fill B(2) = 0 and B(3) = 0;
Output should be like : B = [5,0,0] ---> CASE 2
0 件のコメント
回答 (2 件)
jonas
2018 年 5 月 25 日
Not sure I understand the question, but...
B=zeros(1,3);
%Case 1
B(2)=5
%Case 2
B(1)=5
0 件のコメント
JAYANTH BHIMAVARAPU
2018 年 6 月 30 日
B = zeros(1,length); B(2) = 5;
//Just initialize the vector with zeros(m,n) function and then feed the data as you want
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!