Graphing a messy 5th degree polynomial function

조회 수: 5 (최근 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 CenterFile Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by