Plotting a high order function

6 ビュー (過去 30 日間)
Gabriel Sheets
Gabriel Sheets 2022 年 3 月 13 日
コメント済み: VBBV 2022 年 3 月 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 Center および File ExchangeNumerical 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