Error message I don't understand
4 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(2 个)
Voss
2022-7-8
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.
0 个评论
Benjamin Kraus
2022-7-8
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 个评论
Benjamin Kraus
2022-7-8
编辑:Benjamin Kraus
2022-7-8
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!