MATLAB: Does PLOT3 crash when the X vector is an array and the Y and Z vectors are N-dimensional

crashdimensionsfigureMATLABmultipleplotr14

When I run the following code in MATLAB 7.0.1 (R14SP1):
x=[1:100];
y=[cos(x);sin(x)];
z=[tan(x);cot(x)];
plot3(x,y,z);
I get the following error:
------------------------------------------------------------------------
Segmentation violation detected at Tue Oct 12 11:43:26 2004
------------------------------------------------------------------------
Configuration:
MATLAB Version: 7.0.1.24704 (R14) Service Pack 1
MATLAB License:
Operating System: Microsoft Windows XP
Window System: Version 5.1 (Build 2600: Service Pack 1)
Processor ID: x86 Family 15 Model 2 Stepping 9, GenuineIntel
Virtual Machine: Java 1.4.2_04 with Sun Microsystems Inc. Java HotSpot(TM) Client VM
(mixed mode)
Default Charset: ibm-5348_P100-1997
Register State:
EAX = 20408f70 EBX = 20408b30
ECX = 00000000 EDX = 00000000
ESI = 20408b30 EDI = 203d7030
EBP = 00cde20c ESP = 00cde204
EIP = 78791885 FLG = 00010202
Stack Trace:
[0] libmx.dll:_mxGetDimensions(0x20408b30, 2048, 0x20408b30, 0x200d1a01 "ÊN ") + 21 bytes
[1] hg.dll:void __cdecl plot_rotate_input(struct mxArray_tag *,struct mxArray_tag *,struct mxArray_tag *,bool,struct ActionFlags_t *)(0x20408ef0, 0x014c8a01 "td@@@2@@Z", 0x200d1a80, 0x013231a0) + 157 bytes
[2] hg.dll:void __cdecl gsPlotv7Fcn(int,struct mxArray_tag * * const,int,int,struct mxArray_tag * * const)(0, 0x00cde6ac, 554, 3) + 924 bytes
[3] hg.dll:void __cdecl gsPlotFcnSwitch(bool,int,struct mxArray_tag * * const,int,int,struct mxArray_tag * * const)(1, 0, 0x00cde6ac, 554) + 264 bytes
[4] hg.dll:_hgPlot3(0, 0x00cde6ac, 3, 0x00cde70c) + 30 bytes
[5] m_dispatcher.dll:public: virtual void __thiscall Mfh_builtin<struct mxArray_tag>::dispatch_mf(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(0, 0x00cde6ac, 3, 0x00cde70c) + 55 bytes
<snip>

Best Answer

This bug has been fixed in Release 14 Service Pack 2 (R14SP2). For previous releases, please read below for any possible workarounds:
We have verified that there is a bug in MATLAB 7.0.1 (R14SP1) in the way that PLOT3 handles a single dimensional X with multi-dimensional Y and Z components. This problem has been fixed in MATLAB 7.0.4 (R14SP2). To work around this issue, make the X vector the same size as Y and Z when providing it to PLOT3.
For example, modify
x=[1:100];
y=[cos(x);sin(x)];
z=[tan(x);cot(x)];
plot3(x,y,z);
to be
x=[1:100];
y=[cos(x);sin(x)];
z=[tan(x);cot(x)];
plot3([x;x],y,z);