Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

answer each question with the code array b) (3 Points) Show an example of how yo

ID: 3846377 • Letter: A

Question


answer each question with the code

array b) (3 Points) Show an example of how you would display a triangle in MATLAB. The triangle structure variable is name tri and contains three points. Draw the triangle in red with a line size of 5. Sistem. c) (3 Points) Convert the following code into a while loop: count 0; for index 100 -2 0 index ount count end Count oi d) (2 Points) Use the variables name (example value: Mike), balance (example value 211.351), and account number (example value: 149701), to display output with this format: "Susan has $100,99 in their account #149723.' Make sure to put a new line at the end of the output. Do not hard code any values use the variables. Notice the balance amount displayed has exactly 2 decimals. e) (2 Points) Create a new variable and give it the value which results from applying DeMorgan's Law to: (use appropriate MATLAB syntax) continue times up true AND x 10 OR y 100) To continue

Explanation / Answer

The answers are in accordance with MATLAB coding:
a) check = isempty(array)
check will have 1 (true) if the array is an empty and 0 (false) if it isn't.

b) Let's say we have the following structure:
tri = {[20, 30];
[10, 20];
[30, 40]};
use triplot() to just simple plot the triangle and use '-r' to color it red.

c) It is not the difficult to convert the following into while loop, the loop starts with index=100 put the outside and ends when index==0, make that the condition and now just perform the operations and add the decrement to index and you are done.
count=0;
index=100;
while(index>0)
count=count+index;
index=index-2;
end

d) Let's us say we have the following data:
name="Mike";
balance=211.351;
account_number=149701;
Now, string can printed with %s, balance with exactly two precision can be printed with %0.2f add the dollar. Also, add %d for the account number. is used for creating new line.

fprintf("%s has $%0.2f in their account #%d. ",name,balance,account_number);

e) Here is the equation, directly put it.
variable= not(continue = times_up) != false || (not(x<=10) & not(y>100)