Azzera filtri
Azzera filtri

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

3 visualizzazioni (ultimi 30 giorni)
function graph
x = 1:100;
y = f(x);
plot(x,y);
end
function [y] = f(n)
y = n * log2(n);
end

Risposta accettata

Star Strider
Star Strider il 17 Mar 2016
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.

Più risposte (0)

Categorie

Scopri di più su Multidimensional Arrays in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by