Plotting a high order function

1 次查看(过去 30 天)
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;
Unrecognized function or variable 'del_x'.
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')

采纳的回答

VBBV
VBBV 2022-3-13
plot(x,f2(x),'.k')
give the necessary input values to functions created.
  3 个评论
Gabriel Sheets
Gabriel Sheets 2022-3-13
There it is! -- I thought I already tried that (but I guess not).
VBBV
VBBV 2022-3-30
please accept the answer if it solved the problem, :) thanks

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by