How to scatter plot
显示 更早的评论
hi guys, im trying to plot my X,Z coordinate to a scatter plot. My problem is shown in figure below:

It is becuase my X is a 1x16 double and my Z is a 1x32 double. When i do [X1,X2], it just reads X1 because X1 and X2 has same value in each variable.
Here are my code :
clear;
clc;
H = 5;
L = 15;
Ns = 2;
Nb = 1;
PortalHeight = H;
Bayspan = L;
NumberStory = Ns;
NumberBay = Nb;
%Variable1
h = [0.8,1.00,1.20,1.40,1.6,1.80];
%Variable2
Lss = [2.00,2.40,2.80,3.20,3.60,4.00]
%Variable3
Nss = [2,3,4];
Var1HeightTrussBeam = h;
Var2LengthSpecialSegment = Lss;
Var3NumberSpecialSegment = Nss;
%% XZ Column
for i = 1:NumberBay+1
Xcolumn(i)=L*(i-1);
Xbotbeam(i)=L*(i-1);
end
for j = 1:NumberStory+1
Zcolumn(j) = H*(j-1);
Zbotbeam(j)=(H*(j-1)-h(1));
end
Zbotbeam = Zbotbeam(1,[Ns,Ns+1]);
%calculate segment length of ordinary segment
Los = (L-Lss(1))/2;
Nos = Los/h(1);
Nos = round(Nos);
los = Los/Nos;
checkspan = logical(los*Nos*2+Lss(1)==15)
assert(logical(los*Nos*2+Lss(1)==15),"span must be 15m");
%% 1st Story
%XZ first top and bottom ordinary segment(os)
XTopOrdinarySegment = repmat(0,1,(NumberBay)*Nos);
ZTopOrdinarySegment = repmat(0,1,(NumberStory)*Nos);
XBottomOrdinarySegment = XTopOrdinarySegment;
ii = 0;
jj = 0;
for i = 1:NumberBay
for k = 1:Nos
ii = ii+1;
XTopOrdinarySegment(ii) = los*k*i;
XBottomOrdinarySegment(ii) = los*k*i;
end
end
for j = 1:NumberStory
for k = 1:Nos
jj = jj+1;
ZTopOrdinarySegment(jj) = H*(j);
ZBottomOrdinarySegment(jj) = (H*(j)-h(1));
end
end
X = [XTopOrdinarySegment,XBottomOrdinarySegment]
Z = [ZTopOrdinarySegment,ZBottomOrdinarySegment]
scatter(X,Z,'filled'),grid on
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Scatter Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
