ENGIN 136

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

a. 5^4 b. 5+3/(5*6) c. sqrt(4+6^2) // (4+6^2)^1/2 d. 9*6/12+7*56(2.8+1.3) e. 1+5*3/(6^2+2^(10-4.2)*1/5.5)

Create MATLAB code to perform the following calculation

function [ ] = message( ) disp('Welcome to DVC') end

Define a function to print a welcome message

a. a = -0.3333, a = 0.3333, a = 0.6667 b. a = -0.333333333333333, a = 0.333333333333333, a = 0.666666666666667 c. a = -3.3333e-001, a = 3.3333e-001, a = 6.6667e-001 d. a = -1/3, a = 1/3, a = 2/3

Define matrix equal to [-1/3, 1/3/ 2/3]. Print the value of a using the following formate. a. format short b. format long c. format short e c. format rational

a. %^^^^^^12^^^^^^^5 b. %^^^^^^12^^^^^^^5 c. %^^^^^^12 %^^^^^^^5

Given x = 12 and y 5, what will be printed by the following statements a. fprintf('%8.0f', x,y) b. fprintf('%8.0f%8.0f', x,y) c. fprintf('%8.0f\n%8.0f', x,y)

disp(['The answer is = ', num2str(x)])

Given x = 4.258, use disp function to display the string "The answer is= " and the value of x on one line.

In scripts: Res = test(n); disp(Res) or disp(test(n)) or display(Res) or display(test(n)) In function: output = y ./ 2;

Identify any error in the following script and functions test

fred book_1 second_place No_1 Vel_1 tan

Identify which name in each of the following pairs is a legitimate MATLAB variable name: fred \ fred! -book_1 \ book-1 -2ndplace \ second_place -#1 \ No_1 -Vel_1 \ Vel.5 -tan \ while

b = 1:10 log10 ./ log(b)

MATLAB contains function to calculate the natural logarithm (log), the logarithm to base 10 (log10), and the logarithm to base 2 (log2). However finding a logarithm to another base - for example base b - you will have to do the math yourself using the following formula: logb(x) = loge(x)/loge(x), What is the logb of 10 when b is defined from 1 to 10 in increment of 1?

clc, clear format short e theta = 0:0.1:2*pi; disp('Angle (Radian) Sine-value Cosine-value Tangent-value); disp([theta', sin(theta'), cos(theta'), tan(tan(theta')])

Sometime it is convenient to have a table of sine, cosine, and tangent values instead of using a calculator. Create a table of all three of these trigonometric functions for angles from 0 to 2pi, with a spacing of 0.1 radians. Your table should contain a column for the angle and then for the sine, cosines and tangent

Temp = 1000; Press = 100:300:1000; R = 0.2870; v = R.*Temp./Press

The ideal gas law, Pv = RT, describes the behavior of many gases. When solved for v (the specific volume in m^3/kg), the equation can be written as v = RT/P. Find the specific volume of air at 1000 K and pressures ranging from 100kPa to 1000kPa in increment of 300 kPa. Gas constant (R) for air is 0.2870kJ(kg K)

Note a ^ represent one blank space!

What would be displayed in the command window when the following script runs?

clc, clear t = 0:30; P = 1000 * exp(0.08 . * t) format bank subplot(2,2,1) plot(t,P) title('Continuous Interest') ylabel('dollars') subplot(2,2,2) semilogx(t,P) title('Continuous Interest') subplot(2,2,3) semilogy(t,P) title('Continuous Interest') xlabel('Time, years') ylabel('dollars') subplot(2,2,4) loglog(t,P) title('Continuous Interest') xlabel('time, year')

When interest is compound continuously, the following equation represents the growth of your savings: P = P0e^rt In this equation P = current balance, P0 = initial balance, r = growing constant, expressed as a decimal fraction and t = time invested in years. a. Determine the amount in your account at the end of each year and if you invest $1000 at 8% (0.08) for 30 years; make a table. b. Create a figure with 4 subplot. Plot time on the x axis and current balance P on y-axis. - In the first quadrant, plot P versus t in a rectangular coordinate system. - In the second quadrant, plot P versus t, scaling the x-axis logarithmically. - In the third quadrant, plot P versus t, calling the y-axis logarithmically. - In the fourth quadrant, plot P versus t, calling both axes logarithmically.

clc, clear format compact y = @(x) exp (-0.5 .* x. ^ 2 ./ sqrt (2 .* pi) x = 0:100 Y = y(x) fplot(y, [0,100]) xlabel(' x ') ylabel(' y ')

Write a script to define an anonymous function representing the following function y = e^(-0.5x^2)/sqrt(2*pi) Use this anonymous to evaluate y for x between 0 and 100 with an increment of 1. Then plot the anonymous function versus x in the same range using the plot( ) function

Name = input('Enter your name as LAST, FIRST: ' , 's')

Write one statement with input function to prompt the user to enter his/her name and last name in the following format last, first. Indicate how you would type your last and first names in response to the prompt.

a. a = 1:20 b. b = 0:pi/10:2*pi c. c = Linspace(4:20:15)

write MATLAB code to create: a. An evenly spaced vector of values from 1 to 20 in increment of 1 b. A vector of values from zero to 2pi in increment pi/10 c. A vector containing 15 values and evenly spaced between 4 and 20.


Ensembles d'études connexes

5th grade SS - Industrial Revolution Leads to Massive Immigration

View Set

Introduction to Computer Networks and Data Communications

View Set

ANS 100 Midterm 2 REVIEW, ANS 100 Study Guide for Midterm #2 final!

View Set

Maternal Newborn Practice B with NGN

View Set