Hey all,
i struggle with the following task:
I run multi body simulations and need to find limit values for specific configurations of my multibody system. The specific Configurations are saved in a table which contains all the necessary Data to edit the Model and execute the simulations automatically. Each Configuration is then simulated with different force values until some criterium is reached. The maximum force where some criterium was just not reached is then stored in my table in Col 5 as var "maxForce".
My table contains of several variables, say for this example Length_A and Length_B. Also my RowNames are called "Config 1", "Config 2", etc. Note that the values represent a Design of Experiment, so there are several duplicates of specific Variable Values. So for example Length_A of Config 1, 2 and 5 is 10m.
What i now struggle with is plotting my results to a 3D Bar. Lets say my example table is:
t = table(10, 1.5, 2000)
t.Properties.VariableNames = {'Length_A', 'Length_B','maxForce'};
t_2 = table(11,1.5,2500);
t_2.Properties.VariableNames = {'Length_A', 'Length_B','maxForce'};
t = [t; t_2];
t.Properties.RowNames = {'Config_1', 'Config_2'};
I now want to generate a plot where the values of "Length_A" are on the X-Axis, the values of "Length_B" are on the Y-Axis and the associated "maxForce" result Value is on the Z-Axis and represented in the height of the bar.
I already kind of have a solution but its quite complicated.
%basically i transpose the values manually
for i = 1:height(t)
datapoints(i+1,1) = t.Length_A(i);
datapoints(1,i+1)= t.Length_B(i);
datapoints(i+1,i+1) = t.maxForce(i);
i=i+1;
end
%and then compress the rows so that i only have unique values in the first
%column
t = array2table(datapoints);
[uni,idx_rows] = unique(t(:,1))
final_table = zeros(length(idx_rows), width(t))
final_table(:,1) = uni.datapoints1';
final_table(1,:) = t{1,:};
for j = 2:height(uni)
for i = 1:height(t)
if t{i,1} == uni{j,1}
final_table(j,2:width(t)) = t{i,2:width(t)} + final_table(j,2:width(t)) ;
end
i =i+1;
end
j=j+1;
end
%now basically the same for the columns
Now i have a map in which i have a maxForce Value for each unique Value of Length_A and Length_B which i can plot.
I feel like this is way too complicated but i just cant figure out how to process my data so that bar3 eats it without errors.
Can anyone help?
thank you very much in advance!
kind regards ,Vincent

 채택된 답변

Vincent Perner
Vincent Perner 2021년 3월 18일

0 개 추천

okay i just found a suitable solution myself.
Configs = readtable('InputData.xlsx', 'Format','auto', 'ReadRowNames', true, 'ReadVariableName',true)
maxForce = randi(24000,17,1);
Configs.maxForce = maxForce;
disp(Configs)
[val_r, y_r] = unique(Configs.Radstand)
[val_k, y_k] = unique(Configs.Kupplungslaenge)
for i = 1:1:length(val_r)
for j = 1:1:length(val_k)
idx = find(Configs.Radstand(:) == val_r(i) & Configs.Kupplungslaenge(:) == val_k(j) & Configs.Ueberhang(:) == 2);
if isempty(idx)
val = 0;
else
data(i,j) = Configs.maxForce(idx)
end
j=j+1;
end
i=i+1;
end
bar3(data)
set(gca,'XTickLabel',val_r)
set(gca,'YTickLabel',val_k)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

제품

릴리스

R2020b

태그

질문:

2021년 3월 18일

답변:

2021년 3월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by