You are on page 1of 3

% My first program

tf=1:100;
tc=(tf-32)*(5/9);
figure(11)
plot(tf,tc)
clc
clear all

x=0:360;
y=sind(x);
figure(123)
subplot(2,2,1)
plot(x,y,'y')

2nd prog

x=(1:0.25:180);
y=sind(x);

figure(1)
plot(x,y)

3rdprog

tf=1:100; %input

% fid=fopen('output1.txt','w');

for i=1:50
tc(i)=((tf(i)-32)*(5/9));
% fprintf(fid,'%12.4f%12.4f\n',tf(i),tc(i));
end

4th prog
%sample program%
clear
clc
load ('input_temp.txt'); %loading file
hr=input_temp(:,1);
temp=input_temp(:,2);

fid=fopen('Ainput_temp.txt','w');
fid1=fopen('Binput_temp.txt','w');
fid2=fopen('Cinput_temp.txt','w');
for i=1:length(hr)
if(temp(i)>=30)
fprintf(fid,'%12.0f%12.4f\n',hr(i),temp(i));
elseif ((temp(i)>=20&&temp(i)<30))
fprintf(fid1,'%12.0f%12.4f\n',hr(i),temp(i));
else
fprintf(fid2,'%12.0f%12.4f\n',hr(i),temp(i));
end
end

5th prog
clear
clc
G=load('input_temp.txt'); %loading file
hr=G(:,1);
temp=G(:,2);

fid=fopen('DG.txt','w');

for i=1:3:length(hr)

hrm=nanmean(hr(i:i+2));
tempm=nanmean(temp(i:i+2));

fprintf(fid,'%12.0f%12.4f\n',tempm);
end

6th prog
load temp.txt
hr=temp(:,1);
temp=temp(:,2);

fid=fopen('etemp.txt','w');

for i=1:length(hr)
if(rem(hr(i),2)==0)
fprintf(fid,'%12.0f%12.2f\n',hr(i),temp(i));
end
end

7th prog.
clear
clc
G=load('WG.txt');
long=G(:,1);
lat=G(:,2);
Z=G(:,3);
minlong=min(long);
maxlong=max(long);
minlat=min(lat);
maxlat=max(lat);
[x,y]=meshgrid(minlong:0.25:maxlong,minlat:0.25:maxlat);
[xi,yi,zi]=griddata(long,lat,Z,x,y);

figure(1)
contourf(xi,yi,zi)

You might also like