Question
Can somebody please change this code so that it works in R programming language? lat=nc_varget('/Users/Ajanardhanan/Documents/MATLAB/Complete_TMAX_LatLong1.nc','latitude'); lon=nc_varget('/Users/Ajanardhanan/Documents/MATLAB/Complete_TMAX_LatLong1.nc','longitude'); t=nc_varget('/Users/Ajanardhanan/Documents/MATLAB/Complete_TMAX_LatLong1.nc','temperature'); time=nc_varget('/Users/Ajanardhanan/Documents/MATLAB/Complete_TMAX_LatLong1.nc','time'); n=length(t); x=[90.5 92.5 93.5 90.5 91.5 92.5
Can somebody please change this code so that it works in R programming language?
lat=nc_varget('/Users/Ajanardhanan/Documents/MATLAB/Complete_TMAX_LatLong1.nc','latitude'); lon=nc_varget('/Users/Ajanardhanan/Documents/MATLAB/Complete_TMAX_LatLong1.nc','longitude'); t=nc_varget('/Users/Ajanardhanan/Documents/MATLAB/Complete_TMAX_LatLong1.nc','temperature'); time=nc_varget('/Users/Ajanardhanan/Documents/MATLAB/Complete_TMAX_LatLong1.nc','time'); n=length(t); x=[90.5 92.5 93.5 90.5 91.5 92.5 94.5 95.5 96.5]; y=[26.5 26.5 26.5 26.5 25.5 25.5 24.5 27.5 27.5]; for i=1:length(x) a(i)=find(lon==x(i)); b(i)=find(lat==y(i)); r(:,i)=t(:,b(i),a(i)); end for i=1:length(r) u(i) = 0; for j=1:length(x) u(i) = u(i) + r(i,j); end u(i)=u(i)/length(x); end u=u'; plot(time,u) title('Temperature Time Series for Assam') xlabel('Year') ylabel('Temperature Annomaly') %Abilash Janardhanan %Organzing the Data to create a time series %The data was imported using the import function on MATLAB x=length(Year); time=zeros(12*x,1); rain=zeros(12*x,1); for i=1:x, y=(i-1)*12; for j=1:12, time(y+j,1)=Year(i) + (j-1)/12; end rain(y+1,1)=Jan(i); rain(y+2,1)=Feb(i); rain(y+3,1)=Mar(i); rain(y+4,1)=Apr(i); rain(y+5,1)=May(i); rain(y+6,1)=Jun(i); rain(y+7,1)=Jul(i); rain(y+8,1)=Aug(i); rain(y+9,1)=Sept(i); rain(y+10,1)=Oct(i); rain(y+11,1)=Nov(i); rain(y+12,1)=Dec(i); end rain=(rain/10); z=1871:1/12:2014.9167; figure(2) plot(z,rain) xlabel('Year') ylabel('Precipitation in mm') title('Time Series of Precipitation for Assam and Meghalaya') axis([1871 2014 0 800]) set(gca,'XTick',[1874:20:2014],'XLim',[1871 2014]) set(gca,'XMinorTick','on','YMinorTick','on')
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started