0% found this document useful (0 votes)
73 views

Matlab Test PDF

This document contains code for iterative calculations, differentiation, integration, and partial derivatives. The iterative calculations code defines an initial value of 1 and calculates successive values of 1/n up to 20 iterations or until the difference between successive values is less than 0.1. It outputs the final value of x and the number of iterations required to converge. The differentiation and integration section contains code to take the derivative and second derivative of an expression, and to calculate integrals of expressions with respect to variables between limits.

Uploaded by

machineman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

Matlab Test PDF

This document contains code for iterative calculations, differentiation, integration, and partial derivatives. The iterative calculations code defines an initial value of 1 and calculates successive values of 1/n up to 20 iterations or until the difference between successive values is less than 0.1. It outputs the final value of x and the number of iterations required to converge. The differentiation and integration section contains code to take the derivative and second derivative of an expression, and to calculate integrals of expressions with respect to variables between limits.

Uploaded by

machineman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

1 % Iterative Calculations

2 x(1) = 1; % Define the first element


3 for n = 2:20; % Maximum No of Iterations
4 x(n) = 1/n; % Calculation
5 if abs(x(n) - x(n-1)) < 0.1
6 break
7 end
8 converge = n;
9 end
10 x
11 converge
12
13 % Differentiation & Integration
14 % -----------------------------
15 x1 = sym('t^2-sin(t)');
16 dx1dt = diff(x1)
17 dx12dt2 = diff(x1,2)
18 % Partial Derivatives
19 syms a
20 g = 't^2+a*sin(s^2)';
21 diff(g,'t')
22 diff(g,'s')
23
24 % Integrals
25 syms a t
26 int(a+2*t,t,0,1)
27

You might also like