Fitting a straight line to a set of 3-D points
10 views (last 30 days)
Show older comments
Hi there,
please can someone help me fit a straight line to my data? It's in 3-D I have done it in 2-D before but have no idea about 3-D
This is my code:
Many many thanks
lat_3d= [30.3894980000000;30.3824250000000;30.3886690000000;30.3878380000000;30.3953250000000;30.3874200000000;30.3807640000000;30.3924160000000;30.3874200000000;30.3811820000000;30.3919950000000;30.3928260000000;30.3903320000000;30.3836720000000;30.3774440000000];%new_3d_model_results(:,2);
lon_3d= [40.7508620000000;40.7486390000000;40.7489620000000;40.7476950000000;40.7515010000000;40.7486440000000;40.7461050000000;40.7486490000000;40.7486440000000;40.7451550000000;40.7514980000000;40.7521320000000;40.7502300000000;40.7495900000000;40.7410360000000];%new_3d_model_results(:,1);
depth_3d=[10.0097660000000;8.04296900000000;8.97460900000000;7.98085900000000;9.51289100000000;8.04296900000000;10.1132810000000;10.0304690000000;7.96015600000000;7.98085900000000;9.47148400000000;7.77382800000000;8.76757800000000;9.34726600000000;7.79453100000000]; %new_3d_model_results(:,3);
%% plot 3d
scale = 111; % km/deg
figure
%plot
% h=[30.3 30.45 40.7 40.8];
% lat_lon_proportions(h) % refernced at top of script
% plot events
hold on
p10=plot3(lat_3d,lon_3d,depth_3d/scale,'o','MarkerFaceColor',light_p,'MarkerEdgeColor', 'k','MarkerSize',12); %QPS changed/ Initial Velocity Model
hold on
grid on
%axis equal
ax = gca;
ax.ZDir = 'reverse';
zVal = str2double(ax.ZTickLabel)*scale;
ax.ZTickLabel = num2str(zVal);
xlabel('Longitude (deg, E)');
ylabel('Latitude (deg, N)')
zlabel('Depth (km)')
zval = [2:2:20]';
ax.ZTick = zval/scale;
ax.ZTickLabel = num2str(zval);
hold on
set(gca,'FontName','Helvetica','FontSize',20);
hold on
xlim([30.3 30.45])
ylim([40.7 40.8])
hold on
axis([30.3 30.45 40.7 40.8]);
view(-37.5, 4)
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!