Scatter plot error: not enough input arguments

4 visualizaciones (últimos 30 días)
Kristine
Kristine el 11 de Abr. de 2025
Editada: Walter Roberson el 14 de Abr. de 2025
Hi all,
I am trying to create a scatter plot and I get the error:
Error using scatter Not enough input arguments.
I don’t know what other import arguments would be necessary here as there is an x and y. My code is as follows:
euler = 2.71828 ;
sigma = std(OL_All.EquivDiameter) ; % std(files.ESD) % standard deviation
mu = mean(OL_All.EquivDiameter) ; % mean(files.ESD) % mean
ESD_values = OL_All.EquivDiameter ; % files.ESD
sigma_sqrt2pi = sqrt(2 .* pi).^2 ;
ESD_mu_squared = (ESD_values - mu).^2 ;
sigma_squared_two = (2 .* sigma).^2 ;
f_of_x = table((1 / sigma_sqrt2pi) .* euler.^(-(ESD_mu_squared / sigma_squared_two))) ;
scatter(OL_All.EquivDiameter, f_of_x)

Respuesta aceptada

Walter Roberson
Walter Roberson el 12 de Abr. de 2025
Editada: Walter Roberson el 14 de Abr. de 2025
f_of_x = table((1 / sigma_sqrt2pi) .* euler.^(-(ESD_mu_squared / sigma_squared_two))) ;
scatter(OL_All.EquivDiameter, f_of_x)
The permitted basic syntaxes for scatter are
  • scatter(x, y)
  • scatter(TableVariable, XVariableName, YVariableName)
You are not using either of those. You are using scatter(x, TableVariable)
Meanwhile, your table only has one variable, so you cannot specify it for scatter purposes.
What you can do is
scatter(OL_All.EquivDiameter, f_of_x.Var1)
However, I do not see much of a reason to put f_of_x into a table in the first place. I think you should just do
f_of_x = ((1 / sigma_sqrt2pi) .* euler.^(-(ESD_mu_squared / sigma_squared_two))) ;
scatter(OL_All.EquivDiameter, f_of_x)
  1 comentario
Kristine
Kristine el 14 de Abr. de 2025
I put f_of_x in a table, because i was previously getting an arror about mismatched types. But now when I just tried to re-run it without the table command it ran perfectly fine. So now I'm not sure why it wasn't working before.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Productos


Versión

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by