Graphing a messy 5th degree polynomial function

1 回表示 (過去 30 日間)
Elijah L
Elijah L 2020 年 11 月 23 日
回答済み: Image Analyst 2020 年 11 月 23 日
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)

回答 (1 件)

Image Analyst
Image Analyst 2020 年 11 月 23 日
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);

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by