Info

この質問は閉じられています。 編集または回答するには再度開いてください。

sparse 2matrix getting an error

1 回表示 (過去 30 日間)
Abhishek singh
Abhishek singh 2019 年 4 月 22 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
function A=mysp2matsp(rowIdx,colIdx,entries)
%% transform three-arrays sparse matrix to matlab sparse matrix
nrow = size(rowIdx,2) - 1;
N = size(entries,2);
k = 1;
I = zeros;
J = zeros;
S = zeros;
for i = 1:nrow
j = rowIdx(i);
if i == nrow
for p = j:N
I(k) = i;
J(k) = colIdx(p);
S(k) = entries(p);
k = k + 1;
end
break;
end
for p = 1:(rowIdx(i+1)-rowIdx(i))
I(k) = i;
J(k) = colIdx(j);
S(k) = entries(j);
j = j + 1;
k = k + 1;
end
end
for i = N:-1:1
if S(i)==0
I(i) = [];
J(i) = [];
S(i) = [];
end
end
A=sparse(I,J,S);
end
error
Not enough input arguments.
Error in sparse2matrix (line 5)
N = size(entries,2);
  2 件のコメント
Walter Roberson
Walter Roberson 2019 年 4 月 22 日
When you ran the code, you only passed in either one parameter or else two parameters. You did not pass in three parameters.
We know that you passed in at least one parameter because you would have received the error about insufficient parameters on the line above there where you referred to rowIdx
KSSV
KSSV 2019 年 4 月 22 日
YOu are trying to run the function without inputs........give required inputs and call the function.

回答 (0 件)

タグ

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by