How can I link data from separate arrays?
Afficher commentaires plus anciens
Suppose you have an array [4 7 9 4 8 3] which represents a list of parameter values within a database. For example ‘4’ is the thickness of a plate which has an associated array containing location and temperature values (5x2 double) [0.55 0.16; 0.60 0.16; 0.65 0.15; 0.7 0.14; 0.75 0.12]. Each of the thickness values has an associated 5x2 array which is unique.
So the question I have is this: Is there a way I can link the location and temperature data arrays with the thickness values so that I can plot all the arrays which correspond to thickness value of ‘4’ without doing this manually?
5 commentaires
dpb
le 26 Fév 2021
Insufficient information -- we know nothing of where these other data are nor how they're defined.
The answer to the general question is "of course" but it does have the caveat that you have to have some piece of information somewhere to use to be able to create that link--whether it's a file-naming convention, the sequence of the associated data in a cell array, ...
Matthew Weltevreden
le 26 Fév 2021
Stephen23
le 26 Fév 2021
dpb
le 26 Fév 2021
Be more helpful to us to have information on how the corollary data are stored; generated; etc., ... to have some idea on how they are linked/associated.
Matthew Weltevreden
le 26 Fév 2021
Réponse acceptée
Plus de réponses (1)
Hernia Baby
le 26 Fév 2021
The code below is one I assumed from your infomation.
Therefore, it might be different from what you want to do.
As the other members said, you need to give us enough input data.
Thickness = [4 7 9 4 8 3];
% create datas by the number of thickness datas
name = ("parts"+char('A'+(0:length(Thickness)-1'))');
LocTemp(:,:,1) = [0.55 0.16; 0.60 0.16; 0.65 0.15; 0.7 0.14; 0.75 0.12];
for i = 1:length(Thickness)-1
LocTemp(:,:,i+1) = LocTemp(:,:,i) + 0.01;
end
% seperate data into location and temperature
Location = squeeze(LocTemp(:,1,:))';
Temperature = squeeze(LocTemp(:,2,:))';
% integration as cell type
for i = 1:length(Thickness)
C(i,:) = {name(i),Thickness(i),Location(i,:),Temperature(i,:)};
end
% legends
leg = {'name' 'thickness' 'location' 'temperature'};
% convert type
S = cell2struct(C, leg, 2);
% output example
S(1)
>> S(1)
name: "partsA"
thickness: 4
location: [0.5500 0.6000 0.6500 0.7000 0.7500]
temperature: [0.1600 0.1600 0.1500 0.1400 0.1200]
1 commentaire
Matthew Weltevreden
le 26 Fév 2021
Catégories
En savoir plus sur Data Type Identification dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!