필터 지우기
필터 지우기

How do I stop the code and get the results?

조회 수: 14 (최근 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 CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by