Plots are stuck on semi-log axis

조회 수: 4(최근 30일)
Pat Gipper
Pat Gipper 2021년 1월 7일
댓글: Pat Gipper 2021년 1월 8일
I have created an app that plots on UIAxes either with a plot command or semilogx command depending on a switch value. But once I have plotted with semilogx I am unable to revert to a linear x axis with subsequent executions of the code. The code snippet is shown below. The pasted image shows a bode response with points displayed with the red "x" called out in the regular plot command as opposed to the red "o" used in the semilogx command. I had set a breakpoint in the code and it clearly stopped in the 'Linear' case for every one of these plots. Why doesn't plot result in a linear x-axis?
% Plot results
switch app.FrequencyAxisSwitch.Value
case 'Linear'
case 'Logarithmic'

채택된 답변

Image Analyst
Image Analyst 2021년 1월 7일
I'm not sure you're going into the case you think you are, especially since the code for ylabel is not there so I can't tell which case you did. How/where are you setting the ylabel?
If you put a break point there at the switch, are you sure you're stepping into the linear one and doing the regular plot() call? What happens if you do this before the switch?
cla reset
  댓글 수: 3
Pat Gipper
Pat Gipper 2021년 1월 8일
Bingo! We have a winner. Your original suggestion to use cla worked, but it is a little more complicated with handles. The plot and semilogx commands were in a loop in a section of code that is entered as a result of a callback from a pushbutton. I just needed to clear the axes prior to the loop. I did need to re-apply the label to the axes. Here is the code snippet with your suggestion.
cla(app.UIAxes2,'reset');% Answer 711488 "Image Analyst" suggestion
xlabel(app.UIAxes2, 'Frequency - [Hz]')
cla(app.UIAxes3,'reset');% Answer 711488 "Image Analyst" suggestion
xlabel(app.UIAxes3, 'Frequency - [Hz]')
switch app.OutputStyleSwitch.Value
case 'Real/Imaginary'
case 'Magn(dB)/Phase(Deg)'
ylabel(app.UIAxes2,'Magnitude - [dB]')
ylabel(app.UIAxes3,'Phase - [Deg]')

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

추가 답변(0개)




Community Treasure Hunt

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

Start Hunting!

Translated by