You are on page 1of 3

Guevarra, Sherwin Angelo E. 5 ECE A COAPLAB ACTIVITY 9 1.

) Present a simulation using Octave and Matlab to calculate the power, voltage, current and resistance in an electronic circuit given any of the following. function answer=solveVP(n) R=input('Input the Resistance:'); I=input('Input the Current:'); V=I*R; P=(I^2)*R; printf('The Computed Voltage is: %.2f V\n',V); printf('The Computed Power is: %.2f W\n',P); endfunction function answer=solveRP(n) V=input('Input the Voltage:'); I=input('Input the Current:'); R=V/I; P=I*V; printf('The Computed Resistance is: %.2f Ohms\n',R); printf('The Computed Power is: %.2f W\n',P); endfunction function answer=solveIP(n) V=input('Input the Voltage:'); R=input('Input the Resistance:'); I=V/R; P=(V^2)/R; printf('The Computed Current is: %.2f I\n',I); printf('The Computed Power is: %.2f W\n',P); endfunction I=P/V; R=V/I; printf('The Computed Current is: %.2f A\n',I); printf('The Computed Resistance is: %.2f Ohms\n',R); endfunction function answer=solveVR(n) P=input('Input the Power:'); I=input('Input the Current:'); V=P/I; R=V/I; printf('The Computed Voltage is: %.2f V\n',V); printf('The Computed Resistance is: %.2f Ohms\n',R); endfunction function answer=solveVI(n) P=input('Input the Power:'); R=input('Input the Resistance:'); V=sqrt(P*R); I=V/R; printf('The Computed Voltage is: %.2f V\n',V); printf('The Computed Current is: %.2f A\n',I); endfunction function answer=Solve(n) printf("Choose:\n1=Solve for VP\n2=Solve for RP\n3=Solve for IP\n4=Solve for IR\n5=Solve for VI\n6=Solve for VR\n"); t=input(""); if(t==1);

function answer=solveIR(n) P=input('Input the Power:'); V=input('Input the Voltage:');

solveVP; elseif(t==2) solveRP; elseif(t==3) solveIP; elseif(t==4) solveIR; elseif(t==5)

solveVI; elseif(t==6) solveVR; else printf("ERROR\n") end Formula; endfunction

For this activity we used a syntax function and Input script to store a value in a variable to solve for the Power, Resistance, Current and Voltage depending on the given. 2.) Present a simulation using Octave and Matlab to calculate for the Volume, Radius and Height of a parabola. function answer=Radius(n) H=input('Input the Height:'); V=input('Input the Volume:'); R=sqrt((V*2)/(pi*H)); printf('The Computed Radius is: %.2f meter\n',R); endfunction function answer=Height(n) R=input('Input the Radius:'); V=input('Input the Volume:'); H=(V*2)/(pi*R^2); printf('The Computed Height is: %.2f meter\n',H); endfunction function answer=Volume(n) R=input('Input the Radius:'); H=input('Input the Height:'); V=(pi*(R^2)*H)/2; printf('The Computed Volume is: %.2f cubic meter\n',V); endfunction function answer=SOLVE(n) printf("Choose:\n1=Solve for the Volume\n2=Solve for the Height\n3=Solve for the Radius\n"); t=input(""); if(t==1); Volume; elseif(t==2) Height; elseif(t==3) Radius; else printf("ERROR\n") end SOLVE; endfunction

Like the first activity we used a syntax function and Input script to store a value in a variable to solve for the Volume, Radius and Height of a parabola depending on the given.

3.) Present a simulation using Octave and Matlab to calculate for the max height, velocity, angle of orientation given the gravitational acceleration of a projectile motion.

function answer=MaxHeight(n) Vo=input('Input the Velocity:'); Theta=input('Input the Theta:'); H=((Vo^2)*((sin(Theta))^2))/(2*9.81); printf('The Maximum Height Computed is: %.2f meters\n', H); endfunction function answer=Velocity(n) H=input('Input the Height:'); Theta=input('Input the Theta:'); V=sqrt((H*2*9.81)/((sin(Theta))^2)); printf('The Computed Velocity is: %.2f meters/sec.\n', V); endfunction function answer=Theta(n) H=input('Input the Height:'); Vo=input('Input the Velocity:'); Theta=asin(sqrt((H*2*9.81)/(Vo^2)));

printf('The Computed Theta is: %.2f rad\n', Theta); endfunction function answer=SOLVE(n) printf("Choose:\n1=Solve for MaxHeight\n2=Solve for Velocity\n3=Solve for Theta\n"); t=input(""); if(t==1); MaxHeight; elseif(t==2) Velocity; elseif(t==3) Theta; else printf("ERROR\n") end SOLVE; endfunction

Like the first and second activity we used a syntax function and Input script to store a value in a variable to solve for the Maximum Height, Velocity and Angle of Orientation depending on the given , when the Gravitational acceleration was 9.81. Note: The Value of the Theta that was inputted is RAD.

You might also like