Graphing a messy 5th degree polynomial function

1 visualización (últimos 30 días)
Elijah L
Elijah L el 23 de Nov. de 2020
Respondida: Image Analyst el 23 de Nov. de 2020
I am trying to graph the function 'm' as a function of 'r'. I continuously am getting an error message in the function line. Could some body please help me succesfully graph this? I would like the domain to be 5.75*10^-8 to 2*10-6
This is my script so far:
DabF = 5.662*10^-6; % cm^2/s
Cao = .08; % g/cm^3
L = 250*10^-4; % cm
S = 42; % cm^2
Tao = 1; % unitless
Eps = .4; % unitless
a = 5.75*10^-6; % cm
r = linspace(0,1,10*10^-5);
m = (DabF/L)*Eps*S*((1-(a/r))^2)*(1-2.1*(a/r)+2.09*(a/r)^(3)-.95*(a/r)^(5))*(Cao/Tao);
plot(m,r)

Respuestas (1)

Image Analyst
Image Analyst el 23 de Nov. de 2020
You can't have 10^(-4) elements in your array. You need at least 1.
r = linspace(0,1,10*10^-5);
How many do you want? Say, 1000? Try it this way, using dot operators to do element by element operations on vectors:
DabF = 5.662*10^-6; % cm^2/s
Cao = .08; % g/cm^3
L = 250*10^-4; % cm
S = 42; % cm^2
Tao = 1; % unitless
Eps = .4; % unitless
a = 5.75*10^-6; % cm
numPoints = 1000;
r = linspace(0, 1, numPoints);
term1 = (DabF/L)*Eps*S*((1-(a./r)).^2);
term2 = (1-2.1*(a./r) + 2.09*(a./r).^(3) - .95*(a./r).^(5));
% m = (DabF/L)*Eps*S*((1-(a./r)).^2)*(1-2.1*(a./r)+2.09*(a./r).^(3)-.95*(a./r).^(5))*(Cao/Tao);
m = term1 .* term2 *(Cao/Tao);
plot(r, m)
grid on;
xlabel('r', 'FontSize', 15);
ylabel('m', 'FontSize', 15);

Categorías

Más información sobre Discrete Data Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by