how to save result in continue way in column

1 次查看(过去 30 天)
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
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
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