|
Wow, that's pretty nasty. I guess you're going to have to step through the code (I think this is m-code; can't tell for sure). If this is in VBA-world; hit F8 multiple times. What happens? If this is in Matlab-world, hit F11 multiple times. What happens? Check the values of the variables. Every time you hit the appropriate Function key. Change some things, especially things you know will trigger an error. Be very mindful of the results.
Hope that helps.
"Mirage " <miragel@uvic.ca> wrote in message <k5p42s$a2$1@newscl01ah.mathworks.com>...
> I'm actually using VBA through Matlab... and I can't figure out if this is a Matlab or VBA problem so I'm posting on both threads. I'm using the following code:
>
> Type_Linear = -4132;
> Type_Poly = 3;
> % Type_Power = 4;
> % Type_Exp = 5;
>
> eC.SeriesCollection(1).Trendlines.Add(Type_Linear);
> eC.SeriesCollection(1).Trendlines(1).DisplayRSquared = 1;
> Lin_R_Squared = eC.SeriesCollection(1).Trendlines(1).DataLabel.Text
> eC.SeriesCollection(1).Trendlines(1).DisplayRSquared = 0;
> eC.SeriesCollection(1).Trendlines(1).DisplayEquation = 1;
> Lin_y_Eq = eC.SeriesCollection(1).Trendlines(1).DataLabel.Text
> eC.SeriesCollection(1).Trendlines(1).DisplayRSquared = 1;
> % eC.SeriesCollection(1).Trendlines(1).DisplayEquation = 0;
> Lin_R_squared_Cell = regexp(Lin_R_Squared,{'\d*[\.\d*]\d*[eE\d*][+-\d*]\d*','\d'},'match');
> Lin_y_Eq_Cell = regexp(Lin_y_Eq,'[=\s][+-=\s][\s-]\d*[\.]\d*[eE+-\d*]+','match');
>
> %Gets rid of the '=' in order to evaluate both positive and negtaive
> %numbers to turn them into integers rather than strings
> Temp = cell2mat(regexp(Lin_y_Eq_Cell{1},'[-\s]\d*\.\d*','match'));
> Lin_y_Eq_Cell{1} = Temp;
>
> eC.SeriesCollection(1).Trendlines.Add(Type_Poly,2);
> eC.SeriesCollection(1).Trendlines(2).DisplayRSquared = 1;
> Poly1_R_Squared = eC.SeriesCollection(1).Trendlines(2).DataLabel.text
> eC.SeriesCollection(1).Trendlines(2).DisplayRSquared = 0;
> eC.SeriesCollection(1).Trendlines(2).DisplayEquation = 1;
> Poly1_y_Eq = eC.SeriesCollection(1).Trendlines(2).DataLabel.text
> eC.SeriesCollection(1).Trendlines(2).DisplayEquation = 0;
> Poly1_R_squared_Cell = regexp(Poly1_R_Squared,{'\d*[\.\d*]\d*[eE\d*][+-\d*]\d*','\d'},'match');
> Poly1_y_Eq_Cell = regexp(Poly1_y_Eq,'[=\s][+-=\s][\s-]\d*[\.]\d*[eE+-\d*]+','match');
> if cell2mat(Poly1_R_squared_Cell{2}) == '1'
> Poly1_R_squared_Num = str2num(cell2mat(Poly1_R_squared_Cell{2}));
> else
> Poly1_R_squared_Num = str2num(cell2mat(Poly1_R_squared_Cell{1}));
> end
>
> Temp = cell2mat(regexp(Poly1_y_Eq_Cell{1},'[-\s]\d*\.\d*','match'));
> Poly1_y_Eq_Cell{1} = Temp;
>
> eC.SeriesCollection(1).Trendlines.Add(Type_Poly,3);
> eC.SeriesCollection(1).Trendlines(3).DisplayRSquared = 1;
> Poly2_R_Squared = eC.SeriesCollection(1).Trendlines(3).DataLabel.text
> eC.SeriesCollection(1).Trendlines(3).DisplayRSquared = 0;
> eC.SeriesCollection(1).Trendlines(3).DisplayEquation = 1;
> Poly2_y_Eq = eC.SeriesCollection(1).Trendlines(3).DataLabel.text
> eC.SeriesCollection(1).Trendlines(3).DisplayEquation = 0;
> Poly2_R_squared_Cell = regexp(Poly2_R_Squared,{'\d*[\.\d*]\d*[eE\d*][+-\d*]\d*','\d'},'match');
> Poly2_y_Eq_Cell = regexp(Poly2_y_Eq,'[=\s][+-=\s][\s-]\d*[\.]\d*[eE+-\d*]+','match');
> if cell2mat(Poly2_R_squared_Cell{2}) == '1'
> Poly2_R_squared_Num = str2num(cell2mat(Poly2_R_squared_Cell{2}));
> else
> Poly2_R_squared_Num = str2num(cell2mat(Poly2_R_squared_Cell{1}));
> end
>
> Temp = cell2mat(regexp(Poly2_y_Eq_Cell{1},'[-\s]\d*\.\d*','match'));
> Poly2_y_Eq_Cell{1} = Temp;
>
> This code is supposed to add three trendlines to a graph and pull out the string value for each trendline using datalabel.text. This code is actually in a function and run recursively in my main script, however, sometimes when I change certain variables, datalabel.text will return an empty string and I can't figure out why.
>
> Please let me know if you know why this is doing this!! Thanks.
|