How can I link data from separate arrays?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Matthew Weltevreden
am 26 Feb. 2021
Kommentiert: dpb
am 27 Feb. 2021
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 Kommentare
dpb
am 26 Feb. 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.
Akzeptierte Antwort
dpb
am 26 Feb. 2021
Bearbeitet: dpb
am 26 Feb. 2021
Making harder than needs must be --
Thickness=[19.0;22.0;32.0];
Temp_data=cat(3l [0,-0.05;0.2,-0.13;0.4,0.25;0.6,0.64;0.8,0.56;1,-0.063];
[0,0.36;0.2,-0.15;0.4,-0.1;0.6,0.21;0.8,0.47;1,0.35];
[0,0.64;0.2,-0.22;0.4,-0.42;0.6,-0.11;0.8,0.28;1,-0.027]);
input_thickness = 20;
isWanted=(Thickness>input_thickness); % logical vector of locations wanted
data=Temp_data(:,:,isWanted); % return temperature data wanted
5 Kommentare
dpb
am 27 Feb. 2021
That would then require something like the table with the 2D arrays a cells; you wouldn't be able to use the 3D array "trick" as the planes have to be the same dimension(*) to do that.
(*) It would require augmenting to the maximum size with NaN or somesuch to do that.
Weitere Antworten (1)
Hernia Baby
am 26 Feb. 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]
Siehe auch
Kategorien
Mehr zu Data Type Identification 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!