Error message I don't understand

8 views (last 30 days)
John Figueroa
John Figueroa on 8 Jul 2022
Edited: Benjamin Kraus on 8 Jul 2022
When working an example application, I get the error message below when working with the prgram in the Live Editor mode:
"error using xline" and "must be a scalar"
which then points to the line below, which I have bolded, in the suppoting function: helperPlotStripmapMode, which is part of the program example of the Airborne SAR System Design under the Radar Applications of the Radar Toolbox.
xline(azres,'-.',{[num2str(round(azres)),' m']}); % Selected azimuth resolution
Can someone help me understand what this error means and how to correct it? It is preventing me from executing the remainder this learning exercise.
Thank you in advance.
John Figueroa

Answers (2)

Voss
Voss on 8 Jul 2022
I believe some older versions of MATLAB require the first argument to xline to be a scalar. To get around that, you can call xline multiple times in a for loop:
azres = [1 2];
for ii = 1:numel(azres)
xline(azres(ii),'-.',{[num2str(round(azres(ii))),' m']}); % Selected azimuth resolution
end
xlim([0 3])
However, looking over the example program you're following, it seems to me like azres is a scalar, so you should check that your code is the same as the example code.

Benjamin Kraus
Benjamin Kraus on 8 Jul 2022
I think that error message means that the first input to xline was an empty vector. Have you modified the example at all in a way that might make the first input to xline an empty vector?
  2 Comments
John Figueroa
John Figueroa on 8 Jul 2022
Yes Benjamin,
I did modify the example by changing the values of the required slant range and azimuth resolutions, the maximum unambiguous range, the proability of detection, velocity, and radar altitude in the design specifications section. Are those quantitative changes to those variables responsible for the error message? And is the first input to xline, that you reference, azres?
Thank you.
Benjamin Kraus
Benjamin Kraus on 8 Jul 2022
Edited: Benjamin Kraus on 8 Jul 2022
Yes, the first input to xline is azres. I don't know enough about the subject matter to know how your changes are impacting the value of azres, but if I had to guess your changes are causing azres to become empty, which is triggering this error message.
My suggestion would be to modify the call to xline in the helper function called helperPlotStripmapMode (at the bottom of the Live Script) to add a check for empty.
Basically, modify this one line:
xline(azres,'-.',{[num2str(round(azres)),' m']}); % Selected azimuth resolution
To look like this:
if ~isempty(azres)
xline(azres,'-.',{[num2str(round(azres)),' m']}); % Selected azimuth resolution
end
This will skip the call to xline if azres is empty.
You may need to make other adjustments to the helper function if you encounter other errors, but this should get you past this specific error message.

Sign in to comment.

Tags

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!