フィルターのクリア

how to calculate for each column

1 回表示 (過去 30 日間)
kitty varghese
kitty varghese 2017 年 10 月 4 日
コメント済み: Walter Roberson 2017 年 10 月 5 日
I want to calculate the value for each column
A=[1 -8 5 -7;2 1 -1 1;-9 2 3 -8]
zerocoeff=[];%intialising
for k=1:10
mid=23/4-length(zerocoeff); %..eqn1
mid(zerocoeff)=0;
for i=1:3
for j=1:4
zerocoeff(i,j)=(A(i,j)<=0); %......eqn2
end
initially it should calculate with length(zerocoeff)=0 to calculate mid value and then after first iteration overwrite mid value with column wise length(zerocoeff)
  2 件のコメント
Jan
Jan 2017 年 10 月 4 日
@kitty: You forgot to ask a question. It is not efficient to let the readers guess the intention of the code and the problem you might have with it.
You are not a newcomer in the forum. Please remove the "if true ... end" from the code. It is polite to post proper code. Thanks.
The line
zerocoeff=[];%intialising
is useless: You overwrite the contents in the next line. Simply omit it.
Walter Roberson
Walter Roberson 2017 年 10 月 5 日
I see that you have revised the code and explained more, but I do not know what question you are asking? Are you not already calculating for each column in your "for j" loop? Do you need to do something more than reversing the order of "for i" and "for j" ?

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 10 月 4 日
Guessing about what you are doing:
zerocount = sum(A == 0);
mi = 5 - zerocount;

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by