From: Priyanshu Agarwal on 7 Aug 2010 16:48 Hi, I'm trying to add legends to a plot using a dynamically assigned string array that is being updated in every iteration based on certain condition. However, I see an erratic behavior while using legend. Sometimes it runs successfully without any error (even when a varieties of legends are present in different plots i.e. only one legend, multiple legends). However, sometimes the same program throws the following error: ??? Error using ==> legend>process_inputs at 575 Invalid argument. Type 'help legend' for more information. Error in ==> legend>make_legend at 334 [orient,location,position,children,listen,strings,propargs] = process_inputs(ha,argin); Error in ==> legend at 290 [h,msg] = make_legend(ha,varargin(arg:end)); The following is the use of legend function in my code: for j = 1:1:size(myMembers,2) lh(j) = plot(x(:,j),[cVec(j) '-']); if(myMembers(j)>0 & myMembers(j)<=nptlth) lstr{j} = ['Left Thigh' num2str(j)] elseif(myMembers(j)>nptlth & myMembers(j)<=nptlth+nptll) lstr{j} = ['Left Leg (Lower)' num2str(myMembers(j)-5)] elseif(myMembers(j)>nptlth+nptll & myMembers(j)<=nptlth+nptll+nptrth) lstr{j} = ['Right Thigh' num2str(myMembers(j)-10)] elseif(myMembers(j)>nptlth+nptll+nptrth & myMembers(j)<=nptlth+nptll+nptrth+nptrl) lstr{j} = ['Right Leg (Lower)' num2str(myMembers(j)-15)] end end legend(lh,'String',lstr,'Location','BestOutside','Orientation','Vertical'); Here lh is the array containing the plot values and lstr is the dynamically assigned string array. While I got the above error lstr was lstr = 'Left Thigh1' 'Left Thigh2' 'Left Thigh3' 'Left Thigh4' 'Left Thigh5' What might be the problem? Regards, Priyanshu
From: Greg Heath on 7 Aug 2010 17:05 On Aug 7, 4:48 pm, "Priyanshu Agarwal" <mail2priyan...(a)gmail.com> wrote: > Hi, > > I'm trying to add legends to a plot using a dynamically assigned string array that is being updated in every iteration based on certain condition. However, I see an erratic behavior while using legend. Sometimes it runs successfully without any error (even when a varieties of legends are present in different plots i.e. only one legend, multiple legends). However, sometimes the same program throws the following error: > > ??? Error using ==> legend>process_inputs at 575 > Invalid argument. Type 'help legend' for more information. > > Error in ==> legend>make_legend at 334 > [orient,location,position,children,listen,strings,propargs] = process_inputs(ha,argin); > > Error in ==> legend at 290 > [h,msg] = make_legend(ha,varargin(arg:end)); > > The following is the use of legend function in my code: > > for j = 1:1:size(myMembers,2) > lh(j) = plot(x(:,j),[cVec(j) '-']); > if(myMembers(j)>0 & myMembers(j)<=nptlth) > lstr{j} = ['Left Thigh' num2str(j)] > elseif(myMembers(j)>nptlth & myMembers(j)<=nptlth+nptll) > lstr{j} = ['Left Leg (Lower)' num2str(myMembers(j)-5)] > elseif(myMembers(j)>nptlth+nptll & myMembers(j)<=nptlth+nptll+nptrth) > lstr{j} = ['Right Thigh' num2str(myMembers(j)-10)] > elseif(myMembers(j)>nptlth+nptll+nptrth & myMembers(j)<=nptlth+nptll+nptrth+nptrl) > lstr{j} = ['Right Leg (Lower)' num2str(myMembers(j)-15)] > end > end > legend(lh,'String',lstr,'Location','BestOutside','Orientation','Vertical'); > > Here lh is the array containing the plot values and lstr is the dynamically assigned string array. While I got the above error lstr was > lstr = 'Left Thigh1' 'Left Thigh2' 'Left Thigh3' 'Left Thigh4' 'Left Thigh5' > > What might be the problem? I don't know. However, I would try lstr = ['Left Thigh1','Left Thigh2','Left Thigh3','Left Thigh4',... 'Left Thigh5'] Hope this helps. Greg
From: Priyanshu Agarwal on 7 Aug 2010 20:11 Greg Heath <heath(a)alumni.brown.edu> wrote in message <4d0aa610-996a-4d4b-94a6-e26c38f16aea(a)x21g2000yqa.googlegroups.com>... > On Aug 7, 4:48 pm, "Priyanshu Agarwal" <mail2priyan...(a)gmail.com> > wrote: > > Hi, > > > > I'm trying to add legends to a plot using a dynamically assigned string array that is being updated in every iteration based on certain condition. However, I see an erratic behavior while using legend. Sometimes it runs successfully without any error (even when a varieties of legends are present in different plots i.e. only one legend, multiple legends). However, sometimes the same program throws the following error: > > > > ??? Error using ==> legend>process_inputs at 575 > > Invalid argument. Type 'help legend' for more information. > > > > Error in ==> legend>make_legend at 334 > > [orient,location,position,children,listen,strings,propargs] = process_inputs(ha,argin); > > > > Error in ==> legend at 290 > > [h,msg] = make_legend(ha,varargin(arg:end)); > > > > The following is the use of legend function in my code: > > > > for j = 1:1:size(myMembers,2) > > lh(j) = plot(x(:,j),[cVec(j) '-']); > > if(myMembers(j)>0 & myMembers(j)<=nptlth) > > lstr{j} = ['Left Thigh' num2str(j)] > > elseif(myMembers(j)>nptlth & myMembers(j)<=nptlth+nptll) > > lstr{j} = ['Left Leg (Lower)' num2str(myMembers(j)-5)] > > elseif(myMembers(j)>nptlth+nptll & myMembers(j)<=nptlth+nptll+nptrth) > > lstr{j} = ['Right Thigh' num2str(myMembers(j)-10)] > > elseif(myMembers(j)>nptlth+nptll+nptrth & myMembers(j)<=nptlth+nptll+nptrth+nptrl) > > lstr{j} = ['Right Leg (Lower)' num2str(myMembers(j)-15)] > > end > > end > > legend(lh,'String',lstr,'Location','BestOutside','Orientation','Vertical'); > > > > Here lh is the array containing the plot values and lstr is the dynamically assigned string array. While I got the above error lstr was > > lstr = 'Left Thigh1' 'Left Thigh2' 'Left Thigh3' 'Left Thigh4' 'Left Thigh5' > > > > What might be the problem? > > I don't know. However, I would try > > lstr = ['Left Thigh1','Left Thigh2','Left Thigh3','Left Thigh4',... > 'Left Thigh5'] > > Hope this helps. > > Greg Hi Greg, Directly assigning lstr results in labeling just one of the legend with all the strings. Also, I do have a beforehand knowledge of the string that would form my legends because of which I need to use a dynamically assigned array. Is it a bug in the legend function. Regards, Priyanshu
From: Steven_Lord on 8 Aug 2010 21:30 "Priyanshu Agarwal" <mail2priyanshu(a)gmail.com> wrote in message news:i3kgq4$h26$1(a)fred.mathworks.com... > Hi, > > I'm trying to add legends to a plot using a dynamically assigned string > array that is being updated in every iteration based on certain condition. > However, I see an erratic behavior while using legend. Sometimes it runs > successfully without any error (even when a varieties of legends are > present in different plots i.e. only one legend, multiple legends). > However, sometimes the same program throws the following error: > > > ??? Error using ==> legend>process_inputs at 575 > Invalid argument. Type 'help legend' for more information. > > Error in ==> legend>make_legend at 334 > [orient,location,position,children,listen,strings,propargs] = > process_inputs(ha,argin); > > Error in ==> legend at 290 > [h,msg] = make_legend(ha,varargin(arg:end)); Set an error breakpoint then run your code. When you break at the breakpoint, use DBUP to enter the workspace of the function from which you call LEGEND and look at the contents, types, and sizes of the inputs you pass into LEGEND. If that doesn't allow you to identify the cause of the error, post the contents/types/sizes here and/or send your code to Technical Support for investigation. The documentation that describes how to set error breakpoints is located here: http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_env/brqxeeu-175.html#brqxeeu-242 -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
|
Pages: 1 Prev: DLL Header Next: An exact simplification challenge - 104 (EllipticF, Log) |