Trying to plot x,y, but it says error in y = f(x);

4 ビュー (過去 30 日間)
Jovos
Jovos 2016 年 3 月 17 日
回答済み: Star Strider 2016 年 3 月 17 日
function graph
x = 1:100;
y = f(x);
plot(x,y);
end
function [y] = f(n)
y = n * log2(n);
end

採用された回答

Star Strider
Star Strider 2016 年 3 月 17 日
You need to use element-wise operations in this line:
y = n .* log2(n);
Note the ‘.*’ replacing the ‘*’. See the documentation for Array vs. Matrix Operations for details.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ


Translated by