spy doesn't work - why?

5 ビュー (過去 30 日間)
Clothilde Breger
Clothilde Breger 2020 年 6 月 5 日
コメント済み: Clothilde Breger 2020 年 6 月 7 日
Hello,
I am calling spy on a sparse matrix J, within a subfunction, but the result is not displayed when I run my main.
The matrix is first created with the command sparse (m, n) as a null matrix of dimensions m*n. Then I fill it in as needed with a for, line by line, by taking subsections of the line and assigning to that subsection a vector of ones.
What could I be doing wrong that makes it so that the result of spy isn't displayed?
Basic pseudocode (the actual indexes are more complex, they are for a Jacobian pattern):
J = sparse (m, n);
for i=1:m
J(i, 5:9) = ones(5, 1);
end
spy(J)
  4 件のコメント
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2020 年 6 月 5 日
It does work ok:
m=13; n=23;
J = sparse (m, n);
for i=1:m
J(i, 5:9) = ones(5, 1);
end
spy(J) ; shg
Clothilde Breger
Clothilde Breger 2020 年 6 月 7 日
I don't know, the code was given to me for a uni project, I only filled in the matrix and used spy(J) according to what we saw in class (but it was already created using sparse, not spalloc, to avoid making the question too easy I suppose).
I'll ask my teacher about it, since it could be linked to how I use the rest of the code.
Thank you for your help :)

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

回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by