An error Occur While I was COding in matlab,Attention Please I am in a - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

An error Occur While I was COding in matlab,Attention Please I am in a

weicellweicell Posts: 1Member
function [z,y,wmax,xmax]=Condition(A)
[m,n]=size(A); % Get the dimensions of A
w=ones(m,1); % Start with initial guess eigenvalues
imax=60;
tol=10^-10;
for i=1:imax
[kk,k]=max(abs(w)); % Returns the indices of the maximum w values in vector k
z=w/w(k); % Normalize w with respect to maxw=w(k)
w=A*z; % Calculate w again
wmax=w(k); % z(k)=1
r=norm(wmax*z-w); % Use Euclidean form (norm(w,p) = sum(abs(w).^p)^(1/p))
final=[i,wmax,r,z'];
if r
end

B=inv(A);
% Get the dimensions of A
x=ones(m,1); % Start with initial guess eigenvalue
for i=1:imax
[kk,k]=max(abs(x)); % Returns the indices of the maximum w values in vector k
y=x/x(k); % Normalize w with respect to maxw=w(k)
x=B*y; % Calculate w again
xmax=x(k); % z(k)=1
r=norm(xmax*y-x); % Use Euclidean form (norm(w,p) = sum(abs(w).^p)^(1/p))
final=[i,xmax,r,y'];
if r
end
end
end
xmin=1/xmax
wmax
condition=wmax*xmax

And An erro occurs;

Error in ==> Condition at 2
[m,n]=size(A); % Get the dimensions of A
How can I correct it?

Comments

  • nipnip Posts: 5Member
    Make sure the input you give that function is an array or a vector, cause it looks right to me.
Sign In or Register to comment.