Azzera filtri
Azzera filtri

MATLAB Function Output problem?

2 visualizzazioni (ultimi 30 giorni)
Steve
Steve il 31 Dic 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!!!

Risposta accettata

Chandra Kurniawan
Chandra Kurniawan il 31 Dic 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 Commento
Steve
Steve il 31 Dic 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!!!!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by