我是MATLAB新手,我有一個運行另一個代碼的代碼拋出一個函數。 這裏是運行第二代碼的第一代碼:如何將變量保存到工作區或文件中?
function D=DataT3DSVFAE
%m number of elements
%n number of nodes
m=94;
n=38;
%coordinates of nodes [(X Y Z) for each node]
Coord=[-299.1 200 1875; 25.8 200 1875;
425.8 200 1875; 425.8 -200 1875;
25.8 -200 1875; -299.1 -200 1875;
-327.9 251.7 1450; 25.8 251.7 1450;
425.8 251.7 1450; 425.8 -251.7 1450;
25.8 -251.7 1450; -327.9 -251.7 1450;
-356.6 303.4 1025; 25.8 303.4 1025;
425.8 303.4 1025; 425.8 -303.4 1025;
25.8 -303.4 1025; -356.6 -303.4 1025;
-390.4 364.2 525; 25.8 364.2 525;
425.8 364.2 525; 425.8 0 525;
425.8 -364.2 525; 25.8 -364.2 525;
-390.4 -364.2 525; -390.4 0 525;
-425.8 423.9 25; 25.8 423.9 25;
425.8 423.9 25; 425.8 0 25;
425.8 -423.9 25; 25.8 -423.9 25;
-425.8 -423.9 25; -425.8 0 25;
-425.8 423.9 0; 425.8 423.9 0;
425.8 -423.9 0; -425.8 -423.9 0];
%conection of the nodes [first in coordinates is the first node and ...]
Con=[1 2; 2 3; 4 5; 5 6; 3 4; 1 6; 2 5; 1 12; 6 7; 3 10; 4 9; 1 8; 2 8; 3
8;6 11; 5 11; 4 11; 1 7; 3 9; 4 10; 6 12; 7 8; 8 9; 10 11; 11 12; 7 12;...
9 10; 8 11; 8 10; 7 18; 12 13; 9 16; 10 15; 8 13; 8 15; 10 17; 12 17; 7
13;9 15; 10 16; 12 18; 13 14; 14 15; 16 17; 17 18; 15 16; 13 18; 14 17; 14
16;13 26; 18 26; 15 22; 16 22; 13 20; 14 20; 15 20; 16 24; 17 24; 18 24; 13
19;15 21; 16 23; 18 25; 19 20; 20 21; 23 24; 24 25; 21 22; 22 23;...
19 26; 25 26; 22 24; 20 26; 20 24; 26 27; 26 33; 26 34; 22 30; 22 29;...
22 31; 20 29; 20 27; 20 28; 24 32; 24 31; 24 33; 19 27; 21 29; 23 31;...
25 33; 27 35; 29 36; 31 37; 33];
% Create storage for Q, V and R
allQ = cell(2,1);
allV = cell(2,1);
allR = cell(2,1);
% Load has only a Fx and all other forces and moments are zero
% uniform loads in local coordinate system
w=zeros(m,3);
% E: material elastic modules G:shear elastic modules J:torsional constant
E=ones(1,m)*1e4;nu=0.3;G=E/(2*(1+nu));
% A:cross sectional area and Iy Iz: moment of inertia
A=ones(1,m)*0.5;Iz=ones(1,m);Iy=ones(1,m);J=ones(1,m);
%St: settlement of supports & displacements of free nodes
St=zeros(n,6); be=zeros(1,m);
% All of the variables are transposed and stored in a structure array in
the
%name of D
D=struct('m',m,'n',n,'Coord',Coord','Con',Con','Re',Re',...
'Load',Load','w',w','E',E','G',G','A',A','Iz',Iz','Iy',...
Iy','J',J','St',St','be',be');
[allQ{t},allV{t},allR{t}]=MSA(D); % Save the results
此代碼由MSA(d)的名稱運行另一個代碼作爲函數。
問題是,我可以在我的工作區或文件或任何變量內的輸出。它們只出現在我的命令窗口中,我不能將它們用於我的進一步發展。 我需要一個文件或裏面worksapce這些變量:
allQ = cell2mat(allQ)
allV = cell2mat(allV)
allR = cell2mat(allR)
任何幫助讚賞:)
爲什麼不讓他們成爲'DataT3DSVFAE'的輸出? – excaza
通過用分號';'結束行來抑制屏幕上的打印。另外,如果你希望它們在文件中,請閱讀「save」函數。 –
謝謝excaza,但你的意思是? – SamiHa