MATLAB Answers

While plotting, how to Convert YYaxis left via some formula and display it on YYAxis right...(Using R2020a)

1 view (last 30 days)
i have imported a file that contains data "Range" and "dBsm" and plotted it....My dBsm data is on YYaxis 'left' now i wish that i should convert the dBsm data to metersquare via formula (10.^(dBsm/10) and display it on YYaxis 'Right'....so given below values should be shown as i mentioned in second plot which required...
40 >> 10,000
20 >> 100
0 >> 1
-20 >> 0.001
-40 >> 0.0001
The first plot is my output achieved and second plot shows the desired output
actually i m using ylim[ymin ymax] and assign
ymin = min(dBsm)
ymax = max(sBsm)
so the minimum and maximam value on yyaxis right are showing right but inbetween value r wrong... because "ylim" increases linearly from minimum to maximam... So thats not the rightway. instead of using Ylim i also simply converted my data via formula and used yyaxis 'right' but same results... . kindly guide how i should achieve the desired results shown in below graph.. if i again summarize my question.. i want that left yaxis should reflect on yaxis right by user given formula...i viewed all documentation of "YYAxis" but all examples shows linear increase of axis. Thanks

Accepted Answer

Cris LaPierre
Cris LaPierre on 3 Dec 2020
The YTick location and label are separate properites, though by default are the same value. I would probably try to do this by changing the YTickLabels on the right axis (but not the YTick location/values).
I'd modify your PlotDataButtonPushed callback to this.
function PlotDataButtonPushed(app, event)
yyaxis(app.UIAxes,"left");
xlabel(app.UIAxes,'Range')
ylabel(app.UIAxes,'dBsm')
title(app.UIAxes,'dBsm Vs Meter-Sqaure Graph')
plot(app.UIAxes,app.b,app.c)
ymin = min(app.c);
ymax = max(app.c);
ylim(app.UIAxes,[ymin ymax]);
yyaxis(app.UIAxes,"right");
ylabel(app.UIAxes,'Meter Square')
ylim(app.UIAxes,[ymin ymax]);
app.UIAxes.YAxis(2).TickLabels = 10.^(str2double(app.UIAxes.YAxis(1).TickLabels)/10);
end
  4 Comments

Sign in to comment.

More Answers (0)

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!