how to save result in continue way in column

조회 수: 1 (최근 30일)
Chaudhary P Patel
Chaudhary P Patel 2020년 2월 4일
댓글: Mathias 2020년 2월 4일
every time my out put put result is ( N by 1) and i want save the result for every time into column.
  댓글 수: 2
KSSV
KSSV 2020년 2월 4일
Show us the whole code.....and tell more clearly what you want.
Chaudhary P Patel
Chaudhary P Patel 2020년 2월 4일
편집: Chaudhary P Patel 2020년 2월 4일
for j=1:1:14
for i=1:ne
Ecc=eval(['Ee',num2str(i)]);
acc=[0.3*acce(j,2);acce(j,2);0;Ecc.*(acce(j,2))';0.3*acce(j,2);acce(j,2);0;Ecc.*(acce(j,2))'];
mas = eval(['m',num2str(i)]); %% calling global elemental mass matrix
eval(['force',num2str(i),'=mas*acc']);
end
FG=[]; %%%%%-------ASSEMBLE FORCE VECTOR--------
FG=zeros(N,1);
m=5;
for n=1:1:ne %Calling elements
for i=1:1:8
d2=dof(n,m+i-1);%Calling degree of freedom for second node
force=eval(['force',num2str(n)]);%Calling elemental force vector
FG(d2,1)= FG(d2,1)+force(i,1);%calling element of the elemental force vector and adding to global force vector
end
end
end
here i want to save every time the FG(N by 1) in the name of FGf in a continuous column same table

댓글을 달려면 로그인하십시오.

답변 (1개)

Mathias
Mathias 2020년 2월 4일
You can add lines:
to arrays with index (end+1) --- multiple: (end+1 : end+length())
to tables with function height() +1
also cat(1, ...) or vertcat() should work on both and can be used for multiple lines or vectors
  댓글 수: 2
Chaudhary P Patel
Chaudhary P Patel 2020년 2월 4일
Sir, tell me little bit clearly how and where can use these lines.
Mathias
Mathias 2020년 2월 4일
Its hard to understand your intention completely but maybe you can find a solution in this code.
You can operational add the force values to a zero vector with '+' or
add/concatenate the force vector to the zero vector
% dof function
function y = dof(a,b)
y = a+b;
function to_solve
% example variables
ne = 3;
Ee1 = 2;
Ee2 = 3;
Ee3 = 5;
m1 = 2;
m2 = 3;
m3 = 5;
acce = rand(4,2);
N = 3;
% code
for j = 1:1:4
for i = 1:ne
Ecc = eval(['Ee',num2str(i)]);
acc = [0.3*acce(j,2); acce(j,2); 0; Ecc.*(acce(j,2))'; 0.3*acce(j,2); acce(j,2); 0; Ecc.*(acce(j,2))'];
mas = eval(['m',num2str(i)]); %% calling global elemental mass matrix
eval(['force',num2str(i),'=mas*acc']);
end
FG = []; %%%%%-------ASSEMBLE FORCE VECTOR--------
% FG = zeros(N,1);
m = 5;
for n = 1:1:ne %Calling elements
for i = 1:1:8
d2 = dof(n,m+i-1); % Calling degree of freedom for second node
force = eval(['force', num2str(n)]); % Calling elemental force vector
%% == original ==
% FG(d2,1) = FG(d2,1) + force(i,1); % calling element of the elemental force vector and adding to global force vector
%% == add values at position d2 and trailing ==
if d2 > length(FG)
FG(end+1:d2,1) = 0;
end
FG(d2,1) = FG(d2,1) + force(i,1);
%% == add vector ==
% FG = vertcat(FG, force(i,1)); % calling element of the elemental force vector and adding to global force vector
end
end
end

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by