Plotting a high order function

조회 수: 3 (최근 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 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