Matlab question Evaluate Fx cosx sinx on x 02 x 01 Then us
Matlab question:
Evaluate F(x) = cos(x) sin(x) on x [0,2], x = 0.1. Then, use the resulting vector to estimate the following derivatives:
- First derivative using O (x^2) accurate scheme for center and boundary. - Second derivative using O(x^2) accurate scheme for center and boundary.
Can not use Diff function
Solution
function [x] = load_data
load_data = input(\'Which data file would you like to analyze? \', \'s\');
while exist(load_data) ~= 2
load_data = input(\'Please input a valid file name. \', \'s\');
end
[x] = load(load_data);
end
And the code for the analysis of the data is:
function [mean_value,std_dev] = analysis(data)
mean_value = mean(data);
std_dev = std(data);
disp([\'The mean of the data is \', num2str(mean_value)]);
disp([\'The standard deviation of the data is \', num2str(std_dev)]);
end
if( floor(x) == x )
f = inf;
else
f = x^7 + cos(x)^4 / sin(pi*x);
end
xp = x / pi;
if( floor(xp) == xp )
f = inf;
else
f=x^7+cos(x)^4/sin(x)
end
![Matlab question: Evaluate F(x) = cos(x) sin(x) on x [0,2], x = 0.1. Then, use the resulting vector to estimate the following derivatives: - First derivative usi Matlab question: Evaluate F(x) = cos(x) sin(x) on x [0,2], x = 0.1. Then, use the resulting vector to estimate the following derivatives: - First derivative usi](/WebImages/33/matlab-question-evaluate-fx-cosx-sinx-on-x-02-x-01-then-us-1098033-1761579510-0.webp)