How do i select a variable for global use from an array?

1 Ansicht (letzte 30 Tage)
David Fraser
David Fraser am 26 Feb. 2011
Hi all, i was wondering how i would take a value which is inside an array and assign a variable to it, for example
i have
D=struct('Coord',Coord','Con',Con','Re',Re','Load',Load','E',E','A',A');
in which all of the inputs are relatively large vectors I want to creat a global variable call A (area) by going into this array and selecting the A from it
I have tried A = D[A] but that does not work in MATLAB
Any ideas? thanks

Antworten (2)

James Tursa
James Tursa am 26 Feb. 2011
A = D.A;
But why not just use D.A?
  3 Kommentare
Jiro Doke
Jiro Doke am 26 Feb. 2011
I strongly suggest going through the "Getting Started" guide in the documentation. It will save you in the long run.
Jan
Jan am 27 Feb. 2011
@David: You can mark this answer as matching your question exctly by choosing it as "accepted".

Melden Sie sich an, um zu kommentieren.


David Fraser
David Fraser am 26 Feb. 2011
To put it in better context this is the script in which D (data) is found
function D=D2
%This script uses data of Case 3
% Definition of Data
% Nodal Coordinates Coord = [0 0 0; 0 1.2 0; 3 1 0; 3 2.2 0; 5 1 0; 5 2.2 0; 8 0 0; 8 1.2 0; 1.5 0.5 0; 4.5 1 0; 6.5 0.5 0];
% Connectivity Con = [1 2; 1 9; 1 3; 2 4; 3 4; 3 10; 3 5; 4 6; 5 6; 5 11; 5 7; 6 8; 7 8; 2 9; 9 4; 4 10; 10 6; 6 11; 11 8];
% Definition of Degree of freedom (free=0 & fixed=1); for 2-D trusses the last column is equal to 1 Re=[1 1 1;0 0 1;0 0 1; 0 0 1; 0 0 1; 0 0 1; 0 1 1; 0 0 1; 0 0 1; 0 0 1; 0 0 1];
% Definition of Nodal loads Load=[0 0 0;0 0 0; 0 0 0; 0 0 0; 0 0 0; 0 0 0; 0 0 0; 0 0 0; 0 0 0; 0 0 0; 0 0 0];
% Definition of Modulus of Elasticity E=[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]*(2*10e11);
% Definition of Area A=[0.007854 0.007854 0.007854 0.007854 0.007854 0.007854 0.007854 0.007854 0.007854 0.007854 0.007854 0.007854 0.007854 0.007854 0.007854 0.007854 0.007854 0.007854 0.007854];
% Convert to structure array D=struct('Coord',Coord','Con',Con','Re',Re','Load',Load','E',E','A',A');

Kategorien

Mehr zu Variables finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by