Import archive .txt and the values are wrong when import
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Cristian camilo García Castaño
el 13 de Mayo de 2020
Comentada: Cristian camilo García Castaño
el 13 de Mayo de 2020
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 comentarios
Rik
el 13 de Mayo de 2020
I can't reproduce your problem with this code. What release are you using?
Respuesta aceptada
Walter Roberson
el 13 de Mayo de 2020
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 comentarios
Walter Roberson
el 13 de Mayo de 2020
>> 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,:)
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!