How to remove the display of ans on a function

1 Ansicht (letzte 30 Tage)
smaug66
smaug66 am 23 Feb. 2018
Bearbeitet: Fangjun Jiang am 23 Feb. 2018
I did this function to draw a triangle for a homework. How do I remove "ans=" from the display window?
function [s] = TriangleA(n)
%fhdfh
x = [];
for i = 1 : n;
x = strcat(x,'*');
s = [blanks(n-i) x];
disp(s)
end
>> TriangleA(8)
*
**
***
****
*****
******
*******
******
ans =
'********'

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 23 Feb. 2018
Bearbeitet: Fangjun Jiang am 23 Feb. 2018
TriangleA(10);
Add the semicolon ; at the end
  1 Kommentar
smaug66
smaug66 am 23 Feb. 2018
My bad. I write functions but can't seem to use them. Thanks!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Entering Commands finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by