Disp returns all iterations, only interested in using the last iteration/result in further scripting
Show older comments
Im pretty newbie to this so it might be a very simple thing, now I don't really understand how to solve this or where the issue arises.
I have a problem that when i use disp I get to see all the iterations. Now my question is will that cause problems when I call that function within some other code when Im only interested and after handling the last result/iteration (see the last result/vector in the output below)? If yes how do I adjust the function so that i just returns that and not every iteration happening behind the scenes?
I have this code inside its own file:
function [ s ] = centering( q )
s = zeros(10, 1);
for i = 1:10
s(i,:) = s(i,:) + (q(i,:)-mean(q))
end
end
When I call the function from within another file i use the follwoing:
xc = centering(x);
disp ( xc );
Which returns a very long output, which shows the entire iteration from start to finish. Now I only want the end result to be returned for use in other code and for display. I just included the last 3 iterations/vectors from the console output which starts with a zero-vector. Now Im only interested in the last result/vector in the output, how do I get that?:
s =
33
33
11
11
4
2
-2
-5
0
0
s =
33
33
11
11
4
2
-2
-5
-12
0
s =
33
33
11
11
4
2
-2
-5
-12
-75
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!