How to print this graph?

7 Ansichten (letzte 30 Tage)
Juan Zegarra
Juan Zegarra am 30 Apr. 2019
Beantwortet: KSSV am 1 Mai 2019
So far I have this. Please help.
2(n-1)+1 %number of x
n=row
floor(col/2-(n-1)) %number of blanks
floor (row/2-(n-1))
Screen Shot 2019-04-30 at 3.23.33 PM.png
  2 Kommentare
Rik
Rik am 30 Apr. 2019
The code below should be helpful, but you'll have to explain what exactly you mean by printing. Do you want to have a plot? Print it to the command window? Send it to a real printer to print it on paper?
rows=3;cols=6;
pattern=1-mod(reshape(1:(rows*cols),rows,cols),2)
Juan Zegarra
Juan Zegarra am 1 Mai 2019
What I meant is to print the picture above same as this example that we did in class, but intead of that it should be a shape of diamond. Thank you, same goes for the other problem.
for n = 1 : 5
for m = 1 : n
fprintf('*') ;
end
fprintf('\n') ;
end
*
**
***
****
*****
>>

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

KSSV
KSSV am 1 Mai 2019

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by