Plots are stuck on semi-log axis
조회 수: 5 (최근 30일)
이전 댓글 표시
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'
plot(app.UIAxes2,fra_fvec(1:i_fra),mg21(1:i_fra),'rx');
plot(app.UIAxes3,fra_fvec(1:i_fra),ph21(1:i_fra),'rx');
case 'Logarithmic'
semilogx(app.UIAxes2,fra_fvec(1:i_fra),mg21(1:i_fra),'ro');
semilogx(app.UIAxes3,fra_fvec(1:i_fra),ph21(1:i_fra),'ro');
end
댓글 수: 0
채택된 답변
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
Image Analyst
2021년 1월 8일
If the string is Linear and goes into the Log case, you might try casting everything to lower,
% Plot results
switch lower(app.FrequencyAxisSwitch.Value)
case 'linear'
plot(app.UIAxes2,fra_fvec(1:i_fra),mg21(1:i_fra),'rx');
plot(app.UIAxes3,fra_fvec(1:i_fra),ph21(1:i_fra),'rx');
case 'logarithmic'
semilogx(app.UIAxes2,fra_fvec(1:i_fra),mg21(1:i_fra),'ro');
semilogx(app.UIAxes3,fra_fvec(1:i_fra),ph21(1:i_fra),'ro');
end
or else use contains()
% Plot results
if contains(app.FrequencyAxisSwitch.Value, 'Linear', 'IgnoreCase', true)
plot(app.UIAxes2,fra_fvec(1:i_fra),mg21(1:i_fra),'rx');
plot(app.UIAxes3,fra_fvec(1:i_fra),ph21(1:i_fra),'rx');
else
semilogx(app.UIAxes2,fra_fvec(1:i_fra),mg21(1:i_fra),'ro');
semilogx(app.UIAxes3,fra_fvec(1:i_fra),ph21(1:i_fra),'ro');
end
If before those you put
whos app.FrequencyAxisSwitch.Value
what does it show in the command window? I want to make sure it's a character array, and not a number or something.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!