Borrar filtros
Borrar filtros

How to scatter plot

6 visualizaciones (últimos 30 días)
Arif
Arif el 10 de Abr. de 2024
Comentada: Voss el 12 de Abr. de 2024
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

Respuesta aceptada

Voss
Voss el 10 de Abr. de 2024
Editada: Voss el 10 de Abr. de 2024
"It is because my X is a 1x16 double and my Z is a 1x32 double."
That's true. That is the problem.
"When i do [X1,X2], it just reads X1 because X1 and X2 has same value in each variable."
No. The problem has nothing to do with X1 and X2 being the same.
The problem is your X are half as long as your Z. That is because Nb=1 and Ns=2.
  3 comentarios
Arif
Arif el 12 de Abr. de 2024
Thanks buddy
Voss
Voss el 12 de Abr. de 2024
You're welcome!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by