how to display the outputs

Dear All,
I have problem to display my outputs from this function when I call it from another file drawbox(5)
function [Matrix] = drawbox(n)
R=zeros(5,3);
for i=1:n
R(i,1)=a;
R(i,2)=b;
R(i,3)=c;
R(i,4)=f;
end
R;
sortedR= sortrows(R,4);
Matrix= sortedR(:,1:3);
end
I don't know what is the problem.

3 Commenti

Star Strider
Star Strider il 15 Ott 2014
Two observations:
  1. We have no idea what ‘a’, ‘b’, ‘c’, and ‘f’ are or how you define them;
  2. You could replace your separate ‘R’ lines with: R(i,:) = [a b c f];
dear,
I did what you recommend but it is the same, I got the same result for both
R; and R(i,:) = [a b c f];
complete matrix but still the matrix
Matrix= sortedR(:,1:3); is like above, could you please recommend another advise.
thank you very much
Star Strider
Star Strider il 19 Ott 2014
It would give the same result, just more efficiently.
  1. We still have no idea what ‘a’, ‘b’, ‘c’, and ‘f’ are, or how you define them;

Accedi per commentare.

Risposte (1)

the cyclist
the cyclist il 19 Ott 2014
Modificato: the cyclist il 19 Ott 2014

1 voto

You could use the disp or sprintf command to have more control over what you see.

1 Commento

Image Analyst
Image Analyst il 19 Ott 2014
And fprintf() if you want to go to a file or the command window.

Accedi per commentare.

Categorie

Scopri di più su Argument Definitions in Centro assistenza e File Exchange

Richiesto:

il 15 Ott 2014

Modificato:

il 17 Feb 2015

Community Treasure Hunt

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

Start Hunting!

Translated by