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

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

 Respuesta aceptada

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 comentarios

Thanks Alot Cris... its Exactly Working according to my Requirement i was trying it from many days but Fails.... You especially took interest to edit my Code.. i m Glad and once again more than Thanks..
Hello... Dear Cris i feel annoying interuppting you again... My Previous Question regarding YYAxis is answered at top level of Satisfaction.very Glad.. Now i m doing the same thing with simple code instead of app.UIAxes... Now when i studied the help it come to my knowledge that properties for UIAxes and uifigure are different... so i read all documentation of YTICK & YTickLabels and tried the same code and tryed to intergrate YTickLabels and YYaxis, tried too much but not succeded... last line giving error... if u can Guide me Further. Thanks
a = 0:1:10;
b = [3 1 5 3 7 9 6 2 8 4 1];
plot(a,b)
yyaxis("left");
xlabel('Range')
ylabel('dBsm')
title('dBsm Vs Meter-Sqaure Graph')
ymin = min(b);
ymax = max(b);
ylim([ymin ymax]);
yyaxis("right");
ylabel('Meter Square')
ylim([ymin ymax]);
yticklabels.yyaxis("right")= 10.^(str2double(yticklabels.yyaxis("left"))/10);
%%% YAxis(2).TickLabels = 10.^(str2double(YAxis(1).TickLabels)/10);
%%% YTick(1). yticklabels = 10.^(str2double(YTick(1).yticklabels)/10);
True, but the overall approach is the same. The problem you have is that you do not have a handles object to reference when switching between left and right axes. App designer automatically creates one for you, but in a script, you'll have to create your own variable for this.
You only really need this for setting the yticklabels, but to be consistent with what I shared above, I use it everywhere.
a = 0:1:10;
b = [3 1 5 3 7 9 6 2 8 4 1];
ax = axes;
yyaxis(ax,"left");
xlabel(ax,'Range')
ylabel(ax,'dBsm')
title(ax,'dBsm Vs Meter-Sqaure Graph')
ymin = min(b);
ymax = max(b);
ylim(ax,[ymin ymax]);
plot(ax,a,b)
yyaxis(ax,"right");
ylabel(ax,'Meter Square')
ylim(ax,[ymin ymax]);
ax.YAxis(2).TickLabels = 10.^(str2double(ax.YAxis(1).TickLabels)/10);
Thanks Alot... Works fine.. Really Appreciate ur Cooperation and Support..

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Object Properties en Centro de ayuda y File Exchange.

Productos

Versión

R2020a

Preguntada:

el 2 de Dic. de 2020

Comentada:

el 25 de Feb. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by