Plot of mass using different densities

1 view (last 30 days)
Hi MATLAB Community,
I am trying to make a graph in MATLAB, to look like the grap below. but not sure how to make the plot. ny advice would be appriated.
%Mass of different size balls
de= [.0015, .0020, .0050]; %Density [kg/cm^3]
b=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1500, 2000]; %Ball Size[µm]
r=b/20000; %Radius of ball [cm]
m=de*3/4*pi*r^3; % %Mass [kg]
plot(m,r);
title('3 Different Size of Balls');
legend('1500 kg/m^3, 2500 kg/m^3, 5000 kg/m^3')
xlabel('Ball Mass [kg]');
ylabel('Ball Size [μm]');
grid on
grid minor

Accepted Answer

DGM
DGM on 23 Mar 2021
Something like this
%Mass of different size balls
de= [.0015, .0020, .0050]; %Density [kg/cm^3]
b=[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1500, 2000]; %Ball Size[µm]
r=b/20000; %Radius of ball [cm]
% use element-wise exponentiation
% Kronecker product of two orthogonal vectors is a 2D array
% which is what we want, so transpose the density vector
m=kron(de',3/4*pi*r.^3); %Mass [kg]
plot(r,m);
title('3 Different Size of Balls');
% the legend strings need to be separate arguments, not one
legend('1500 kg/m^3', '2500 kg/m^3', '5000 kg/m^3','location','northwest')
ylabel('Ball Mass [kg]');
xlabel('Ball Radius [cm]'); %needed to use the right units
grid on
grid minor
That's getting there.
  1 Comment
Kenneth Bisgaard Cristensen
Thanks, the m=kron(x) was exactly what I was looking for. Relly appricate the help.

Sign in to comment.

More Answers (0)

Categories

Find more on Particle & Nuclear Physics in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!