scatter command not working

9 ビュー (過去 30 日間)
Kika
Kika 2024 年 5 月 18 日
コメント済み: Kika 2024 年 5 月 20 日
xdata = exp_data.concentration;
ydata = exp_data.velocity;
scatter(xdata, ydata)
I'm a beginner and I'm practically following the tutorial to the letter, there doesn't seem to be any problem with the code but each time I try to run it, it won't work. The error message comes out as such;
Error using scatter (line 68)
Input arguments must be numeric, datetime, duration, or categorical.
Error in
scatter(xdata,ydata)
for the record, my code does not have 68 lines

採用された回答

John D'Errico
John D'Errico 2024 年 5 月 18 日
編集済み: John D'Errico 2024 年 5 月 18 日
(It is good you are using the tutorials.) But first, learn to read the error message, an important skill in using MATLAB, unless you will never generate errors. Clearly, I have that skill, as I have generated many of my own errors over the years. ;-)
The error happened in YOUR code at line 4.
Error in
experiment1 (line 4)
That happened, when you called scatter. The error was generated from line 68 of scatter, and scatter has at least 68 lines. That error was generated when scatter realized you had passed it something it did not understand.
And that tells us what matters here is what is in xdata, and in ydata. You do this:
xdata = exp_data.concentration;
ydata = exp_data.velocity;
Next, to learn what is actually in those variables, do this:
whos xdata ydata
Both of those variables must have class as listed here:
Input arguments must be numeric, datetime, duration, or categorical.
So look carefully at what you see. If not, then you will see an error. We don't know what you have in there.
Anyway, the immediate problem is not directly in the code you wrote, but in what you have in those variables. Well, there is a problem in the code, to the extent it is in how your code interacts with the data you have. Remember that code does not stand on its own, living in a complete vacuum. Your data matters.
  1 件のコメント
Kika
Kika 2024 年 5 月 20 日
Thank you so much it was so helpful!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by