フィルターのクリア

multiply a matrix by a specific value from a vector

3 ビュー (過去 30 日間)
Naema
Naema 2015 年 4 月 8 日
編集済み: Naema 2015 年 4 月 8 日
Hi : I want to multiply a matrix (resultx) sized 10001x10001 by only one value from etae which is sized 1x50.I want to access only the first value of etae and the last value of eate separately. can I do it like this:
Iph1=pinc*(resultx).^2*(etae(1,1))/h*v) % for first value
and,
Iph2=pinc*(resultx).^2*(etae(1,50))/h*v) % for last value
and, did I square (resultx) correctly?. should the (.) be there?. pinc,h, v, etae are single values. resultx is (mXn)
  2 件のコメント
James Tursa
James Tursa 2015 年 4 月 8 日
What are the sizes of pinc, h, and v? Scalars? As written, only h is in the denominator. Is this what you want or do you want v there as well?
Naema
Naema 2015 年 4 月 8 日
編集済み: Naema 2015 年 4 月 8 日
both h and v are in the denominator. pinc,h,v are scalars

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

採用された回答

Jeffrey Girard
Jeffrey Girard 2015 年 4 月 8 日
編集済み: Jeffrey Girard 2015 年 4 月 8 日
Let's use a cleaner example:
a = 5;
b = [1,2,3,4;5,6,7,8];
c = [0.5,1.0,1.5,2.0];
So if I want to multiply the matrix b by scalar a and then add that product's square to the first value of vector c, you should do the following:
d = (b .* a) .^ 2 + c(1);
And if you want to do the same but with the last value of vector c , you should do the following:
d = (b .* a) .^ 2 + c(end);
The dot before a mathematical operator (e.g., .*) indicates that you want to perform the operation using array operations (or element-wise) rather than matrix operations. If you are unfamiliar with matrix algebra, you want to be using the dots (i.e., array operations). In some cases, such as when using scalars, the two are equivalent, but it will be safer for you to use the dots as I did above.
  1 件のコメント
Naema
Naema 2015 年 4 月 8 日
編集済み: Naema 2015 年 4 月 8 日
so, is this the right answer?:
Iph1=pinc.*(resultx).^2.*etae(1)/h/v;

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOperating on Diagonal Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by