Question

3. a) Write a Matlab program to define student grade program and student number with (10 Marks) statement logic b) Write a Ma

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

Find your both the programs below:
a)  

prompt='What is the grade from 0 to 100?';

x=input(prompt)

if x>60

if x>70

if x>80

if x>90

if x>0

end

  if x>=90

disp('A')

end

end

if x>=80 && x<90

  disp('B')

end

end

if x>=70 && x<80

disp('C')

end

end

if x>=60 && x<70

disp('D')

end

end

if x<60

disp('F')

end

b)

clear all

mypi = raspi

mypi.AvailableI2CBuses;

mypi.I2CBusSpeed;

scanI2CBus(mypi,'i2c-1');

BMP180 = i2cdev(mypi,'i2c-1','0x77');

AC1m=int16(readRegister(BMP180, hex2dec('AA'),'int8'));

AC1l=int16(readRegister(BMP180, hex2dec('AB'),'int8'));

AC1 = int32(typecast((bitshift(AC1m,8)+ AC1l),'int16'));

AC2m=int16(readRegister(BMP180, hex2dec('AC'),'int8'));

AC2l=int16(readRegister(BMP180, hex2dec('AD'),'int8'));

AC2 = int32(typecast((bitshift(AC2m,8)+ AC2l),'int16'));

AC3m=int16(readRegister(BMP180, hex2dec('AE'),'int8'));

AC3l=int16(readRegister(BMP180, hex2dec('AF'),'int8'));

AC3 = int32((bitshift(AC3m,8)+ AC3l));

AC4m=int16(readRegister(BMP180, hex2dec('B0'),'int8'));

AC4l=int16(readRegister(BMP180, hex2dec('B1'),'int8'));

AC4 = int32(typecast((bitshift(AC4m,8)+ AC4l),'uint16'));

% AC5=int16(readRegister(BMP180, hex2dec('B2'),'uint16'));

AC5m=int16(readRegister(BMP180, hex2dec('B2'),'int8'));

AC5l=int16(readRegister(BMP180, hex2dec('B3'),'int8'));

AC5 = int32(typecast((bitshift(AC5m,8)+ AC5l),'uint16'));

% AC6=int16(readRegister(BMP180, hex2dec('B4'),'uint16'));

AC6m=int16(readRegister(BMP180, hex2dec('B4'),'int8'));

AC6l=int16(readRegister(BMP180, hex2dec('B5'),'int8'));

AC6 = int32(typecast(bitshift(AC6m,8)+ AC6l,'uint16'));

% B1=int16(readRegister(BMP180, hex2dec('B6'),'int16'));

B1m=int16(readRegister(BMP180, hex2dec('B6'),'int8'));

B1l=int16(readRegister(BMP180, hex2dec('B7'),'int8'));

B1 = int32((bitshift(B1m,8)+ B1l));

% B2=int16(readRegister(BMP180, hex2dec('B8'),'int16'));

B2m=int16(readRegister(BMP180, hex2dec('B8'),'int8'));

B2l=int16(readRegister(BMP180, hex2dec('B9'),'int8'));

B2 = int32((bitshift(B2m,8)+ B2l));

% MB=int16(readRegister(BMP180, hex2dec('BA'),'int16'));

MBm=int16(readRegister(BMP180, hex2dec('Ba'),'int8'));

MBl=int16(readRegister(BMP180, hex2dec('BB'),'int8'));

MB = int32((bitshift(MBm,8)+ MBl));

% MC=int16(readRegister(BMP180, hex2dec('BC'),'int16'));

MCm=int16(readRegister(BMP180, hex2dec('BC'),'int8'));

MCl=int16(readRegister(BMP180, hex2dec('BD'),'int8'));

MC = int32((bitshift(MCm,8)+ MCl));

% MD=int16(readRegister(BMP180, hex2dec('BE'),'int16'));

MDm=int16(readRegister(BMP180, hex2dec('BE'),'int8'));

MDl=int16(readRegister(BMP180, hex2dec('BF'),'int8'));

MD = int32((bitshift(MDm,8)+ MDl));

if readRegister(BMP180, hex2dec('D0'),'int8') ~=hex2dec('55')

error('Sonething wrong with temperature sensor')

end

writeRegister(BMP180, hex2dec('F4'), hex2dec('2E'),'int8')

pause(4.5E-3)

pause(5*60)

MSBt=int16(readRegister(BMP180, hex2dec('F6'),'int8'));

LSBt=int16(readRegister(BMP180, hex2dec('F7'),'int8'));

UT=int32((bitshift(MSBt, 8)) + (LSBt));

% UT = int32(27898);

% AC1 = int16(408)

% AC2 = int16(-72)

% AC3 = int16(-14383)

% AC4 = int16(32741)

% AC5 = int16(32757)

% AC6 = int16(23153)

% B1 = int16(6190)

% B2 = int16(4)

% MB = int16(-32768)

% MC = int16(-8711)

% MD = int16(2868)

%

%

X1=int32((UT-int32(AC6))*int32(AC5)/(2^15));

X2=int32(int32(MC)*2^11/((X1+int32(MD))));

B5=double(X1+X2);

T=(B5+8)/(2^4)*0.1

Add a comment
Know the answer?
Add Answer to:
3. a) Write a Matlab program to define student grade program and student number with (10 Marks) statement logic b) Write a Matlab program for sensor selection of temperature, pressure, flow sensor...
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
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