Plotting a high order function
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
VBBV
le 13 Mar 2022
plot(x,f2(x),'.k')
give the necessary input values to functions created.
3 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Numerical Integration and Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!