Question

In: Computer Science

Use MATLAB to create a program that answers the given problems: One of your friends has...

Use MATLAB to create a program that answers the given problems:

  1. One of your friends has an awful writing style: he almost never starts a message with a capital letter, but adds uppercase letters in random places throughout the message. It makes chatting with him very difficult for you, so you decided to write a plugin that will change each message received from your friend into a more readable form.

Implement a function that will change the very first symbol of the given message to uppercase, and make all the other letters lowercase.

2. Implement a function that will compute the area of a triangle.

Solutions

Expert Solution

%1st

function readableMessage = parseMessage(unreadableMessage)
%%readableMessage = function(unreadableMessage)
%input: unreadableMessage=> 1xM character vector
%output: readableMessage => 1xM character vector
readableMessage = [upper(unreadableMessage(1)),lower(unreadableMessage(2:end))];
end

%to run the function, type the command shown below, on the left side, in the command window

%2

function area = triangle_Area(a,b,c)
%area = triangleArea(a,b,c)
%this function calculates the area of a triangle by 2 methods
%1
%When base and height are known
%In this case, argument a is the base, b is the height.
%c should not be provided
%2
%when length of all 3 sides are known
%In this case,a,b,c are the 3 side lengths
if nargin==2
area=.5*a*b;
elseif nargin==3
s=(a+b+c)/2;
area=sqrt(a*(s-a)*(s-b)*(s-c));
else
error('Invalid number of arguments')
end
end


Related Solutions

Create a Matlab program that can evaluate Green Theorem
Create a Matlab program that can evaluate Green Theorem
I want to create an image compression program with matlab use PCA. I have the code...
I want to create an image compression program with matlab use PCA. I have the code listed below. But this code is fail, the image is colorless, but still gray. Can you help me to fix my code. clc clear all picture = im2double(imread('picture1.jpg')); Red = picture(:,:,1); premean = mean(Red(:)); premax = max(Red(:)); premin = min(Red(:)); x = size(Red,1); y = size(Red,2); Z = ones(x,y)*premean; A = (Red - Z)*(1/premax - premin); B = cov(A); [veceig,eig,C] = pcacov(B); NewRed =...
Matlab program Create a function, when given a two-digit integer as input, prints the equivalent English...
Matlab program Create a function, when given a two-digit integer as input, prints the equivalent English phrase. For example, given 39, output thirty-nine. Limit the input numbers to be in the range 21 to 39.
Eve is a college student and one of your friends, she suffering from some emotional problems....
Eve is a college student and one of your friends, she suffering from some emotional problems. Please answer each of the following scenarios by using key concepts of psychological science to give her advice. 1- Eve likes to vent all of the time about everything that makes her angry. What advice would you give her to control her anger and why based on psychological science? 2- Eve is always comparing herself to students who have better grades and more money...
Given ? = ???+??? + ??? and ? = ???-3?? + ????. Use MATLAB to find...
Given ? = ???+??? + ??? and ? = ???-3?? + ????. Use MATLAB to find the following: a) ? + ? b) ?  ? c) ? × ? d) A unit vector in the direction of ? − 2? e) ??? f) The component of ? along ? 2. Use MATLAB to convert points ?(11,4,15), ?(10,−14,33) and ?(−33,−14,15) from Cartesian to Cylindrical and Spherical coordinates.
** USING MATLAB TO PROGRAM The main objective of this lab is to create a game...
** USING MATLAB TO PROGRAM The main objective of this lab is to create a game that involves betting on the sum of two dice. The player will start out with some initial total amount of money. During each round, the player can bet some money that the sum of the two dice will be equal to a certain number. If the player wins the bet, that player adds the amount of the bet to his or her current total....
MATLAB: Create your own problem in words that use loop and selection statements in the same...
MATLAB: Create your own problem in words that use loop and selection statements in the same problem. Create a problem that has a somewhat practical, real-life application like entering your PIN code at an ATM, and then after 4 incorrect tries, you are locked out of the ATM. Or create a problem based perhaps upon a physics or chemistry lab.   The problem should require the use of a WHILE loop, a FOR loop and a minimum of 3 selection statements...
This is a Matlab Question Create MATLAB PROGRAM that can solve First Order Linear Differential Equation...
This is a Matlab Question Create MATLAB PROGRAM that can solve First Order Linear Differential Equation ( 1 example contains condition and the other does not have condition). 1. ty′ + 2y = t^2 − t + 1, y(1)=12 The correct answer is y(t) = 1/4 t^2 − 1/3 t + 1/2 + 1/12t^2 2. (x-1) dy/dx + 2y = (x+1)^2 The correct answer is y = (x(x+1) / x-1 ) + C(x+1) / x-1 The correct answer is
Working with MATLAB arrays. You can check your answers on MATLAB but do not include a...
Working with MATLAB arrays. You can check your answers on MATLAB but do not include a script file or MATLAB output for this problem . Just write the commands you would use each part. You may not 'hard code' which means you cannot just write in the answers. Show the MATLAB commands You have the following array: Data1[ 3.6 8.9 2.5 4.6 12.0 3.3 7.8 1.5] A) Write the command(s) you would use to order the values in the array...
USE MATLAB Write a program in Matlab that would continuously ask the user for an input...
USE MATLAB Write a program in Matlab that would continuously ask the user for an input between 1 and 6, which would represent the result of rolling a die. The program would then generate a random integer between 1 and 6 and compare its value to the value entered by user. If the user’s die is larger, it should display, “Mahahanap mo na ang forever mo. Sana all!” If the user’s die is smaller, it should display, “Gising na friend,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT