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)

 Réponse acceptée

madhan ravi
madhan ravi le 2 Nov 2018
Modifié(e) : madhan ravi le 2 Nov 2018
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 commentaires

thank you so much madhan,i got the plot
madhan ravi
madhan ravi le 2 Nov 2018
Modifié(e) : madhan ravi le 2 Nov 2018
Anytime:), if you got the answer to your question make sure to accept the answer so that people know the question is solved
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)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by