how to code for a equation with summation symbol

1 回表示 (過去 30 日間)
PK
PK 2012 年 9 月 4 日
how to code for a equation containing summation like this
sum(i=1to10)sum(j=1to2)BijXi
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 9 月 4 日
what are sizes of B and X
Kevin Claytor
Kevin Claytor 2012 年 9 月 4 日
This would be a perfect case for a pair of nested for loops.

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

採用された回答

Star Strider
Star Strider 2012 年 9 月 4 日
編集済み: Star Strider 2012 年 9 月 4 日
I am guessing that you want to multiply B (that seems to be a [10 x 2] matrix) and X (that seems to be a [10 x 1] vector). That will not work because the number of columns of B has to equal the number of rows in X.
If you define B as [2 x 10], then the [2 x 1] vector Y will be:
Y = B*X
See the documentation sections on Language Fundamentals, Arrays and Matrices, and Linear Algebra for more information.
Also, please do not use ‘i’ and ‘j’ for array indexing. MATLAB uses those for its imaginary operators. They will work as array indexes but will cause confusion if you also use complex numbers.
  2 件のコメント
PK
PK 2012 年 9 月 5 日
k i tried it that way and its working fine but how to subtract a complex value obtained from exponential with a constant numerical value and removing complex value from a term
Star Strider
Star Strider 2012 年 9 月 5 日
I am not certain that I understand your question. If you mean by ‘removing a complex value from a term’ that you want to eliminate imaginary values, then the easiest way is to use the real function.
If the values of the complex part are very small (perhaps on the order of 1E-6 times the real part or less and you have good reason to believe the result should not be complex) you may be able to consider them as numerical errors in the calculation process and ignore them. If they are not, I suggest you look closely at your data and your code to be sure you are doing the calculations correctly.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by