Clear Filters
Clear Filters

Matlab code is taking so much timing to run?

3 views (last 30 days)
Priyank Pathak
Priyank Pathak on 18 Oct 2021
Commented: Rik on 18 Oct 2021
%This is my code
E=xlsread('toplatlongecs','c1:c292681');
N=xlsread('geoidlatlongecs','c1:c292681');
zL=xlsread('labecsgrid.xlsx');
xL334=reshape(zL',292681,1);
% cd=mean(xc);
%link for the data is given below
% xL334=xL33';
L0=2400; %load in metres
r_c=2670; % density of crust in kg/m3
r_w=1030; % density of water in kg/m3
r_a=3200; % density of asthenosphere in kg/m3
r_m=3300; % density of lithosphere mantle in kg/m3
Zmax=300000; %compensation level, zmax in metres
g=9.8; % gravity in m/s2
r_ac=r_a-r_c; % density contrast b/w asthenosphere and crust
r_cw=r_c-r_w; % density contrast b/w crust and water
r_wc=r_w-r_c; % density contrast b/w water and crust
r_ma=r_m-r_a; % density contrast b/w mantle lithosphere and asthenosphere
r_mc=r_m-r_c; % density contrast b/w mantle lithosphere and crust
rmc=(r_mc.^2);
r_cm=r_c-r_m;
rma=(r_ma.^2);
ur_ac=1/(r_ac);
ur_mc=1/(r_mc);
rcw=(r_cw.^2);
% ZL= 120000; %in metres
% ZC= 27000; % in metres
% Zmax2=Zmax^2;
% E2=E.^2;
% ZC2=ZC.^2;
% ZL2=ZL.^2;
% C2=3.14*6.67*10^(-11);
% N0=-(C2*(E2*r_w+ (ZC2-E2)*r_c+(ZL2-ZC2)*r_m+ (Zmax2-ZL2)*r_a))./ 9.8 -N ;
% N22=-(N0+N)*9.8/C2;
%r_cw=r_c;
%zC=(r_a*L0+E*(r_cw+zL*r_ma)*ur_mc;
%A=(r_c*rma/rmc)+r_m-(r_m*rma/rmc)-r_a;
% A=r_ma+(rma*r_cm)/(rmc);
% A2=2*A;
% D3=Zmax2*r_a;
% D4=(r_a*r_a*L0*L0*r_cm)/rmc;
% A07=r_a.*L0;
% A08=E.*r_c;
% A09= xL334.*r_ma;
% for i=1:1:292681
% %
% % zC2(i)=(A07+ E(i).*r_c + xL334(i).*r_ma)./(r_mc);
% % end
% zC2(i)=(A07+ A08(i) + A09(i))./(r_mc);
% end
% zC3=reshape(zC2,541,541);
% zC=zC3';
E02=reshape(E,541,541);
E03=E02';
zC2=zeros(541,541);
for o=1:541
for p=1:541
if E03(o,p)>0
zC2(o,p)=(r_a*L0+E03(o,p)*r_c+zL(o,p)*r_ma)/(r_mc);
else
zC2(o,p)=(r_a*L0+E03(o,p)*r_cw+zL(o,p)*r_ma)/(r_mc);
end
end
end
zC=zC2;
im= imagesc([117 135], [-38 -20] ,zC);
colorbar
hold on
colorbar;
%brighten('h',);
%C=contour(A,'LineColor','black');
x=117:0.033333333:135;
y=-38:0.033333333:-20;
minx = round(min(zC(:)),1);
maxx = round(max(zC(:)),1);
levels = minx:5:maxx;
levels2=round(levels);
[X,Y] = meshgrid(x,y);
%[C,h]=contour(X,Y,csia21,'linewidth',0.2,'LineColor',[0,0,0]+0.5);
[C,h]=contour(X,Y,zC,levels2,'linewidth',0.2,'LineColor',[0,0,0]+0.5);
%C=contour(A,'ShowText','on','LineColor','black');
clabel(C,h,'FontSize',6);
xlabel('longitude(deg.)')
ylabel('latitude(deg.)')
colorbar
  2 Comments
Priyank Pathak
Priyank Pathak on 18 Oct 2021
please help!
or if possible make new code , i am using R2016a .
thank you
Priyank
Rik
Rik on 18 Oct 2021
Did you run the profiler to see where your code is spending most time?
Also, please upload your data as a zip file instead.

Sign in to comment.

Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!