How is it possible to get a different result in the MatLab command window as compared to a stand alone application

10 views (last 30 days)
I am calculating some basic attributes of coils. The first and easiest example is area. I know the length and width of a piece of steel. When I compute this in the MatLab command window I see my answer either by stopping on that line of code or by not using the ; at the end of the line doing the calculation.
Once I compile my code and process the same steel strip, I get 0.0 as my answer!
function UnitCoilSumm(coilName,coilType)
I initialize the array (a 1x1) in the beginning of my code:
coilArea = zeros(1,1);
I calculate the value:
coilArea = coilLength * stripWidthSpec; %length in meters, width in meters for metric
I then store or want to see my value:
csvRecord(109) = coilArea(1,1); %round(coilArea); %csvRecord(109)
coilArea(1,1)
end%funtion
How can I get help with this?
Bob Jones

Answers (2)

Walter Roberson
Walter Roberson on 14 Nov 2012
This can happen in cases where variables are "poofed" into existence, and I suspect it can happen if the datatype of a variable is magically changed.
In your routines, do you call upon any scripts (not functions)?
When you wrote your code, did you insert an "end" to match each "function"? Doing so would result in interactive MATLAB more closely matching the behavior of compiled code.
  3 Comments
Walter Roberson
Walter Roberson on 14 Nov 2012
Edited: Walter Roberson on 14 Nov 2012
The .mat file probably won't help, but the source to the full function might. Also, please indicate class() of any variable being load()'d or passed in.
Ah, one thing to check: are you aware that input arguments to the main routine of an executable are always received as strings? So the 2 would have to be str2double() to make it the numeric value 2 rather than the string '2' (numeric value 50) ?

Sign in to comment.


Robert Jones
Robert Jones on 14 Nov 2012
BINGO!
I converted the input var coilType from str2double and she runs! Thanks!!
bob

Products

Community Treasure Hunt

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

Start Hunting!