I am trying to plot frequency-wavenumber from Das strain data. Error is found when I use imagesc to get the graph.
Error using image
Image XData and YData must be vectors.
Error in imagesc (line 52)
hh = image(varargin{:}, 'CDataMapping', 'scaled');
Error in a6 (line 52)
imagesc(k,f,abs(st));
The Matlab script is given below. Any help would be appreciated.
Dasdata_folder = 'C:\Users\dan24\Documents\MATLAB\Flow Loop Fiber Strain Readings\DAS Data\2.5 Lpm Step Test for 2 inch pipe with 0 insulation/';
testName = '2.5 Lpm';
file_start = [];
plot_title = '2.5 Lpm flow';
save_plot = true; %saves plots as png files if true
channels = 55:67; %define specific channels you want plots of
folder_path = [Dasdata_folder testName '/'];
figure_save_name = [testName '_' file_start];
Dasdata = ReadDasLogV4(folder_path, file_start);
Fs = 15625; %sampling frequency
i = 1:length(channels);
y = Dasdata.Strain(channels(i),:);
L = length(y); data=abs(y/L);
T=Dasdata.Time(channels);
dt=T(2:end)-T(1:end-1);
Nt=length(T);
X=Dasdata.Position(channels);
dx=X(2:end)-X(1:end-1);
Nx=length(X);
fn=1./2./dt;
kn=1./2./dx;
df=1./Nt./dt;
dk=1./Nx./dx;
f=[-fliplr(1:(Nt/2)) 0 (1:(Nt/2-1))].*df;
k=[-fliplr(1:(Nx/2)) 0 (1:(Nx/2-1))].*dk;
st=fftshift(fft2(data))./Nx./Nt;
figure(1);
%xticks = get(gca,'XTick')/Fs;
%for i = 1:length(xticks)
% xticklabels{i} = num2str(xticks(i),3);
%end
%set(gca,'XTickLabels',xticklabels);
imagesc(k,f,abs(st));
colorbar;
%title('FFT2');
%xlabel('k (1/m)')
%ylabel('f (Hz)')
%spec=st.*conj(st)./df./dk;
%figure(2)
%imagesc(f,k,log10(spec)); axis xy
%colormap(jet)
%shg
%xlabel('k (1/m)')
%ylabel('f (Hz)')

1 commentaire

Image Analyst
Image Analyst le 15 Oct 2021
You forgot to attach any data or the ReadDasLogV4() function:
Unrecognized function or variable 'ReadDasLogV4'.
Error in test8 (line 16)
Dasdata = ReadDasLogV4(folder_path, file_start);
We'll check back later for it. In the meantime, check very carefully the three inputs your sending to imagesc() and validate that it can take those types of arguments.

Connectez-vous pour commenter.

 Réponse acceptée

Walter Roberson
Walter Roberson le 16 Oct 2021

0 votes

T=Dasdata.Time(channels);
Your T is a column vector.
dt=T(2:end)-T(1:end-1);
That makes dt a column vector, because indexing a column vector with a vector index returns a column vector no matter whether the index itself is row or column.
Nt=length(T);
Scalar.
df=1./Nt./dt;
Nt is scalar, 1./Nt is scalar. dt is column vector, scalar ./ column vector gives column vector.
f=[-fliplr(1:(Nt/2)) 0 (1:(Nt/2-1))].*df;
1:(Nt/2) is a row vector. fliplr() of a row vector is a row vector. 1:(Nt/2-1) is a row vector. [row vector, 0, row vector] gives a row vector.
Then you .* the row vector with a column vector. Implicit expansion is used, and you get a result which is length() of the column vector, by length() of the row vector -- a 2D array.
You then try to pass in f as the YData parameter to imagesc(), but the YData parameter to imagesc() must be one of:
  1. Empty
  2. A scalar
  3. A vector with two or more elements. In this case, the first and last entries are used and the rest are ignored
Your 2D array is not empty or a scalar or a vector with two elements, so you are given an error message.
You have the same problem with construction of k: it will be a 2D array as well, for the same reason: you are combining row vectors and column vectors with implicit expansion.
Easiest fix:
T = Dasdata.Time(channels) .';
X = Dasdata.Position(channels) .';

6 commentaires

Iffat Arisa
Iffat Arisa le 18 Oct 2021
Thanks for your help. I fixed T and X and run, but it again shows the following error:
Arrays have incompatible sizes for this operation.
Error in a6 (line 40)
f=[-fliplr(1:(Nt/2)) 0 (1:(Nt/2-1))].*df;
Walter Roberson
Walter Roberson le 19 Oct 2021
Please attach a copy of as much of the 2.5 Lpm Step Test for 2 inch pipe with 0 insulation folder as we need to test your code. You can zip the files and attach the zip.
Iffat Arisa
Iffat Arisa le 19 Oct 2021
I've fixed it, now it is running. Thanks a lot for your help.
I have a question about getting slope of the graph. I used:
b = polyval(f,k, abs(st));
slope = b(1)
Is this a correct Matlab command?
Walter Roberson
Walter Roberson le 20 Oct 2021
No, to get the slope you can use polyfit() (not polyval) with degree 1
Iffat Arisa
Iffat Arisa le 20 Oct 2021
I have attached the figure which is frequency vs. wavenumber. Would you please tell me how can I get slope from this? Which Matlab function is required to get slope of this figure?
Walter Roberson
Walter Roberson le 21 Oct 2021
I suspect that what you need is gradient() rather than slope.

Connectez-vous pour commenter.

Plus de réponses (1)

Iffat Arisa
Iffat Arisa le 15 Oct 2021

0 votes

I've attached ReadDasLogV4.m

2 commentaires

Image Analyst
Image Analyst le 15 Oct 2021
I think you forgot to attach a .das file, didn't you?
Iffat Arisa
Iffat Arisa le 16 Oct 2021
I tried to attach das file, but it is not attached here.
After running the script, I found the attached section. Please see it.

Connectez-vous pour commenter.

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by