MATLAB Answers

Error using plot Not enough input arguments.

43 views (last 30 days)
Zaime Ali
Zaime Ali on 27 Sep 2020
Commented: Star Strider on 27 Sep 2020
I'm having an issue when plotting recall vs precision
In my code i want to plot a graph to check my faster rcnn accuracy.
My code is below
overlap = 0.5;
[ap, recall, precision] = evaluateDetectionPrecision(resultsDoc, gTestTruth.LabelData(2, :), overlap);
plot(recall, precision);
grid on
title(sprintf('Average precision = %.1f', ap))
In precision variable i have a value
4×1 cell array
{3×1 double}
{[ 1]}
{[ 1]}
{2×1 double}
In recall variable i have a value
4×1 cell array
{3×1 double}
{[ 0]}
{[ 0]}
{2×1 double}
Now i don't know what to do

Answers (2)

the cyclist
the cyclist on 27 Sep 2020
If you take a look at the documentation for the plot function, you will see that it cannot take cell arrays as input.
I'm not exactly sure what you are trying to plot, but maybe you need to pull out the contents of the cell array to plot? Possibly something like
the cyclist
the cyclist on 27 Sep 2020
To be clear, all I was really trying to do was point out that you were using MATLAB syntax incorrectly. You did not post enough information to do much more than that.
I strongly suggest you do more than just "try a solution" posted here. You need to
  • think carefully about what you want your code to do conceptually -- in your case, plotting the accuracy
  • learn/understand the MATLAB functions that can accomplish that
  • form your data into the proper form of input for those functions
  • repeat the above if you do not get what you expect
We can help with some of that, but it is really important for to think about our suggestions, and understand how they help solve your problem.

Sign in to comment.

Star Strider
Star Strider on 27 Sep 2020
You may need to use the cell2mat function, or concatenate the elements inside a vector, using this (strange-looking but effective) notation:
plot([recall{:}], [precision{:}])
Star Strider
Star Strider on 27 Sep 2020
Use the other option, cell2mat instead:
recallv = cell2mat(recall);
precisionv = cell2mat(precision);
When I tested them with:
recall = {rand(3,1); 1; 1; rand(2,1)};
precision = {rand(3,1); 0; 0; rand(2,1)};
cell2mat worked correctly.
plot(recallv, precisionv)
title(sprintf('Average precision = %.1f', ap))
should produce the plot you want.
That plots correctly for me. It is plotting a horizontal line, look at the result of the cell2mat output. That is likely what your data actually are, such that ‘precision’ is essentially a constant for all values of ‘recall’. I do not have your data, so I cannot determine that.

Sign in to comment.




Community Treasure Hunt

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

Start Hunting!

Translated by