フィルターのクリア

setting column of a matrix to zero

16 ビュー (過去 30 日間)
Prince Igweze
Prince Igweze 2019 年 11 月 7 日
回答済み: Bhaskar R 2019 年 11 月 7 日
A(j,k) = exp((-a * j^2 * z)/mt(k))
A is a 20 by 50 matrix
how can i set column 25 - 30 of A to zero
thank you

回答 (2 件)

Bhaskar R
Bhaskar R 2019 年 11 月 7 日
a(:, 25:30) = 0; % all columns from 25 to 30 assigned as 0's
Refer the link for the MATLAB matrix indexing

Muhammad Usman
Muhammad Usman 2019 年 11 月 7 日
You haven't define constants a and z, and a vector mt, so I suppose a=-1, z=4 and mt=rand(1,50) and following lines of code to produce zeros in your required columns
a=-1; z=4;
mt=rand(1,50);
A=zeros(20,50);
for j=1:20
for k=1:50
A(j,k) = ((-a * j^2 * z)/mt(k));
if k>=25 && k<=30
A(j,k)=0;
end
end
end
A

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by