I am facing error while executing this code,pls help me to solve this issue

A = [ 1 12 3 9 5
11 7 8 14 10
6 2 13 4 15]
C = zeros(size(A)) ;
[val,idx] = max(abs(A)) ;
for i = 1:size(A,3)
[val,idx] = max(abs(A(:,i)));
C(idx,i) = val
end

6 件のコメント

Birdman
Birdman 2017 年 11 月 27 日
What do you want to do with the code?
Prabha Kumaresan
Prabha Kumaresan 2017 年 11 月 27 日
if I run this code the value of idx is displayed as 2,but its not 2,and if i change the value of A to (5*10) or (4*15) the code was not getting executed.
Birdman
Birdman 2017 年 11 月 27 日
Ok,but what do you want to see for idx instead of 2?
Prabha Kumaresan
Prabha Kumaresan 2017 年 11 月 27 日
why idx is set to 2 even if i change the number of rows in A to 5 or 10
Prabha Kumaresan
Prabha Kumaresan 2017 年 11 月 27 日
ok A is 2D. if i change the number of rows in A to 5 or 10 in for loop the command i = 1:size(A,2) whether needs to get changed to i = 1:size(A,5) or i = 1:size(A,10)
KSSV
KSSV 2017 年 11 月 27 日
Irrespective of what is size of A..it should be size(A,2)...red about size command in matlab.

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

回答 (1 件)

KSSV
KSSV 2017 年 11 月 27 日

0 投票

It should be run till size(A,2) not size(A,3)...note that your matrix A is 2D not 3D.

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

タグ

質問済み:

2017 年 11 月 27 日

コメント済み:

2017 年 11 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by