MATLAB: How can i plot a 3D matrix? I am trying to plot a 3D scatter plot with a 3D matrix to display the relation between three variables.

3d plots

clear all; close all; clc
%Given
x1=3.2; %meters





x2=2.7; %meters
y1=4.0; %meters
y2=3.6; %meters
%varying
y=0:.1:6;%meters
for n=1:61
z=y(1,n);
m=1000; %kg
d=.010; %meters
%cord lengths in distance
AC=sqrt(x1^2+z^2);
AB=sqrt(y2^2+z^2+x2^2);
AD=sqrt(y1^2+z^2+x2^2);
%unit vector
unitac=[x1,0,z]/AC;
unitab=[-x2,-y2,z]/AB;
unitad=[-x2,y1,z]/AD;
A=[unitac;unitab;unitad]';
Area=pi*d^2/4;
syms ab ac ad
eqn1=A(3,1)*ac+A(3,2)*ab+A(3,3)*ad==m*9.81; %z direction
eqn2=A(2,1)*ac+A(2,2)*ab+A(2,3)*ad==0; %y direction
eqn3=A(1,1)*ac+A(1,2)*ab+A(1,3)*ad==0; %x direction
[E,F] =equationsToMatrix([eqn1,eqn2,eqn3],[ac,ab,ad]);
X=vpa(linsolve(E,F)); %solves systems of equations for force
% lowest height
% smallest dieameter
for d=1:11;
D=[10,11,12,14,16,18,20,22,25,28,30]; %%%%%%%%%%%what are the diamater ranges?
area=D(d)^2/4*pi;
Tension(:,d,n)=X/area; %pascals
SF(:,d,n)=330*10^6./X/area;
end
end
plot3(Tension(1,:),Tension(2,:),Tension(3,:))
hold on

Best Answer

A 3D matrix of values is equivalent to a set of 4 dimensional points, (x(J), y(K), z(L), Tension(J,K,L)) . There are no 4 dimensional plotting routines. You can encode a dimension as color, or you can use slice() or isosurface() to project down to 3 dimensions.
Related Question