Need support for 3d plotting payload calculation for electric vehicle

2 次查看(过去 30 天)
Hi,
Am trying to develop a 3d plot for payload calculation, for the motor power distribution of the vehicle. Am knew to this but trying it out now. Below you can find the equation am trying to use;
X=((Wp × Xp) + (Wu × X)) / (Wp+W)
Also wanted to mention, am using GNU Octave for this, as an alternative to Matlab, but am sure both are relatively same. If you could let me know or provide suggestion on how to create 3D graphical plot for this above equation in matlab, will be great.
Note: you can consider any random values for the equation as an example. I have also attached a code which i did previously and 3d graph i want to recreate.

回答(1 个)

Venkat Siddarth Reddy
Hi Akash,
I reviewed the code and noticed a mismatch in the sizes of the parameters for the surf and contour functions.For 3D plot, the size of height matrix(i.e. Xcp) should be same as size of x-y plane co-ordinates i.e.(size(Xcp)=size(x)=size(y)).
In the provided code x,y co-ordinates are of same size but not the Xcp. Refer to the following code snippet to plot a 3D plot for the equation X=((Wp × Xp) + (Wu × X)) / (Wp+W):
% Define ranges for Wp and Wu
Wp = linspace(0, 100, 50);
Wu = linspace(0, 100, 50);
% Create a meshgrid for Wp and Wu
[WpGrid, WuGrid] = meshgrid(Wp, Wu);
% Constants for Xp and Xu
Xp = 2;
Xu = 1;
% Calculate Xtotal for each combination of Wp and Wu
Xtotal = ((WpGrid .* Xp) + (WuGrid .* Xu)) ./ (WpGrid + WuGrid);
% Handling division by zero or NaN results when both Wp and Wu are 0
Xtotal(isnan(Xtotal)) = 0;
% Plotting the 3D surface
surf(WpGrid, WuGrid, Xtotal)
title('3D Plot for Motor Power Distribution')
contour(WpGrid, WuGrid, Xtotal,10);
xlabel('payload');
ylabel('center of gravity');
I hope it helps!

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by