can anyone help me prepare the code

clear clc syms E0 E1 E2 E3 c0 c1 c2 c3 t r0 r1 r2 r3 K0 K1 K2 K3 format long
c0=0 c1=1/3; c2=2/3; c3=1; r0=0; r1=1; r2=2; r3=3;
E0=[euler(r0,sym(c0)) euler(r0,c1) euler(r0,c2) euler(r0,c3)] E1=[euler(r1,c0) euler(r1,c1) euler(r1,c2) euler(r1,c3)] E2=[euler(r2,c0) euler(r2,c1) euler(r2,c2) euler(r2,c3)] E3=[euler(r3,c0) euler(r3,c1) euler(r3,c2) euler(r3,c3)] E=[E0' E1' E2' E3']
K0=[int(euler(r0,t), 0,c0) int(euler(r0,t), 0,c1) int(euler(r0,t), 0,c2) int(euler(r0,t), 0,c3)] K1=[int(euler(r1,t), 0,c0) int(euler(r1,t), 0,c1) int(euler(r1,t), 0,c2) int(euler(r1,t), 0,c3)] K2=[int(euler(r2,t), 0,c0) int(euler(r2,t), 0,c1) int(euler(r2,t), 0,c2) int(euler(r2,t), 0,c3)] K3=[int(euler(r3,t), 0,c0) int(euler(r3,t), 0,c1) int(euler(r3,t), 0,c2) int(euler(r3,t), 0,c3)] K=[K0' K1' K2' K3']
Ek=E-K F=[6*c0-3*c0^2;6*c1-3*c1^2;6*c2-3*c2^2;6*c3-3*c3^2] InvInv_Ek=inv(Ek) C=inv(Ek)*F Ua=E*C
Ue=[6*c0 6*c1 6*c2 6*c3]'

답변 (1개)

per isakson
per isakson 2021년 4월 21일

0 개 추천

Problems with your script
  • The long lines make the code hard to read.
  • Numerous statement separators are missing
I added line breaks and semicolons. Now the script runs.
%%
clear clc
syms E0 E1 E2 E3 c0 c1 c2 c3 t r0 r1 r2 r3 K0 K1 K2 K3
format long
c0=0; c1=1/3; c2=2/3; c3=1; r0=0; r1=1; r2=2; r3=3;
E0=[euler(r0,sym(c0)) euler(r0,c1) euler(r0,c2) euler(r0,c3)];
E1=[euler(r1,c0) euler(r1,c1) euler(r1,c2) euler(r1,c3)];
E2=[euler(r2,c0) euler(r2,c1) euler(r2,c2) euler(r2,c3)];
E3=[euler(r3,c0) euler(r3,c1) euler(r3,c2) euler(r3,c3)];
E=[E0' E1' E2' E3'];
K0=[int(euler(r0,t), 0,c0) int(euler(r0,t), 0,c1) int(euler(r0,t), 0,c2) int(euler(r0,t), 0,c3)];
K1=[int(euler(r1,t), 0,c0) int(euler(r1,t), 0,c1) int(euler(r1,t), 0,c2) int(euler(r1,t), 0,c3)];
K2=[int(euler(r2,t), 0,c0) int(euler(r2,t), 0,c1) int(euler(r2,t), 0,c2) int(euler(r2,t), 0,c3)];
K3=[int(euler(r3,t), 0,c0) int(euler(r3,t), 0,c1) int(euler(r3,t), 0,c2) int(euler(r3,t), 0,c3)];
K=[K0' K1' K2' K3'];
Ek=E-K;
F=[6*c0-3*c0^2;6*c1-3*c1^2;6*c2-3*c2^2;6*c3-3*c3^2];
InvInv_Ek=inv(Ek);
C=inv(Ek)*F
C = 
Ua=E*C
Ua = 
Ue=[6*c0 6*c1 6*c2 6*c3]'
Ue = 4×1
0 2 4 6

댓글 수: 6

Relly Syam
Relly Syam 2021년 4월 26일
편집: Relly Syam 2021년 4월 26일
thank you very much for the answer, could you help me write it down using the 'for loop' function to make it shorter
Relly Syam
Relly Syam 2021년 4월 26일
I run it on matlab mobile, what do you think about the result, where the approximate solution and the exact solution are the same
Walter Roberson
Walter Roberson 2021년 4월 26일
https://www.mathworks.com/help/symbolic/sym.euler.html
The function accepts vectors for both arguments
Walter Roberson
Walter Roberson 2021년 4월 26일
You are only doing symbolic computation, which should be exact for those formulas. I do not see any approximation calculations?
Relly Syam
Relly Syam 2021년 4월 26일
The above code is part of the process of estimating the integral using the weighted residual collocation method. the example above uses n = 3. what do you think what i did was a little wrong?
Relly Syam
Relly Syam 2021년 4월 26일
편집: per isakson 2021년 4월 26일
I am trying to approximate this equation

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

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

태그

질문:

2021년 4월 19일

편집:

2021년 4월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by