Y data addition on scatter plot
1 次查看(过去 30 天)
显示 更早的评论
i am plotting a scatter plot X= [ 2 ,3,4,5] Y=[10,20,30,40] scatter(X,Y) i am looking for putting y values on the scatter plot...any specific code or hint can anyone help.i am using 2016b version.Thank you in advance.
1 个评论
Voss
2022-1-17
Well, the code - as you have it now - works:
X= [ 2 ,3,4,5]
Y=[10,20,30,40]
scatter(X,Y)
采纳的回答
Voss
2022-1-17
You need to convert those cell arrays to numeric matrices before you can plot them (scatter or otherwise):
X= { 2 ,3,4,5}
Y={ 10,20,30,40}
scatter(cell2mat(X),cell2mat(Y))
更多回答(1 个)
Cris LaPierre
2022-1-17
编辑:Cris LaPierre
2022-1-17
Use square brackets to define vectors, not curly braces. You might find MATLAB Onramp helpful, especially chapters 2, 4 & 9. Also, capitalization matters in MATLAB. X is not the same variable as x.
X= [2,3,4,5];
Y=[10,20,30,40];
scatter(X,Y)
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!