Reputation: 2897
I am using the following code to read from a file in MATLAB .
A=textread('A.txt');
B=textread('B.txt');
F=textread('F.txt');
LB=textread('LB.txt');
options = optimset('LargeScale','off','Simplex','on');
disp('Main Solution')
[X,fval,exitflag,output,lambda] = linprog(-F,A,B,[],[],LB,[],[],options);
-fval
exitflag
output
The actual data in the file is as following like the image :
But MATLAB reads this as like follows :
Why ? Is there any problem ? First data is 1674.25 but MATLAB reads it as like 0.1665 . WHy ?
Upvotes: 0
Views: 118
Reputation:
If you'll look closely, you will see that F is displayed like
1.0e+004 *
...
...
which means that all the values in the columns are actually multiplied by a 10000 factor. Thus 0.1665 * 10000 = 1665 which is approx 1674.25.
NB1: Mathworks recommends textscan()
instead of textread()
;
NB2: For immediate feedback from the console about a problem, try the standard command why
in command window.
Upvotes: 2
Reputation: 3914
It is reading the file correctly. What you're seeing is only a display issue. Notice the 1.0e+004 *
at the top of the listing. Try typing 'format longg' and then look at the values, or else just type F(1)
to look at the first value.
Upvotes: 1