getting different results with excel data

4 visualizaciones (últimos 30 días)
Lou Gnerre
Lou Gnerre el 21 de Nov. de 2021
Comentada: Image Analyst el 27 de Nov. de 2022
Hello, I am fairly new to MATLAB, here is my issue:
I have frequency domain data I wish to perform an IFFT on in order to recover the waveform in the time domain.
The original data is an FFT data captured by test equipment. It is in an excel spreadsheet, stored in .csv format.
When I import the .csv data into my MATLAB code and perform the IFFT, I get a waveform that is not correct.
However, when I manually copy the exact data from the .csv and paste it into an array in the MATLAB source file, and run the same IFFT, the resulting time domain waveform is correct.
I have had this issue with several different waveforms/files.
I am confident the results of the second approach (manually copying data to array into MATLAB source) is correct because in each case I know what the origial time domain is.
Any help is greatly appreciated,
THANKS!!!!

Respuestas (4)

Yongjian Feng
Yongjian Feng el 21 de Nov. de 2021
Without a sample file, it is difficult to investigate the problem for you. You might need to do this yourself:
  1. read the data from csv (using readcsv?) as readArr
  2. copy and paste the data as pastedArr
  3. Diff them find(readArr~=pastedArr)
  2 comentarios
Lou Gnerre
Lou Gnerre el 22 de Nov. de 2021
I figured it out, using importdata() seemed to mess things up, readtable() gives me good results.
THANKS FOR YOUR HELP!
Yongjian Feng
Yongjian Feng el 22 de Nov. de 2021
Great.
Accept an answer if it helps you. Then others with the same question know how to handle it.
Thanks.

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 21 de Nov. de 2021
Does the data have both the positive and negative frequencies? And did you make sure the zero frequency (DC) component was at element 1 and the negative freq's are basically mirrored so that the right side of the spectrum looks similar to the left half?
Unfortunately you forgot to attach your data file. Attach it if you want people to help you with your actual data.

Lou Gnerre
Lou Gnerre el 22 de Nov. de 2021
see attached is a sample of my captured data,
  1 comentario
Image Analyst
Image Analyst el 23 de Nov. de 2021
I don't understand this data. What does column 1 and column 2 of the file represent? They both just seem like random numbers. I mean the x (if that's the first column) is not even sorted:
% Demo by Image Analyst
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 22;
data = readmatrix('MYDATAcart.txt');
x = data(:, 1);
y = data(:, 2);
plot(x, y, 'b-', 'LineWidth', 2);
grid on
title('Frequency Spectrum', 'FontSize', fontSize);
xlabel('Frequency', 'FontSize', fontSize);
ylabel('Fourier Signal Value', 'FontSize', fontSize);

Iniciar sesión para comentar.


Lou Gnerre
Lou Gnerre el 22 de Nov. de 2021
Editada: Image Analyst el 23 de Nov. de 2021
Here are pictures of the kinds of outputs I am getting:
  2 comentarios
Yashika Chauhan
Yashika Chauhan el 27 de Nov. de 2022
can you please share the matlab code for converting the csv data into ifft
Image Analyst
Image Analyst el 27 de Nov. de 2022
data = readmatrix(fileName);
ft = fft(data);

Iniciar sesión para comentar.

Categorías

Más información sobre Standard File Formats en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by