problem with workspace matlab 2020b

I have a problem with workspace ı can not see variables while code is working perfectly also ı can not see any plotting

 Respuesta aceptada

Walter Roberson
Walter Roberson el 5 de Dic. de 2020

1 voto

The code you posted is a function. Local variables for a function disappear after the function returns; you would have to put in a breakpoint before the end of the function to see the local variables.
Your posted code does not plot anything.

3 comentarios

function GaussSeidel
close all
clear all
n=10;
for i1=1:n
b(i1)=i1
for j1=1:n
a(i1,j1)=((i1*(-1)^j1)/70 +(j1*(-1)^i1)/50);
end
sumvalue=0;
for j1=1:i1-1
sumvalue=sumvalue+abs(a(i1,j1));
end
for j1=i1+1:n
sumvalue=sumvalue+abs(a(i1,j1));
end
a(i1,i1)=sumvalue;
end
b=transpose(b);
Detofa=det(a)
eigenvalueofa=eig(a);
conditionnumberofa=max(abs(eigenvalueofa))/min(abs(eigenvalueofa))
inverseofa=inv(a);
Xinv=inverseofa*b;
error=a*Xinv-b;
L2error=sqrt(transpose(error)*error);
for i1=1:n
X(i1)=1.0;
end
X=transpose(X);
L2errors=0.01
L2errora=1.0
iter=0;
lambda=0.4;
while L2errora>L2errors
iter=iter+1;
Xprevious=X;
for i1=1:10
sumvalue=0;
for j1=1:i1-1
sumvalue=sumvalue+a(i1,j1)*X(j1);
end
for j1=i1+1:n
sumvalue=sumvalue+a(i1,j1)*X(j1);
end
x(i1)=(b(i1)-sumvalue)/a(i1,i1);
end
errora=(X-Xprevious)./X*100;
X=lambda*X+(1-lambda)*Xprevious;
L2errora=sqrt(transpose(errora)*errora);
errorvector(iter)=L2errora;
continue
end
figure
semilogy(errorvector,"-ro",...
"LineWidth",2,...
"MarkedSize",10,...
"MarkedEdgeColor",
"b")
title("error")
xlabel("iteration")
ylabel("l2error")
* ı mention about this code , in course same code with teacher but he can see the plots but ı can not see any thing , there is no error also
x(i1)=(b(i1)-sumvalue)/a(i1,i1);
That is the only place in the code that you use lower-case x as a variable name.
semilogy(errorvector,"-ro",...
"LineWidth",2,...
"MarkedSize",10,...
"MarkedEdgeColor",
"b")
That needs a few changes:
semilogy(errorvector, "-ro",...
"LineWidth", 2,...
"MarkerSize", 10,...
"MarkerEdgeColor", "b")
ataberk kaplica
ataberk kaplica el 6 de Dic. de 2020
thank you man ,I really appreciated you're support.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Productos

Versión

R2020b

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by