clc clear all % exercise 1 - chapter 24 % w=-7r^2+3r+25; disp('Exercise 1 - Chapter 24') for r=0:2:40 w=-7*r^2+3*r+25; if w<0 break end fprintf('The value of w is %g and r is %g\n',w,r) end disp(' ') % exercise 4 - chapter 24 disp('Exercise 2 - Chapter 24') R=120; for t=0:0.1:20 i=2*t^2-3*t; % current as a function of time: note the change in formula V=i*R; % voltage formula if V>=4 break end end fprintf('The voltage is %g V at a time of %g sec\n\n',V,t)