필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
David Fraser
David Fraser 2011년 2월 26일
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

답변 (2개)

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

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


David Fraser
David Fraser 2011년 2월 26일
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');

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by