Question

Please answer 1c, use MATLAB, and paste your entire script in your answer so that I can copy and paste to see if it works.

Problem #1 400g triangle square pentagon hexagon Figure 1 For a closed geometric figure composed of straight lines (Figure 1)

Sample runs in the command window >> hw4xla Shape choices [t]riangle [s] quare [P]entagon [h]exagon Enter first letter of sha

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

clc%clears screen
clear all%clears history
close all%closes all files
format long
choice = menu('Choose a shape','Triangle','Square','Pentagon','Hexagon');
kc=['t','s','p','h'];
ch=kc(choice);
while(ch~='t'&ch~='s'&ch~='p'&ch~='h')
fprintf('Error: Invalid shape. Please try again.\n');
ch=lower(input('Enter first letter of shape: ','s'));
end
if(ch=='t')
s=(1)*180;
elseif(ch=='s')
s=2*180;
elseif(ch=='p')
s=3*180;
else
s=4*180;
end
fprintf('Sum of angles = %d degrees\n',s);

- O X Pradeep EDITOR PUBLISH VIEW do E C . Search Documentation Insert fx Comment % 92% Indent 1 - EDIT Run Section Advance B

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Please answer 1c, use MATLAB, and paste your entire script in your answer so that I...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please use Matlab to solve and show your full codes Write a script file Ask the...

    Please use Matlab to solve and show your full codes Write a script file Ask the user to enter sides of a triangle: a, b, c Check to see if the sides are all greater than 0 If they are: Use the function (triangle) that you created in your last homework problem (HW#5 problemttF) to calculate the area. command Display the results on the screen using fprintf write the results to disk using the fprintf command. If any of the...

  • Copy/Paste your script from 5b here. 4. Let's look at a more complicated script executable. a....

    Copy/Paste your script from 5b here. 4. Let's look at a more complicated script executable. a. Write the following as script6.sh and change its permissions to count for num in d do if num eq 100 then count (count+1) done echo The number 10 was found $count times What is the output? Run the script as ./script6.sh 10 20 30 10 40 20 50 10 60 <enter Summarize what the script does r using the read command. The following script...

  • The first script is validate.sh. This is a simple form validation script that will be used...

    The first script is validate.sh. This is a simple form validation script that will be used to verify the inputs given. Normally, this would be done to validate input from a website or another program before entry into a database or other record storage. In this case, we will keep it simple and only focus on the input validation step. In particular, the script should prompt the user for four values: first name, last name, zip code, and email address....

  • Need help please! Question 1: you must use if /else statement to receive credit for this...

    Need help please! Question 1: you must use if /else statement to receive credit for this question Write a MATLAB script to prompt the user to enter the value of t and use if /else statement to calculate f(t): 0. ift 0.5 f)2t2, if 0.5<t<1 4t. for all other t Test your code with different values of t. Question2: you must use switch/case to receive credit for this question Create a script to prompt the user to enter TWO numbers....

  • Menu-driven programs will display the menu options to the user and then prompt them for a...

    Menu-driven programs will display the menu options to the user and then prompt them for a menu choice. This program will display the following menu in the following format: Calculator Options: Calculate the area of a circle Calculate the area of a rectangle Calculate the area of a triangle Calculate the area of a trapezoid Calculate the area of a sphere Exit Enter your choice (1-6) Once the user enters a choice for the menu, the program should use a...

  • I need help solving these questions,please don’t know how to solve it by using matlab.!

    i need help solving these questions,please don’t know how to solve it by using matlab.! Solve the following questions Ol: You are required to develop a script to calculate the volume of a pyramid, which is 1/3 *base *height, where the base is length *width. Prompt the user to enter values for the length, width, and height, and then calculate the volume of the pyramid. When the user enters each value, he or she will then also be prompted to...

  • This is a matlab HW that I need the code for, if someone could help me figure this out it would b...

    This is a matlab HW that I need the code for, if someone could help me figure this out it would be appreciated. The value of t can be estimated from the following equation: in your script file, estimate the value of π for any number of terms. You must ask the user for the desired number of terms and calculate the absolute error/difference between your calculation and the built-in MATLAB value ofpi. Display your results with the following message...

  • Java Please - Design and implement a class Triangle. A constructor should accept the lengths of...

    Java Please - Design and implement a class Triangle. A constructor should accept the lengths of a triangle’s 3 sides (as integers) and verify that the sum of any 2 sides is greater than the 3rd(i.e., that the 3 sides satisfy the triangle inequality). The constructor should mark the triangle as valid or invalid; do not throw an exception. Provide get and set methods for the 3 sides, and recheck for validity in the set methods. Provide a toString method...

  • MATLAB ONLY!! PLEASE WRITE IN COMPUTER SO I CAN COPY PASTE!!! ANSWER COMPLETELY, USE FOR LOOPS....

    MATLAB ONLY!! PLEASE WRITE IN COMPUTER SO I CAN COPY PASTE!!! ANSWER COMPLETELY, USE FOR LOOPS. THE PROGRAM TO BE MODIFIED IS THE NEXT ONE: clc clear % Approximate the value of e ^ x using the Taylor Series x = input( 'Enter the value of x for e^x. x = ' ); t = input( 'Enter the amount of desired terms. t = ' ); i = 1; e_taylor = 0; % initializing the variable for the accumulator while...

  • In Matlab Create a single script (.m file) to solve these problems. Unless directed otherwise, use...

    In Matlab Create a single script (.m file) to solve these problems. Unless directed otherwise, use meaningful variable names for each variable; do not use the default variable ans to store your results. For this project, suppress your output with semi-colons (;). Each problem should be in a separate cell, using the cell mode feature of MATLAB. Problem 4 Video games are rather complicated to program, not least of which because of the graphics work that needs to be completed...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT