Error when calling a previously made function in a separate script. Any ideas?

12 次查看(过去 30 天)
I keep getting an Error when calling a previously made function that was made in a separate script, even when it is on my path. This piece of code performs a multiple regression iterative search task with 3 parameters.
Here is the original function that gets called later(Both original function script and the other Script it is being called in are attached) I created the function that is being called myself.
Open each attachment separately and run iterative search script to see error.
  5 个评论
Walter Roberson
Walter Roberson 2018-4-25
The function needs White blood cell count as well as red blood cell count. It ignores all other table properties.
Reece Nasse
Reece Nasse 2018-4-25
So how should it look then? Are you referring to this line of code being changed or the original function? It may seem like a stupid question but I am new to using matlab and this is only the second piece of code ive ever written. Thanks.

请先登录,再进行评论。

采纳的回答

Ameer Hamza
Ameer Hamza 2018-4-25
The problem is caused by this line
WR = table(RedBloodCellCount,MeanWBCM30,'variablenames',{'RedBloodCellCount','MeanWBCM30'});% 2 previosly defined varibles are put into a table.
The function MultipleRegression require tables with field WhiteBloodCellCount and RedBloodCellCount, which the table WR does not contain. Change the 2nd variable name to WhiteBloodCellCount and it will give no syntax error.
WR = table(RedBloodCellCount,MeanWBCM30,'variablenames',{'RedBloodCellCount','WhiteBloodCellCount'});% 2 previosly defined varibles are put into a table.
*** "the following passage is just a suggestion based on observing your code, you may ignore it if you are sure about what you are doing."
It appears that you are making a logical mistake in your code. The new table WR contain the same value for WhiteBloodCellCount, so it might not be a good way to evaluate the performance of [Bestparams1, Bestparams2, Bestparams3]. It might be better to compare the parameters based on the original Data table as follow
Curve = MultipleRegression([Bestparams1,Bestparams2,Bestparams3], Data);
Also as I mentioned in Answer to your previous question, the line
SSD = A(:,3)-SimulatedY.^2; %calculate squared deviations at each data point in column 3 of data table (the row labelled IQ). Column 3 represents Y values.
is definitely wrong which is also indicated by your comment after the line. The correct is
SSD = (A(:,3)-SimulatedY).^2;
Hope this will help.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by