Import archive .txt and the values are wrong when import

Hello!
I am new in matlab I guess this code are so simple, but I don't understand what is wrong with them, when I call the .txt file and call the Permeability matrix don't show the same values (picture in bottom). But the plot are corret. The problem whit this is when I want to find values when the plot are flat the program gave me the values from .txt and that values are wrong. I dont know what is my mistake?
Thanks for all, I hope understand me
This is my code:
close all;
clearvars;
clc;
%% import data for permeability
Permeability = importdata('Permeabilidad1.txt');
%% Plot for presure
Pet = Permeability(:,1); %%Call measure of time
Pre = Permeability(:,2); %% Call measure of presure
Pet3 = (Pet - (43767.399))*1000
figure (1)
plot(Pet3, Pre, '-r');
title('Medida de presi?n en funci?n del tiempo')
legend('Oil recovery oil-wet','Location', 'southeast')
xlabel('Tiempo')
ylabel('Presi?n')
xlim([0 8])
%ylim([0 0.9])
%grid on
%% whan to know the mean of the values when the plot are flat
PetX = 24.7 < Pet < 35.21;
Pet(PetX);
PromPetX = mean(Pet(PetX));
PetY = 235.9 < Pre < 235;
Pre(PetY);
PromPetY = mean(Pre(PetY));

4 Comments

Can you attach the data that results in this? You may need to put it in a zip file first.
I attach a .txt file in the top called permeabilidad1.txt is that data?
I can't reproduce your problem with this code. What release are you using?

Sign in to comment.

 Accepted Answer

PetX = 24.7 < Pet < 35.21;
In MATLAB, that means the same as
PetX = ((24.7 < Pet) < 35.21);
The first part compars 24.7 to Pet, returning 0 (false) or 1 (true) in each case. Then that 0 or 1 is compared to 35.21, and since 0 and 1 are both < 35.21 everything is considered to match.
You need
PetX = 24.7 < Pet & Pet < 35.21;
Also, you output so many values that part of the output scrolls off the screen -- about 186 lines or so have scrolled off. And because it scrolled off, you also would not notice the initial
ans =
1.0e+04 *
before the values. The values will look less wildly strange if you use
format long g
before you display them.
%% import data for permeability
Permeability = importdata('Permeabilidad1.txt');
%% Plot for presure
Pet = Permeability(:,1); %%Call measure of time
Pre = Permeability(:,2); %% Call measure of presure
Pet3 = (Pet - (43767.399))*1000;
figure (1)
plot(Pet3, Pre, '-r');
title('Medida de presi?n en funci?n del tiempo')
legend('Oil recovery oil-wet','Location', 'southeast')
xlabel('Tiempo')
ylabel('Presi?n')
xlim([0 8])
%ylim([0 0.9])
%grid on
%% whan to know the mean of the values when the plot are flat
PetX = 24.7 < Pet & Pet < 35.21;
Pet(PetX);
PromPetX = mean(Pet(PetX));
PetY = 235.9 < Pre & Pre < 235;
Pre(PetY);
PromPetY = mean(Pre(PetY));
PromPetX
PromPetY

3 Comments

:) Thanks in that part of the code I understand my mistake! now I have nice value. otherside, you know what is the reason of the discrepance between the values from the .txt and the values in the comand window? the values in the comand window are when I put Permeability and press enter.
That values should be are the same?
>> size(Permeability)
ans =
13415 4
Preferences -> Command Window -> Display -<> Nubmer of lines in command window scroll buffer: 5000
So all but the last 5000 entries would scroll off the display. You could increase the preference to 15000 to be able to scroll back to see them all. For that matrix. Until the time when you want to display all rows of a matrix with 20000 rows...
I would suggest it would make more sense to examine pieces of the variable such as
Permeability(1:200,:)
You are Rigth! Thanks soo much! now it's more clear for me. I can see the values . Thanks :) i

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!