Reading Files and plotting in matlab

4 visualizaciones (últimos 30 días)
Gerald Boddie
Gerald Boddie el 7 de Ag. de 2020
Comentada: Star Strider el 7 de Ag. de 2020
I have been using the code (attached) to read in files from Abaqus, and plot the displacement versus time output plots. After the displacement plots, the code plots the fast fourier transform (FFT) of the displacement plots for frequency analysis. This code usually works fine and I have used it over the summer without any trouble. However, every once in a while, I will download a file and when I run the code displacement plots appear but not the frequency plots. I usually get an error at line 84 (image of command window attached). When I traceback this error I see in the work space that the fvec and F do not have the same length. They're mismatched by a value of one. I tried reloading old files and the code works fine but when I try loading the new file I run into the same issue. Can anyone please explain why this is happening? And if so, how can I fix this issue?
I have attached:
The file I am running - Abaqus_AScan_and_FFT_Plotter.m
An example of a file that works - NO4mm_25x25x15_U123.txt
An example of a file that doesn't work - NO2mm_25x25x15_U123.txt
An image of the error (in the command window) - Matlab Error.JPG
An image of the work space, with the mismatched vector lengths - Works Space Matlab.JPG

Respuesta aceptada

Star Strider
Star Strider el 7 de Ag. de 2020
I am not certain what the responses to the input calls should be, so I did not run your code, only looked at it.
It appears that the lengths of ‘fvec’ and ‘F’ are calculated differently.
A ‘quick fix’ would simply be:
F = abs(F(1:numel(fvec)));
That would essentially guarantee that they are always the same lengths. (The numel function returns the number of elements in an array. For vectors, this is the same as a number of other functions, one being length. They behave differently in different situations, so understanding them is important.)
Also, consider using textscan to read the files. That might make that part easier.
  2 comentarios
Gerald Boddie
Gerald Boddie el 7 de Ag. de 2020
Thank you for your reply! This was indeed a 'quick fix'. I will look more into the numel function to make sure I understand what I really just did but it definetly worked. Thanks again!
Star Strider
Star Strider el 7 de Ag. de 2020
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Import and Analysis 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