How to get a contour plot from the combination of "for loop" and "matrix operation"?

2 ビュー (過去 30 日間)
Nasir Mehmood
Nasir Mehmood 2020 年 9 月 28 日
コメント済み: madhan ravi 2020 年 9 月 28 日
How to get a contour plot of say z = matrix_a * matrix_b?
Here matrix_a = f(x,y), matrix_b = f(x,y) and f(x,y) may be a complex function.
Possible approach may look like this:
Loop1: x = variable
Loop2: y = variable
matrix_a = f(x,y)
matrix_b = f(x,y)
Result: z = matrix_a * matrix_b
contourf(x, y, real(z))
or
contourf(x, y, imag(z))

回答 (1 件)

madhan ravi
madhan ravi 2020 年 9 月 28 日
[X, Y] = meshgrid(x, y);
Z = X .* Y;
contourf(X, Y, Z)
  2 件のコメント
Nasir Mehmood
Nasir Mehmood 2020 年 9 月 28 日
Thanks for a quick response dear Madhan Ravi.
However, the problem I encountered is different. I do not need a point-wise multiplication. Instead I need to multiply two matrices (matrix operation) which'll produce a single number (in case of a 1-by-n and n-by-1 matrix multiplication). Therefore I need to have multiple matrices (varying with x and y) and getting a set of values of z to be plotted.
madhan ravi
madhan ravi 2020 年 9 月 28 日
.* with *

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

カテゴリ

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

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by