How do I stop the code and get the results?

18 Ansichten (letzte 30 Tage)
Omar B.
Omar B. am 4 Mär. 2022
Kommentiert: Omar B. am 9 Mär. 2022
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 Kommentare
Omar B.
Omar B. am 5 Mär. 2022
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 am 5 Mär. 2022
Perhaps they just ran the code on a larger system. The code ran on my system. Not quickly, but it ran.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Steven Lord
Steven Lord am 5 Mär. 2022
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 Kommentare
Walter Roberson
Walter Roberson am 8 Mär. 2022
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. am 9 Mär. 2022
Thank you very much. I got the same results as in the paper. Thank you again.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by