Error using plot Not enough input arguments.

조회 수: 77 (최근 30일)
Zaime Ali
Zaime Ali 2020년 9월 27일
댓글: Star Strider 2020년 9월 27일
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);
figure;
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

답변 (2개)

Star Strider
Star Strider 2020년 9월 27일
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{:}])
.
  댓글 수: 2
Zaime Ali
Zaime Ali 2020년 9월 27일
when using cell2mat function, it is plotting the horizontal line on y-index
Star Strider
Star Strider 2020년 9월 27일
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.
Then:
figure
plot(recallv, precisionv)
grid
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.

댓글을 달려면 로그인하십시오.


the cyclist
the cyclist 2020년 9월 27일
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
plot(recall{1},precision{1})
  댓글 수: 3
Zaime Ali
Zaime Ali 2020년 9월 27일
I have also tried your solution but it's giving me a straight line now
the cyclist
the cyclist 2020년 9월 27일
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.

댓글을 달려면 로그인하십시오.

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by