フィルターのクリア

How to write the code in Matlab for the the double summation attached below.

4 ビュー (過去 30 日間)
Bijaya Das
Bijaya Das 2023 年 6 月 10 日
コメント済み: Bijaya Das 2023 年 6 月 13 日

回答 (2 件)

Torsten
Torsten 2023 年 6 月 10 日
移動済み: Torsten 2023 年 6 月 10 日
n = 5;
m = 10;
p = rand(n,m);
C = rand(1,m);
dt = 0.2;
F1 = dt*sum(sum(C.*p))
F1 = 3.3520
  2 件のコメント
Image Analyst
Image Analyst 2023 年 6 月 10 日
@Bijaya Das To learn other fundamental concepts, invest 2 hours of your time here:
Bijaya Das
Bijaya Das 2023 年 6 月 13 日
Thank you...

サインインしてコメントする。


RANGA BHARATH
RANGA BHARATH 2023 年 6 月 12 日
Hi @Bijaya Das. Here is the solution and code for your question.
Question: How to write the code to perform double summation (for the equation attached)?
Solution:
According to the provided equation, it can be clearly seen that 'C' is a one-dimensional vector (column or row vector) of length m and 'p' is a 2D array with shape (n,m) or (m,n). One of the approaches is to use normal matrix multiplication for the inner sum and then use 'sum' function for outer sum.
Assumptions:
  • Let us assume C as a column vector of shape (m,1) and p as a 2D matrix of shape (n,m).
  • Here, I'm using integers to perform this task as it would be easy to understand.
  • And the values taken are: m = 3, n = 2, range of integers used = 1 to 5, deltat = 0.5.
Code:
n = 3;
m = 2;
p = randi([1,5],n,m)
C = randi([1,5],m,1)
deltat = 0.5;
temp = p*C*deltat
f1 = sum(temp,1)
Links to Documentation:

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by