A sensor measures the concentration of oxygen in bloodstream (in g/L) during a medical procedure. The data are recorded ? times every Δ? seconds and stored in the one-dimensional array ?(1: ?). Write a MATLAB function, which takes Δ?, ? and ? as input and returns, as an output, an array showing the rate of change ??⁄?? of oxygen concentration with time at ?? = ?Δ?, ? = 1, … , ? − 1. Use numerical differentiation based on the forward difference. Write and run the script which verifies the function using Δ? = 0.1, ? = 100, and ?(?) = 0.01sin(??), ? = 1, … , ?. Plot the computed derivatives as a function of ?.
clear all;close all;
% disp('enter the value of del_t');
% input('enter the value of del_t =');
% disp('enter the value of n');
% input('enter the value of n = ');
% disp('enter the value of o_i');
% input('enter the value of o_i= ');
del_t=.1;
n=100;
i=1:n;
ti=i*del_t;
o_i=.01*sin(ti);
%plot(o_i);
do_i=.01*cos(ti);
plot(i,o_i,'b',i,do_i,'r');
xlabel('Sample number');
ylabel('do/dt');
title('response of the function');
Get Answers For Free
Most questions answered within 1 hours.