Programmatically define elements of a matrix
Show older comments
I have the following code:
cellnumber=6;
Vtype=4;
r=500;
H=500;
d=0.5*r;
nodes = [0 0 r 0 -r 0 sqrt(2)*r/2 -sqrt(2)*r/2 -sqrt(2)*r/2 sqrt(2)*r/2
0 0 0 r 0 -r sqrt(2)*r/2 sqrt(2)*r/2 -sqrt(2)*r/2 -sqrt(2)*r/2
H-d H 0 0 0 0 2*H-d 2*H-d 2*H-d 2*H-d];
totalnodes=size(nodes,2)+(cellnumber-1)*(size(nodes,2)-Vtype);
nodestotal=zeros(3,totalnodes);
for i=1:size(nodes,2)
nodestotal(:,i)=nodes(:,i);
for ii=size(nodes,2)+1:size(nodes,2)-Vtype:totalnodes
nodestotal(1,ii)=nodes(1,1);
nodestotal(2,ii)=nodes(2,1);
nodestotal(3,ii)=?????????;
for jj=size(nodes,2)+2:size(nodes,2)-Vtype:totalnodes
nodestotal(1,jj)=nodes(1,2);
nodestotal(2,jj)=nodes(2,2);
nodestotal(3,jj)=?????????;
end
end
end
I would like to assign specific values to specific elements of nodestotal (indicated as ?????????) in for loop. In particular such values are:
nodestotal(3,11)=3*H-2*d nodestotal(3,12)=3*H-*d
nodestotal(3,17)=5*H-3*d nodestotal(3,18)=5*H-2*d
nodestotal(3,23)=7*H-4*d nodestotal(3,24)=7*H-3*d
nodestotal(3,29)=9*H-5*d nodestotal(3,30)=9*H-4*d
nodestotal(3,35)=11*H-6*d nodestotal(3,36)=11*H-5*d
How can I do this?
Notice that cellnumber can vary.
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!