Primi esercizi in Matlab compreso algoritmo di risoluzione per sistemi lineari
This commit is contained in:
28
float2bin.m
Normal file
28
float2bin.m
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
function b = float2bin(f)
|
||||||
|
%This function converts a floating point number to its binary form.
|
||||||
|
|
||||||
|
%Input error handling
|
||||||
|
if ~isfloat(f)
|
||||||
|
disp('Input must be a floating point number.');
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
|
%Hex characters
|
||||||
|
hex = '0123456789abcdef';
|
||||||
|
|
||||||
|
%Convert from float to hex
|
||||||
|
h = num2hex(f);
|
||||||
|
|
||||||
|
%Convert to cell array of chars
|
||||||
|
hc = num2cell(h);
|
||||||
|
|
||||||
|
%Convert to array of numbers
|
||||||
|
nums = cellfun(@(x) find(hex == x) - 1, hc);
|
||||||
|
|
||||||
|
%Convert to array of binary numbers
|
||||||
|
bins = dec2bin(nums, 4);
|
||||||
|
|
||||||
|
%Reshape into horizontal vector
|
||||||
|
b = reshape(bins.', 1, numel(bins));
|
||||||
|
end
|
||||||
5
jesocristo_calculate_eps.m
Normal file
5
jesocristo_calculate_eps.m
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
errore = 1;
|
||||||
|
while 1+errore ~= 1
|
||||||
|
errore = errore /2;
|
||||||
|
end
|
||||||
|
errore = errore *2
|
||||||
6
jesocristo_minimo.m
Normal file
6
jesocristo_minimo.m
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
u = 1;
|
||||||
|
while u~= 0
|
||||||
|
rmin = u;
|
||||||
|
u=u/2;
|
||||||
|
end
|
||||||
|
rmin
|
||||||
5
jesocristo_while.m
Normal file
5
jesocristo_while.m
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
a = 0;
|
||||||
|
while a~= 5
|
||||||
|
a= a + 0.625
|
||||||
|
end
|
||||||
|
|
||||||
17
liner_system_resolver.m
Normal file
17
liner_system_resolver.m
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
U=[2,2,4;0,-7,-11;0,0,2];
|
||||||
|
b=[5;-8;-2];
|
||||||
|
|
||||||
|
x=[];
|
||||||
|
n= length(b);
|
||||||
|
x(n) = b(n)/U(n,n);
|
||||||
|
|
||||||
|
for i=n-1:-1:1
|
||||||
|
somma = 0;
|
||||||
|
for k=i+1:n
|
||||||
|
somma=somma+U(i,k) * x(k);
|
||||||
|
end
|
||||||
|
|
||||||
|
x(i) = (b(i) - somma)/ U(i,i);
|
||||||
|
end
|
||||||
|
disp ('La soluzione <EFBFBD> ')
|
||||||
|
x
|
||||||
10
matricesuperiore.m~
Normal file
10
matricesuperiore.m~
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
U=[1,2,3:4,5,6;7,8,9];
|
||||||
|
B=[5;6;7];
|
||||||
|
|
||||||
|
x=[];
|
||||||
|
n= lenght(B);
|
||||||
|
x(n) = b(n)/U(n,n);
|
||||||
|
|
||||||
|
for i=n-1:-1:1
|
||||||
|
somma = 0;
|
||||||
|
for k
|
||||||
Reference in New Issue
Block a user