how can i sum different variables?

조회 수: 1 (최근 30일)
GIORGIA FRANZINO
GIORGIA FRANZINO 2024년 1월 24일
댓글: GIORGIA FRANZINO 2024년 1월 30일
I have to perform this calculation and I don't know the tau values so it is a simobolic calculation. How can I implement it? Thank you so much.
a=2 N=4 n=3
  댓글 수: 1
Torsten
Torsten 2024년 1월 24일
편집: Torsten 2024년 1월 24일
Define a function with the tau-vector, a, n and N as inputs. Then all the operations can and should be done numerically.

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

답변 (1개)

Milan Bansal
Milan Bansal 2024년 1월 30일
Hi GIORGIA FRANZINO,
I understand you want to solve the given expression in symbolic form for the case when a = 2, N = 4 and n = 3.
For the particular case when a = 2, N = 4 and n = 3, the expression becomes:
The above expression can be resolved in symbolic form as shown in the code snippet below:
% Define the symbolic variables
syms v1 v2 v3; % Define symbolic variables
% Create symbolic tau vector
tau = [v1 v2 v3];
% use nested for loops to calculate the expression
s = 0; % initialize sum
for i1 = 1:2
s1 = 0;
for i2 = 2:3
s2 = 0;
for i3 = 3:3
p = tau(i1) * tau(i2) * tau(i3);
s2 = s2 + p;
end
s1 = s1+s2;
end
s = s+s1;
end
% display results
disp(s)
Please refer to the following documentation link to learn more about "Symbolic Math Toolbox".
Hope this helps!

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by