Error using plot Vectors must be the same length?

Area=645; Length=3000; K=36.86; CosK=0.80; p=[0 170 200 220 240 250 260 275 300 310 350 370 380 400]; F=p/(2*CosK); stress=F*1000/Area; E=221.4; belowyieldstress=[164.71 193.77 213.15 232.53 242.22 251.91 247.06]; postyieldstress=[266.4 290.66 300.35 339.10 358.48 368.17 387.55]; %% if(stress<=yieldstress) strain=((belowyieldstress)/E); disp(strain); delu=strain*Length; u=delu/CosK else pstrain=((postyieldstress-232.4)/16900) delu=pstrain*Length; u=delu/CosK; end plot(u,p)

1 件のコメント

madhan ravi
madhan ravi 2018 年 11 月 2 日
編集済み: madhan ravi 2018 年 11 月 2 日
yieldstress?

サインインしてコメントする。

 採用された回答

madhan ravi
madhan ravi 2018 年 11 月 2 日
編集済み: madhan ravi 2018 年 11 月 2 日

0 投票

Note at the end :
size(u) and size(p) have to have the same dimensions in order to plot them.
So try:
plot(u,p(1:numel(u)))

3 件のコメント

Ramya Anandhan
Ramya Anandhan 2018 年 11 月 2 日
thank you so much madhan,i got the plot
madhan ravi
madhan ravi 2018 年 11 月 2 日
編集済み: madhan ravi 2018 年 11 月 2 日
Anytime:), if you got the answer to your question make sure to accept the answer so that people know the question is solved
Ramya Anandhan
Ramya Anandhan 2018 年 11 月 28 日
Hey Madhan, Hope you're doing good. I'm not getting the solution for below code. Please try to help me out.
% E; modulus of elasticity
% A: area of cross section
% L: length of bar
E = 30e6;A=2;EA=E*A; L = 60;
% generation of coordinates and connectivities
% numberElements: number of elements
numberElements=3;
% generation equal spaced coordinates
nodeCoordinates=linspace(0,L,numberElements+1);
xx=nodeCoordinates;
% numberNodes: number of nodes
numberNodes=size(nodeCoordinates,2);
% elementNodes: connections at elements
ii=1:numberElements;
elementNodes(:,1)=ii;
elementNodes(:,2)=ii+1;
% for structure:
% displacements: displacement vector
% force : force vector
% stiffness: stiffness matrix
displacements=zeros(numberNodes,1);
force=zeros(numberNodes,1);
stiffness=zeros(numberNodes,numberNodes);
% applied load at node 2, node 3, node 4
force(2)=-150;
force(3)=-300;
force(4)=-600;
% computation of the system stiffness matrix
for e=1:numberElements;
% elementDof: element degrees of freedom (Dof)
elementDof=elementNodes(e,:) ;
nn=length(elementDof);
length_element=nodeCoordinates(elementDof(2))...
-nodeCoordinates(elementDof(1));
detJacobian=length_element/2;invJacobian=1/detJacobian;
% central Gauss point (xi=0, weight W=2)
[shape,naturalDerivatives]=shapeFunctionL2(0.0);
[shape,naturalDerivatives]=shapeFunctionL3(0.0);
[shape,naturalDerivatives]=shapeFunctionL4(0.0);
Xderivatives=naturalDerivatives*invJacobian;
% B matrix
B=zeros(1,nn); B(1:nn) = Xderivatives(:);
stiffness(elementDof,elementDof)=...
stiffness(elementDof,elementDof)+B*B*2*detJacobian*EA;
end
% boundary conditions and solution
% prescribed dofs
fixedDof=find(xx==min(nodeCoordinates(:)) ...
| xx==max(nodeCoordinates(:)));
prescribedDof=[fixedDof]
% free Dof : activeDof
activeDof=setdiff([1:numberNodes],[prescribedDof]);
% solution
GDof=numberNodes;
displacements=solution(GDof,prescribedDof,stiffness,force);
% output displacements/reactions
outputDisplacementsReactions(displacements,stiffness,...
numberNodes,prescribedDof)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by