Reading Files and plotting in matlab
2 views (last 30 days)
Show older comments
Gerald Boddie
on 7 Aug 2020
Commented: Star Strider
on 7 Aug 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
0 Comments
Accepted Answer
Star Strider
on 7 Aug 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.)
2 Comments
More Answers (0)
See Also
Categories
Find more on Data Import and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!