Challenge

Project 1 - Data Handling and Interpolation

%one
clear all;
close all;
clc;
import math.*
m= input('mass:');
k= input('spring constant:')
x = [0 15];
t=[0 15];
time = linspace(0,20,500);
result= ode45(ode_func,time);
figure(1);
plot(t,result(:,1),'color','r')
hold on;
figure(2);
plot(t,result(:,2),'color','b')
hold on;
result1= ode23(ode_func,time);
figure(3);
plot(t,result1(:,1),'color','m')
hold on;
figure(4);
plot(t,result1(:,2),'color','y')
hold off;
%ode_function
function [dx_dt] = ode_func(t,x,m,k)
dx_dt=1;
dx_dt= -k(x)/(dx_dt * m);
end;
%2
clear all;
close all;
clc;
data = xlsread('curvefitting.xlsx');
m = data(:,1);
k = data(:,2);
a = 0;
b = 0;
f = 100;
n = 2;
k1=zeros(length(k),1);
for i = 1:length(k)/f
a = b+1;
b = b + f;
m1 = m(a:b);
k2 = k(a:b);
[co] = polyfit(m1,k2,n);
k3 = polyval(co,m1);
k1(start:stop) = k1(a:b)+k3;
%merge
title(sprintf('%dnd Order with %f',n,r2));
fid= fopen('evaluated_data.txt','w');
fprintf(fid,'%f\n',k3);
close(fid);
end;
s= sum(k1-mean(k))^2;
e = sum(k-k1)^2;
t = s+e;
r2 = s/t;
figure(1);
plot(m,k,'r','linewidth',1.5);
hold on;
plot(m,k1,'b','linewidth',1.5);
xlabel('m');
ylabel('k');
legend('k','k1','location','northwest');
%3
clear all;
close all;
clc;
x = 2;
y = sin(x^2) + cos(x)- 2*sin(x)*cos(x);
plot(x,y);
[max,maxid] = findpeaks(y);
hold on;
plot(n(maxid),max,'r*');
gtext('max',findpeaks(y));
[minima,minid] = findpeaks(-y);
plot(n(minid),-Minima,'g*');
gtext('min',findpeaks(-y));
hold off;
%4
clear all;
close all;
clc;
x = linspace(-2*pi,2*pi);
y = linspace(0,4*pi);
[a,b] = meshgrid(x,y);
c = sin(Xa)+cos(b);
contour(a,b,c);
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.