I am having a really weird problem that I cant find a reason. After a lot of calculation I was getting a wrong value for a variable, so I debbuged to find where was the problem, and I found a simple division mistake. A double h=0.0030 and another double hh=1/h .
Of course hh is suposed to be 333.3333 but I am getting hh=333.8898
Here is the piece of code:
Tales wrote:
...
> I am having a really weird problem that I cant find a reason. After a
> lot of calculation I was getting a wrong value for a variable, so I
> debbuged to find where was the problem, and I found a simple division
> mistake. A double h=0.0030 and another double hh=1/h .
> Of course hh is suposed to be 333.3333 but I am getting hh=333.8898
> Here is the piece of code:
>
> h=str2double(cell2mat(raw(nameLinNum,densColumn)));
> hh=1/h;
>
> Does anyone hava an idea on how to fix it???
...
Undoutedly h _isn't_ 0.00300000... but closer to 0.002995...
Try
disp(h-0.0030)
during a debugging session and see what is returned.
Why that is isn't determinable from the data provided but delving into
where the underlying data come from and how they're processed will
surely uncover same.
--
Tags for this Thread
Add a New Tag:
Separated by commas
Ex.: root locus, bode
What are tags?
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Terms prior to use.