MATLAB Code1
-
Upload
alex-richey -
Category
Documents
-
view
214 -
download
1
description
Transcript of MATLAB Code1
![Page 1: MATLAB Code1](https://reader035.fdocuments.net/reader035/viewer/2022080221/563db812550346aa9a904fe6/html5/thumbnails/1.jpg)
MATLAB Code:
Output:
%File name: Lab1.m%% Purpose: To perform some trivial calculations and quit MATLAB% files%%Date Programer Description%++++++++++ +++++++++++ ++++++++++++++%01/28/2015 Alex Richey Lab 1 problems%%% Problem 1% Purpose:To convert Fahrenheit to Celsiusftemp = input('Enter the temperature in F' ); % Get the temperature in Fctemp = (ftemp-32)*5/9; % Convert the temperature from F to Cfprintf('The converted temperature in Celcius is %f. \n',ctemp)
Enter the temperature in F 80
The converted temperature in Celcius is 26.666667.
![Page 2: MATLAB Code1](https://reader035.fdocuments.net/reader035/viewer/2022080221/563db812550346aa9a904fe6/html5/thumbnails/2.jpg)
Matlab Code:
Output:
%File name: Lab1.m%% Purpose: To perform some trivial calculations and quit MATLAB% files%%Date Programer Description%++++++++++ +++++++++++ ++++++++++++++%01/28/2015 Alex Richey Lab 1 problems%
%% Problem 2% Purpose: To Generate random numbersrandom_real = rand*(50-20)+20 %Generate a random real number between 20 and 50random_integer = randi([50,100], 1) %Generate a random intager between 50 and 100
random_real = 23.8096
random_integer = 96
![Page 3: MATLAB Code1](https://reader035.fdocuments.net/reader035/viewer/2022080221/563db812550346aa9a904fe6/html5/thumbnails/3.jpg)
Matlab Code:
Output:
%File name: Lab1.m%% Purpose: To perform some trivial calculations and quit MATLAB% files%%Date Programer Description%++++++++++ +++++++++++ ++++++++++++++%01/28/2015 Alex Richey Lab 1 problems%%% Problem 3% Purpose: To compute weight tolerance weight = input('Enter the desired weight: '); %To find the weighttolerance = input ('Enter the desired tolerance: '); % To find the toleranceweight_min = weight - (.01*tolerance*weight) %To find the minimum weightweight_max = weight + (.01*tolerance*weight) %To find the maximum weight
Enter the desired weight: 100
Enter the desired tolerance: 15
weight_min = 85
weight_max = 115