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

matlab Q1) a) create a vector that starts at a, ends at b, and has a spacing of

ID: 1766288 • Letter: M

Question

matlab

Q1)

a) create a vector that starts at a, ends at b, and has a spacing of c (allow the user to input all of these parameters)

b)create an inches vector using a,b and c

c) calculate the corresponding values of feet in another vector (1feet=12 inches)

d) group the inch vector and the feet vector together into a table matrix

e)use the disp command to create a title for a table that converts inches to feet

f)use the disp command to create column headings for your table

g)use fprintf command to send your table to the command window

Explanation / Answer

Ans)===============Matlab code============

a = input('Enter a :' ); %prompts user to enter 'a' value
b = input('Enter b :' ); %prompts user to enter 'b' value
c = input('Enter c :' ); %prompts user to enter 'c' value

%=====part-a=======
vec=a:c:b %vector starts at 'a' ends at 'b' with spacing 'c'

%========part-b========
inches=a:c:b %inches vector

%=======part-c======
feets=inches/12 %feets vector

%=======part-d=======
%creating table
tableM(:,1)=inches';
tableM(:,2)=feets';

%===========part-e============
disp('Table showing inches to feets')

%===============part-f========

disp(' inches feets')

%==============part-g========

fprintf(1,' %f %f ',tableM')

%===================================================

%===result in command window when you run the above code===

>> solution

Enter a :1

Enter b :10

Enter c :1

vec =

1 2 3 4 5 6 7 8 9 10

inches =

1 2 3 4 5 6 7 8 9 10

feets =

Columns 1 through 7

0.0833 0.1667 0.2500 0.3333 0.4167 0.5000 0.5833

Columns 8 through 10

0.6667 0.7500 0.8333

Table showing inches to feets

inches feets

1.000000 0.083333

2.000000 0.166667

3.000000 0.250000

4.000000 0.333333

5.000000 0.416667

6.000000 0.500000

7.000000 0.583333

8.000000 0.666667

9.000000 0.750000

10.000000 0.833333

>>

================================