Borrar filtros
Borrar filtros

MATLAB Function Output problem?

2 visualizaciones (últimos 30 días)
Steve
Steve el 31 de Dic. de 2011
Hello Experts,
I have the following function:
function X = STK(U, D, n, delta_t)
X = zeros(1,n); % Creating the vector of X
X(1) = 1; % = X(0) = 1;
r = randn(1,n); %
N = zeros(1);
for i=1:n
X(i+1) = X(i) - U*X(i)*delta_t + D*sqrt(delta_t)*r(i);
N(i) = i;
end
plot(N,X(1:n));
end
The function outputs the whole vector, I need it to output only the plot without any other ans = ... Please teach me how to do it, I mean to "enable/disable" output printing.
Happy New Year, Thanks a lot in advance!!!

Respuesta aceptada

Chandra Kurniawan
Chandra Kurniawan el 31 de Dic. de 2011
function STK(U, D, n, delta_t)
X = zeros(1,n); % Creating the vector of X
X(1) = 1; % = X(0) = 1;
r = randn(1,n); %
N = zeros(1);
for i=1:n
X(i+1) = X(i) - U*X(i)*delta_t + D*sqrt(delta_t)*r(i);
N(i) = i;
end
plot(N,X(1:n));
end
  1 comentario
Steve
Steve el 31 de Dic. de 2011
Thanks Chandra!!! Happy New Year, it may be funny but I have done something like a min before you answered and it really works.
It's like to write void in C/C++.
Thanks a lot, Happy New Year!!!!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by