Error with Set function when I am trying to change the Xlabel form a figure (Unable to use a value of type matlab.ui.Figure as an index.)
Mostra commenti meno recenti
I am getting an error in the Set function. I have been trying to solve the problem but havent been able to get through. In plamce of 'figure(1)', I also tried gca but it showed the same error. (Unable to use a value of type matlab.ui.Figure as an index.)Risposta accettata
Più risposte (2)
Steven Lord
il 11 Mar 2020
2 voti
Rename the variable you've created in your workspace named set.
You intended to call the set function included in MATLAB on the line "set(figure(1), 'XScale', 'linear', 'YScale', 'log')" but because the variable exists MATLAB interpreted that as an attempt to index into the variable. MATLAB doesn't know how to use a figure handle as an index into a variable so it throws an error.
You should also use a handle to an axes instead of a figure to set the XScale and YScale properties since those are axes properties not figure properties, as tmarske and Guillaume stated, but you need to remove the variable named set as well.
tmarske
il 11 Mar 2020
XScale and ySCale are properties of the axes, not the figure, so you need to pass an axes handle in as the first argument to set(). Try:
set(ax, 'XScale', 'linear', 'YScale', 'linear')
Categorie
Scopri di più su Subplots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!