labro11 -...

Info icon This preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Doug Rivas ME 218 Lab 11 M 5-7 11.1 Code: #include <stdio.h> #include <math.h> #define R .1000 #define C 1.0000 int main(void) { double h; double y; double dy; double t; t=0; y=4; h=.05; printf("time, t voltage, y\n");
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
while(t<1.05) { dy= -y/(R*C); printf("%lf %lf\n", t, y); y=y+ h*dy; t= t+.05; } } 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 0 0.2 0.4 0.6 0.8 1 1.2 Voltage vs. Time Voltage vs. Time Time 11.2 Code: #include <stdio.h> #include <math.h> #define R .1000 #define C 1.0000 int main(void) { double h; Voltage
Image of page 2
double y; double dy; double t; double k1; double k2; double k3; double k4; double slope; t=0; y=4; h=.05; printf("time, t voltage, y\n"); while(t<1.05) { k1= -y/(R*C); k2= y+(h/2)*k1; k3= y+(h/2)*k2; k4= y + h*k3; slope= (k1+2*k2 + 2*k3 +k4)/6; printf("%lf %lf\n", t, y); y=y+ h*slope; t= t+.05; } }
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Voltage vs Time 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 0 0.2 0.4 0.6 0.8 1 1.2 Series1 Time 11.3
Image of page 4
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Code: #include <stdio.h> #include <math.h> #define R .1000 #define C 1.0000 #define Pi 3.14159265 double t; double volt(double t); int main(void) { double h; double y; double dy; double t; double k1; double k2; double k3; double k4; double slope; Voltage t=0; y=4; h=.05; printf("time, t voltage, y\n"); while(t<1.05) { k1= -y/(R*C) + volt(t); k2= y+(h/2)*k1; k3= y+(h/2)*k2; k4= y + h*k3; slope= (k1+2*k2 + 2*k3 +k4)/6; printf("%lf %lf\n", t, y); y=y+ h*slope; t= t+.05; } } double volt(double t) { double v; v=10*exp(-t*20)*sin(t*2*Pi/.03); return v; } Output: Excel Plot: Voltage vs Time (with variable voltage across capacitor) 0.5 1 1.5 2 2.5 3 3.5 4 4.5 0.2 0.4 0.6 0.8 1 1.2 Series1 Time Voltage...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern