graph2d package cannot be found

15 Ansichten (letzte 30 Tage)
WY
WY am 25 Okt. 2014
Kommentiert: Star Strider am 25 Okt. 2014
Hi, I tried to plot horizontal lines using graph2d.constantline function. It worked well with R2014a, but not any more since I upgraded to R2014b. Matlab does not seem to find graph2d package:
hy = graph2d.constantline(0, 'LineStyle','-', 'Color','r'); changedependvar(hy,'y');
Undefined variable "graph2d" or class "graph2d.constantline".
I did have graph2d package installed. Is there a way to fix this problem? There is an answer about installing Matlab from a network drive. But I install my Matlab on my computer directly. Thanks.

Antworten (1)

Star Strider
Star Strider am 25 Okt. 2014
I didn’t realise it existed. (It was an undocumented function through R2014a, apparently, as referred to here.) It doesn’t exist in R2014b, gone with a lot of other graphics functionality that is no longer available in HG2. (That’s why I’m keeping R2014a and its more flexible graphics.)
It’s easy enough to plot a horizontal line. This plots one at y=5:
figure(1)
plot(-2:5, (-2:5).^2-1)
hold on
plot(xlim, [5 5]) % Plot Horizontal Line
hold off
  2 Kommentare
Star Strider
Star Strider am 25 Okt. 2014
WY’s Answer moved here...
Thanks. But graph2d does come with other packages of 2014b. It is usually located in /toolbox/matlab/graph2d. So my question was actually why Matlab does not recognize it. Maybe you are right. With the graphics upgrade in 2014b, this is probably no longer supported although it is installed.
graph2d.constantline is very convenient because you don't have to care about the limits of your axes.
Star Strider
Star Strider am 25 Okt. 2014
My pleasure!
You don’t have to care about the limits of your axes without it, if you use xlim (or ylim) to define them, as I did in my example. I simply defined the x-coordinates using xlim, and a two-element vector (here [5 5]) to plot it at the desired y-value. If for any reason xlim changes, the line’s x-coordinates automatically change as well.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by