Trying to code from Polymath

조회 수: 9 (최근 30일)
Houtan
Houtan 2023년 12월 27일
댓글: Alan Stevens 2023년 12월 29일
Im supposed to turn this Polymath code into a Matlab code but Im not sure how. Please help. I am supposed to graph as well<</matlabcentral/answers/uploaded_files/1577366/IMG_0357.jpeg>>

답변 (1개)

Alan Stevens
Alan Stevens 2023년 12월 28일
Like this for example (I'll leave you to extract the numerical values):
Wspan = [0 2]; % Integration range
% Initial values
Fe0 = 5.58E-04;
Fo0 = 0.001116;
Fd0 = 0;
Fu10 = 1E-7;
Fu20 = 0;
F0 = [Fe0, Fo0, Fd0, Fu10, Fu20];
% Call integrating function
[W, F] = ode45(@fn, Wspan, F0);
% Extract individual variables
Fe = F(:,1); Fo = F(:,2); Fd = F(:,3); Fu1 = F(:,4); Fu2 = F(:,5);
% Note that Fu1 and Fu2 are virtually indistinguishable!
% Plot F vs W
plot(W,F), grid
xlabel('W'), ylabel('F')
legend('Fe','Fo','Fd','Fu1','Fu2')
% Calculate X and S
X = 1 - Fe/0.000558;
S = Fd./Fu1;
% Plot X vs W and S vs W
figure
plot(W,X,W,S), grid
xlabel('W'), ylabel('X and S')
legend('X','S')
function dbydW = fn(~,F)
Fe = F(1); Fo = F(2); Fd = F(3); Fu1 = F(4); Fu2 = F(5);
Finert = 0.007626;
Ft = Fe + Fo + Fd + Fu1 + Fu2 + Finert;
K1 = 6.5;
K2 = 4.33;
Pto = 2;
Pe = Pto*Fe/Ft;
Po = Pto*Fo/Ft;
k1 = 0.15;
k2 = 0.088;
r1e = -k1*Pe*Po^0.58/(1+K1*Pe)^2;
r2e = -k2*Pe*Po^0.3/(1+K2*Pe)^2;
dbydW = [ r1e + r2e;
r1e/2 + 3*r2e;
-r1e;
-2*r2e;
-2*r2e];
end
  댓글 수: 3
abdurahman
abdurahman 2023년 12월 29일
also can you plot X Vs S?
Alan Stevens
Alan Stevens 2023년 12월 29일
The function is listed below the second figure.
plot(X,S) (or plot(S,X) if you want S on the x-axis and X on the y-axis)) will plot X vs S.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by