possible parameter division rounding error?

1 次查看(过去 30 天)
Hi, I have a large set of parameters and about half of them I define by dividing by some experimental value, like so:
kd=.06;c2=.01;
c1=c2/kd;
However, this seems to result in some errors. These parameters in particular act as a kind of switch, and the output looks like they are at zero. If I manually define c1=.17, then I see the expected output.
Is this possibly some rounding error Matlab is making, or do I have some error in passing the values?
I'm attaching my graphing + ode file. Thanks!
  2 个评论
John D'Errico
John D'Errico 2015-3-4
No. MATLAB is not making a rounding error, and will certainly not do this only sometimes. But we really do not know exactly what you have done here, as you say it results in "some" errors. Either it gives an unexpected result or it does not. Please show what you actually did that gave you a result you did not expect.
You may be stuffing the result into an integer variable. Or, possibly you are doing a divide between vectors, and do not realize that you need to be using ./ and not / as the operator.
Renee
Renee 2015-3-4
By "some errors" I mean unexpected output, yes (caused by several parameter issues). I attached the relevant files. All my parameters are of type double, and in my ODE file I use the vector operator.

请先登录,再进行评论。

回答(1 个)

per isakson
per isakson 2015-3-4
编辑:per isakson 2015-3-4
I downloaded your files. What am I supposed to do next? I run graph
>> graph
Undefined function or variable 'tdata'.
Error in graph (line 55)
plot(tdata, ydata,'*',t, X(:,11),'+')
and got an error, which doesn't resemble your description of the problem. Next I set stop on error
&nbsp
and run graph again
&nbsp
the execution halted at plot and I confirmed that tdata and ydata were not defined at that point in the code. More guessing: I removed these to variable from plot
&nbsp
and run graph again
&nbsp
to me the result looks fine

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by