필터 지우기
필터 지우기

how to code a sum of function in matlab

조회 수: 5 (최근 30일)
MOUNIBA REDAH
MOUNIBA REDAH 2023년 11월 29일
댓글: MOUNIBA REDAH 2023년 12월 1일
I have already did a code for this function but without sum it didnt give me the right result
clear
el= 0.3;
L= 0.57 ;
h= 0.15;
t=0:0.5:20;
x=0.02;
omega1=6.0578;
omega=6.66358;
g=9.81;
A=0.0333179;
k=((1/L)*pi);
D=4*omega/L*cosh(k*h)*(1/k^(2));
C=omega*D*pi/((omega1)^(2)-(omega)^(2));
A1=-C*(D/omega);
z=(1/g)*sin(k*(x-(L/2)))*cosh(k*h)*(-A*omega1*sin(omega1*t)-C*omega*sin(omega*t))-1/g*A*omega*(x-L/2)*sin(omega*t) ;
figure
plot(t,z);
  댓글 수: 1
Dyuman Joshi
Dyuman Joshi 2023년 12월 1일
The value of k is dependent on n, whereas you have defined it as a constant.
Thus, other subsequent definitions are incorrect.
And the summation is w.r.t n, whereas you are performing it w.r.t t.

댓글을 달려면 로그인하십시오.

채택된 답변

Torsten
Torsten 2023년 11월 29일
이동: Torsten 2023년 11월 29일
Generate the elements that you want to sum in a matrix M of size (N,nt) where N is the index up to which you want to sum and nt is the number of time points in the "t" array. After you did this, use sum(M,1) to build the sum over the rows of M.
  댓글 수: 1
MOUNIBA REDAH
MOUNIBA REDAH 2023년 12월 1일
okey i will try it thank you for your response

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by