I need to plot B = (cos(X))^m; for m=1-20 and X at viewing angles 10degrees, 20 degrees, and 45 degrees. I am new to matlab and can't get the code right.

>> B = (cos(X))^m;
Undefined function or variable 'X'.
>> X = [10 20 45];
>> m = [1:20];
>> B = (cos(X))^m;
Error using ^
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead.
>> B = (cos(X)).^m;
Error using .^
Matrix dimensions must agree.
>> X = [10, 20, 45];
>> B = (cos(X)).^m;
Error using .^
Matrix dimensions must agree.

 採用された回答

Mischa Kim
Mischa Kim 2014 年 12 月 5 日
You mean
X = [10 20 45]';
m = [1:20];
B = bsxfun(@power, cosd(X), m)

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

2014 年 12 月 5 日

コメント済み:

2014 年 12 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by