function does not store variable at workspace

Hello everyone,
I write a function and it works properly, it gives results at command window. However it does not store anayting at workspace. My funcion as follows:
function qwerty
a1=[];
x1=[];
x2=[];
x3={};
x4=[];
x5=[];
x6=[];
func1;
func2;
func3;
func4;
function func1
a1 = readtable('asd.xlx');
x1=a1;
end
function func2
statement
x2=statement;
end
function func3
statementp;
x3=statement;
end
function func4
statement;
x4=statement;
x5=statement;
x6=statement;
end
end

4 comentarios

Chunru
Chunru el 27 de Dic. de 2021
The variables you defined in the functions are local variable to the function. The local variables no longer exist once the called function exit.
Cem Eren Aslan
Cem Eren Aslan el 27 de Dic. de 2021
how can i fix it? I try "global x1 x2 x3..." but does not work. Is there any way to convert global?
Chunru
Chunru el 27 de Dic. de 2021
Try not use global. If you do want to keep them in workspace, use script. Or you post your complete program so that we can help you.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

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

Etiquetas

Preguntada:

el 27 de Dic. de 2021

Comentada:

el 27 de Dic. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by