필터 지우기
필터 지우기

Creating 3D efficiency map using interpolation.

조회 수: 14 (최근 30일)
Michal
Michal 2023년 7월 6일
댓글: Joe Vinciguerra 2023년 7월 6일
Hi, I need to get double variable when X and Y are torgue and spped and values of the cells are efficiences from 86 to 96, because know i could only check efficiences of the points on the curves.
I have a problem with interpolating it in Z- scale, I propably need to use scatteredInterpolant but i dont know how. I attach the data, the example points from the curves where x-es are the speed and y - torgue, and then the cript where i interpolate the data, and create 2-D plot and surf from it.
Thank you in advance for any help.

채택된 답변

Joe Vinciguerra
Joe Vinciguerra 2023년 7월 6일
Here is your existing code:
%B-spline interpolation
eff96_spline(:,1) = spline(1:numel(eff96(:,1)), eff96(:,1), 1:0.1:numel(eff96(:,1)))';
eff96_spline(:,2) = spline(1:numel(eff96(:,1)), eff96(:,2), 1:0.1:numel(eff96(:,1)))';
eff95_spline(:,1) = spline(1:numel(eff95(:,1)), eff95(:,1), 1:0.1:numel(eff95(:,1)))';
eff95_spline(:,2) = spline(1:numel(eff95(:,1)), eff95(:,2), 1:0.1:numel(eff95(:,1)))';
eff94_spline(:,1) = spline(1:numel(eff94(:,1)), eff94(:,1), 1:0.1:numel(eff94(:,1)))';
eff94_spline(:,2) = spline(1:numel(eff94(:,1)), eff94(:,2), 1:0.1:numel(eff94(:,1)))';
eff90_spline(:,1) = spline(1:numel(eff90(:,1)), eff90(:,1), 1:0.1:numel(eff90(:,1)))';
eff90_spline(:,2) = spline(1:numel(eff90(:,1)), eff90(:,2), 1:0.1:numel(eff90(:,1)))';
eff86_spline(:,1) = spline(1:numel(eff86(:,1)), eff86(:,1), 1:0.1:numel(eff86(:,1)))';
eff86_spline(:,2) = spline(1:numel(eff86(:,1)), eff86(:,2), 1:0.1:numel(eff86(:,1)))';
% creating speed torgue and efficiency variables
lng = length(eff96_spline);
speed(:,1) = eff86_spline(:,1);
speed(:,2) = eff90_spline(:,1);
speed(:,3) = eff94_spline(:,1);
speed(:,4) = eff95_spline(:,1);
speed(:,5) = eff96_spline(:,1);
torgue(:,1) = eff86_spline(:,2);
torgue(:,2) = eff90_spline(:,2);
torgue(:,3) = eff94_spline(:,2);
torgue(:,4) = eff95_spline(:,2);
torgue(:,5) = eff96_spline(:,2);
efficiency = ones(lng,5);
efficiency(:,1) = 86 * ones(1, lng)';
efficiency(:,2) = 90 * ones(1, lng)';
efficiency(:,3) = 94 * ones(1, lng)';
efficiency(:,4) = 95 * ones(1, lng)';
efficiency(:,5) = 96 * ones(1, lng)';
% plot(eff96_spline(:,1),eff96_spline(:,2),'-');
% hold on;
% plot(eff95_spline(:,1),eff95_spline(:,2),'-');
% hold on;
% plot(eff94_spline(:,1),eff94_spline(:,2),'-');
% hold on;
% plot(eff90_spline(:,1),eff90_spline(:,2),'-');
% hold on;
% plot(eff86_spline(:,1),eff86_spline(:,2),'-');
% hold on;
% plot(continoustorgue(:,1),continoustorgue(:,2),'k--')
% hold on;
% plot(peaktorgue(:,1),peaktorgue(:,2), 'k--')
% xlabel('Motor speed [rpm]')
% ylabel('Torgue [Nm]')
% xlim([0,5510])
% ylim([0,250])
% legend('96%','95%','94%','90%','86%', 'continous torgue', 'peak torgue')
grid on;
figure()
% surfc([eff86(:,1) eff90(:,1) eff94(:,1), eff95(:,1),eff96(:,1)], [eff86(:,2) eff90(:,2) eff94(:,2),eff95(:,2),eff96(:,2)], (ones(numel(eff86(:,1)),5).*[86 90 94 95 96]))
surfc([eff86_spline(:,1),eff90_spline(:,1), eff94_spline(:,1), eff95_spline(:,1), eff96_spline(:,1)],[eff86_spline(:,2),eff90_spline(:,2), eff94_spline(:,2), eff95_spline(:,2), eff96_spline(:,2)], (ones(lng,5).*[86 90 94 95 96]), ...
"EdgeColor","none", "FaceAlpha",0.5)
xlabel('Motor Speed (rpm]')
ylabel('Torque [Nm]')
zlabel('Efficiency [%]')
colormap(parula(10))
colorbar
Here is what I would add
hold on;
n = length(eff86_spline); % find the length of the data we're working with
foo = [eff86_spline; eff90_spline; eff94_spline; eff95_spline; eff96_spline]; % combine all the speed and torque data into single array
bar = repelem([86; 90; 94; 95; 96], n); % create an array for the efficiency values
blah = [foo, bar]; % combine the speed, torque, and efficiency
blah = unique(blah, "rows"); % remove duplicate data
F = scatteredInterpolant(blah(:,1), blah(:,2), blah(:,3)); % create a scatteredInterpolant object from your data
xq = 2500; % pick a speed
yq = 50; % pick a torque
zr = F(xq, yq); % find the resulting interpolated efficiency
scatter3(xq, yq, zr, "red", "filled") % plot the resulting point
Here is the resulting graph (note I changed the transparency of your surface because the point was slightly hidden below the surface):
  댓글 수: 2
Michal
Michal 2023년 7월 6일
Thanks, it also works without creating the foo, bar and blah variables in a way shown by @Matt J, but thank s to both of you. One more question, how to make the surf "closed" on the top so the whole point in the top are will be in 96% efficiency?
Joe Vinciguerra
Joe Vinciguerra 2023년 7월 6일
You could just add another dataset representing a single point approximately in the middle of the top; an array the same size as your other data.
Something like this for the surface
surfc(...
[eff86_spline(:,1),eff90_spline(:,1), eff94_spline(:,1), eff95_spline(:,1), eff96_spline(:,1), repmat(3000,351,1)], ...
[eff86_spline(:,2),eff90_spline(:,2), eff94_spline(:,2), eff95_spline(:,2), eff96_spline(:,2), repmat(100,351,1)],...
(ones(lng,6).*[86 90 94 95 96 96]), ...
"EdgeColor","none", "FaceAlpha",0.5)
and for the interpolation:
n = length(eff86_spline); % find the length of the data we're working with
foo = [eff86_spline; eff90_spline; eff94_spline; eff95_spline; eff96_spline; repmat([3000,100],351,1)]; % combine all the speed and torque data into single array
bar = repelem([86; 90; 94; 95; 96; 96], n); % create an array for the efficiency values
blah = [foo, bar]; % combine the speed, torque, and efficiency
blah = unique(blah, "rows"); % remove duplicate data
F = scatteredInterpolant(blah(:,1), blah(:,2), blah(:,3)); % create a scatteredInterpolant object from your data

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

추가 답변 (1개)

Matt J
Matt J 2023년 7월 6일
편집: Matt J 2023년 7월 6일
torque=torgue;
F=scatteredInterpolant(speed(:),torque(:), efficiency(:))
Now use F to query the points you want as explained in the documentation:

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by