How do I stop the code and get the results?

9 ビュー (過去 30 日間)
Omar B.
Omar B. 2022 年 3 月 4 日
コメント済み: Omar B. 2022 年 3 月 9 日
I am trying to run the Matlab code for Arnoldi method. The code dose not stop because the matrix is too large,. Is there a way to get the output?
[V,H] = Arnoldi();
function [V,H]=Arnoldi(A,v1,m)
% Load the data
load('soc-Epinions1.mat');
A = Problem.A;
n=size(A,1);
m=9000;
V=zeros(n,m);
H=zeros(m,m);
v1=rand(n,1);
V(:,1)=v1/norm(v1);
for j=1:m % the Anoldi loop
z=A*V(:,j);
for i=1:j
H(i,j)=V(:,i)'*z;
z=z-H(i,j)*V(:,i);
end
H(j+1,j)=norm(z);
if H(j+1,j)==0, break, end
V(:,j+1)=z/H(j+1,j);
end
H=H(1:m,1:m);
V=V(1:n,1:m);
f=diag(V*(expm(H)-eye(m))*V')
end
  6 件のコメント
Omar B.
Omar B. 2022 年 3 月 5 日
I do not know if the authers used a technique to get the results. In their paper, they just used Arnoldi process with different values of iteration (m) and obtained the results when m=9000 by compute the diagonal of Vf(H)V' . Anyways, thank you for your help.
Walter Roberson
Walter Roberson 2022 年 3 月 5 日
Perhaps they just ran the code on a larger system. The code ran on my system. Not quickly, but it ran.

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

回答 (1 件)

Steven Lord
Steven Lord 2022 年 3 月 5 日
If you're out of time and need to get the results that have been computed, under certain circumstances (the main ones being the MATLAB Editor is open and you're using a sufficiently new release, plus the code has to give MATLAB a chance to recognize and process events) press the Pause button on the Editor tab of the toolstrip. save or assignin (into the base workspace) the results that you want to access and then either quit debugging (if you want to terminate the execution of the function) or continue (if you want to let it continue.)
Note that if you do this and quit debugging there's no way to "let MATLAB restart from where it was" unless your function was specifically designed to accept variables representing the state of the function's execution.
  6 件のコメント
Walter Roberson
Walter Roberson 2022 年 3 月 8 日
syms f [5 3]
syms V [5 3]
b1 = diag(f*V')
b1 = 
b2 = sum(f.*conj(V),2)
b2 = 
b1 - b2
ans = 
So... you can use
load('soc-Epinions1.mat');
A = Problem.A;
n = size(A,1);
v1 = randn(n,1);
m = 2000;
[V, H] = Arnoldi4(A, v1, m);
f = V*(expm(H)-eye(m));
b = sum(f .* conj(V),2);
Omar B.
Omar B. 2022 年 3 月 9 日
Thank you very much. I got the same results as in the paper. Thank you again.

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

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by