You are on page 1of 2

q = load('copper.

dat');
yi = q(:,2);
ti = q(:,1);
A = [1./ti,ti,ti.^2,ti.^3];
c = A\(1./yi);
t = linspace(0,50,501);
k = 1./(c(1) * 1./t + c(2) * t + c(3) * t.^2 + c(4) * t.^3);
figure
plot(t,k,'r-',ti,yi,'b.')

p = polyfit(xi,log(yi),1); y = exp(polyval(p,x)); % y=exp(a*x+log(b))


a = p(1); b = exp(p(2));
% so that y = b*exp(a*x)
x0 = 100;
a = -10
x(1) = (2/3)*x0 + a/(3*x0^2);
tol = 10^-5;
n=1;
while abs(x(n)^3-a)>tol,
x(n+1) = (2/3)*x(n) + a/(3*(x(n)^2))
n=n+1;
end

x = linspace(1,15,50);
th = linspace(0,2*pi,31);
[X,Th] = meshgrid(x,th);
F = 1./X;
Y = F.*cos(Th);
Z = F.*sin(Th);
surf(X,Y,Z);
view(-25,15);
colormap hsv;
function y = factorial(x);
n = 1:x;
for i=2:x;
n(i) = n(i)*n(i-1);
end
y = n(x);
function y = factorial(x);
n = 1:x;
a = cumprod(n);
y = a(x);

fp = fopen(grades1.dat)
fgetl(fp)
A = fscanf(fp,%*s %f %f %f %f %*s,*4,inf+) (4 columns)
C = textscan(fp,%s %f %f %f %f %s);
A = cell2mat(C(2:5))

[ave,is] = sort(A(:,4),'descend');
As = A(is,:);
S='%-12s %3.0f %3.0f %3.0f %5.2f %-2s\n';
for i=1:length(G),
fprintf(fp, S, Ns{i}, As(i,:), Gs{i});
end
C = [Ns,num2cell(As),Gs]'; % convert to cells
% fprintf(fp, S, C{:});

You might also like