Question: Question 2 ( 4 0 points ) Write a MATLAB function that takes the integer n as an argument and prints out a complex diamond
Question points
Write a MATLAB function that takes the integer n as an argument and prints out a complex diamond shape
with n rows, where each row alternates between numbers and stars. For example, if n is the output
should look like this:
Hint: Use nested loops to print spaces, numbers, and stars.
here is the code I used to answer the question, however some errors appear when I run the funcion. Fix the following code in the function so that it will run proporly:
function printComplexDiamondn
for i :n
fprintfrepmat n i;
for j :i
fprintfd j;
if j i
fprintf;
end
end
fprintf;
end
for i n::
fprintfrepmat n i;
for j :i
fprintfd j;
if j i
fprintf;
end
end
fprintf;
end
end
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
