Unable to add xlabel to subplots with secondary axis

3 visualizaciones (últimos 30 días)
Abilash Subbaraman
Abilash Subbaraman el 14 de Abr. de 2018
Respondida: Ahmet Cecen el 14 de Abr. de 2018
I was trying to add xlabel to subplots with secondary axis but i kept getting errors.
figure
p = subplot(1,2,1);
plot (tmin,capex,'r-o');
xlabel(p,'\Delta T_{min}')
ylabel('Total Capital Cost ($)')
yyaxis right
plot(tmin,opex,'g-*');
legend ('Total Capital Cost','Utility Cost/s')
ylabel('Utility Cost ($/s)')
ax2 = subplot(1,2,2)
....
The error message is as follows.
Function 'subsindex' is not defined for values of class 'matlab.graphics.axis.Axes'.
Error in Untitled (line 44)
xlabel(p,'\Delta T_{min}')
But without the xlabel, the graph appears perfectly with the ylabels and legend

Respuestas (1)

Ahmet Cecen
Ahmet Cecen el 14 de Abr. de 2018
The only reason I can think of for this to happen is if you used the name "xlabel" somewhere else in the code. I can replicate the error like this:
xlabel = 6
p = subplot(1,2,1);
xlabel(p,'aa')
Make sure xlabel is not used as a variable name in your code.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by