Plotting a high order function
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Gabriel Sheets
am 13 Mär. 2022
Kommentiert: VBBV
am 30 Mär. 2022
I just solved a differential equation numerically (and solved a system of 11 eq. 11 unknowns), which is denoted by my S-variable, and am trying to plot the solution against x (same x as for the Analytical Solution -- x = 0:del_x:L). When I try to plot(x,f2(x,S)), or even plot(x,f2(x,S(1),S(2),S(3),etc.)), I get an error stating, "Too many inputs".
What am I missing in my code?
Thanks in advance!
%Consolidating b-matrix values
c1 = (7500-((50^3)/3600)*2.5)/600000;
c2 = (15000-((100^3)/3600)*2.5)/600000;
c3 = (22500-((150^3)/3600)*2.5)/600000;
c4 = (30000-((200^3)/3600)*2.5)/600000;
c5 = (37500-((250^3)/3600)*2.5)/600000;
c6 = (45000-((300^3)/3600)*2.5)/600000;
c7 = (52500-((350^3)/3600)*2.5)/600000;
c8 = (60000-((400^3)/3600)*2.5)/600000;
c9 = (67500-((450^3)/3600)*2.5)/600000;
c10 = (75000-((500^3)/3600)*2.5)/600000;
c11 = (82500-((550^3)/3600)*2.5)/600000;
%b-matrix
b = [c1;c2;c3;c4;c5;c6;c7;c8;c9;c10;c11];
%A-matrix
A = [2 1 0 0 0 0 0 0 0 0 0;
1 2 1 0 0 0 0 0 0 0 0;
0 1 2 1 0 0 0 0 0 0 0;
0 0 1 2 1 0 0 0 0 0 0;
0 0 0 1 2 1 0 0 0 0 0;
0 0 0 0 1 2 1 0 0 0 0;
0 0 0 0 0 1 2 1 0 0 0;
0 0 0 0 0 0 1 2 1 0 0;
0 0 0 0 0 0 0 1 2 1 0;
0 0 0 0 0 0 0 0 1 2 1;
0 0 0 0 0 0 0 0 0 1 2];
%Solution to Differential Equation
S = A\b;
f2 = @(x) (S(1)*x.^10)+(S(2)*x.^9)+(S(3)*x.^8)+(S(4)*x.^7)+(S(5)*x.^6)+(S(6)*x.^5)+(S(7)*x.^4)+(S(8)*x.^3)+(S(9)*x.^2)+(S(10)*x)+S(11);
%Plot of Analytical Solution
x = 0:del_x:L;
f1 = @(x,E,I,Wo,L) Wo/(120*E*I*L)*(-x.^5+(2*(L^2)*x.^3)-(x.*L^4));
subplot(2,1,1)
plot(x,f1(x,E,I,Wo,L),'r-')
xlabel('Axial Position (cm)')
ylabel('Displacement (cm)')
title('Analytical Solution')
hold on
subplot(2,1,2)
plot(x,f2(x,S),'.k')
0 Kommentare
Akzeptierte Antwort
VBBV
am 13 Mär. 2022
plot(x,f2(x),'.k')
give the necessary input values to functions created.
3 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!