xlabel not working inside a function
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sankalp Garud
el 20 de Oct. de 2021
Comentada: Sankalp Garud
el 20 de Oct. de 2021
Hey all,
I am trying to create a simple funciton
function scatter_plot(x, y, xlabel, ylabel)
scatter(x,y,'filled');
xlabel(xlabel)
ylabel(ylabel)
end
However this does not work at the xlabel line. Why? The same code if I take it out of the function works very well. I'm not wanting to copy paste this code for all my scatter plots. In addition, I may want to change some formatting in future, and again, having a function would be ideal.
0 comentarios
Respuesta aceptada
Dave B
el 20 de Oct. de 2021
You've named the function's parameters xlabel and ylabel. So within the function xlabel and ylabel are variables, not functions. Simply choose a different name:
function scatter_plot(x, y, xlbl, ylbl)
scatter(x,y,'filled');
xlabel(xlbl)
ylabel(ylbl)
end
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!