Filter löschen
Filter löschen

MATLAB Function Output problem?

2 Ansichten (letzte 30 Tage)
Steve
Steve am 31 Dez. 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!!!

Akzeptierte Antwort

Chandra Kurniawan
Chandra Kurniawan am 31 Dez. 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 Kommentar
Steve
Steve am 31 Dez. 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!!!!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by