Cannot import Excel xls file
11 views (last 30 days)
Show older comments
Hi, I don't understand why I can no longer use xls files? Never had a problem before but if I use import data my xls files are greyed out in my file directory so Matlab can't import it? I have read a few threads here about this but really don't understand how to implent comoplicated solutions and script fixes. I just want the software to open like it used to. Already spent an hour and nada... Beyond fruistrating when everything used to work fine when I last used Matlab 6 months ago. Any help much appreciated. Thanks
2 Comments
Mil Shastri
on 14 Nov 2019
What function are you using to read the excel file, have you tried readtable?. Also, feel free to upload a sample excel file.
Answers (7)
Sky Trader
on 14 Nov 2019
2 Comments
Walter Roberson
on 14 Nov 2019
You appear to be using the Import Data toolstrip item, which appears to use uiimport(), which in turn these days appears to use readtable() by default.
What shows up if you do
fileattrib('DJI DAILY 1985-2019 Std Dev copy 2.xls')
Sky Trader
on 15 Nov 2019
1 Comment
Mil Shastri
on 15 Nov 2019
The distribution filter app requires data to be vectors. You can do this by creating separate vectors from selected columns in a table as shown below:
As always, some good detailed information about using the app can be found in the MATLAB documenation here https://www.mathworks.com/help/stats/model-data-using-the-distribution-fitting-tool.html
On a side note, you can also have MATLAB generate code automatically for all the GUI based customizations that you may have performed using DistributionFilterApp > File > GenerateCode . This can be handy if at all you would like to automate your scripts in future.
Sky Trader
on 20 Nov 2019
3 Comments
Walter Roberson
on 21 Nov 2019
Right, there was a change to the default output type for uiimport. I seldom use that routine because I find the output types to be too unpredictable, so I forgot about that.
Image Analyst
on 9 Dec 2020
For what it's worth, I'm attaching data and a demo to compute the volatility of the US Stock Market Dow Jones Index.
It seems like the TV analysts are always saying that we're in a period of historically high volatility. But is that really true (no) or are they just trying to make the new exciting (yes)? Well I downloaded the data from Yahoo finance and did my own analysis. The long term average day-to-day percent change of the index is 0.75%.
It's a very short and simple program that I'm sharing below (and attached with the data file).
% Program to plot the Dow Jones Industrial Average from 1985 to August 2019, and compute the standard deviation.
% Data available for download at https://finance.yahoo.com/quote/%5EDJI/history?p=%5EDJI
% Just set the Time Period, then find and click the download link.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures if you have the Image Processing Toolbox.
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 14;
filename = 'Dow Jones Industrial Index.csv'
data = readtable(filename)
% Date,Open,High,Low,Close,Adj Close,Volume
dates = data.Date;
closing = data.Close;
subplot(3, 1, 1);
plot(dates, closing, 'b-');
xticks(datetime(1985,1,1):calendarDuration(2,0,0):datetime(2021,1,1))
drawnow;
grid on;
title('Dow Jones Industrial Average', 'FontSize', fontSize);
% Get the average change from one trading day to the next.
diffs = 100 * abs(closing(2:end) - closing(1:end-1)) ./ closing(1:end-1);
subplot(3, 1, 2);
averageDailyChange = mean(diffs)
numWeeks = 4;
diffs = sgolayfilt(diffs, 2, 5*numWeeks+1);
plot(dates(2:end), diffs, 'b-');
grid on;
xticks(datetime(1985,1,1):calendarDuration(2,0,0):datetime(2021,1,1))
hold on;
line(xlim, [averageDailyChange, averageDailyChange], 'Color', 'r', 'LineWidth', 2);
caption = sprintf('Day-to-Day Change Percentage. Average Daily Change (from prior day) = %.2f%%', averageDailyChange);
title(caption, 'FontSize', fontSize);
drawnow;
% Get the stddev over a 5 trading day window.
sd = stdfilt(closing, ones(5, 1));
% Get it relative to the magnitude.
sd = sd ./ closing * 100;
averageVariation = mean(sd)
numWeeks = 40;
sd = sgolayfilt(sd, 2, 5*numWeeks+1);
subplot(3, 1, 3);
plot(dates, sd, 'b-');
grid on;
xticks(datetime(1985,1,1):calendarDuration(2,0,0):datetime(2021,1,1))
hold on;
line(xlim, [averageVariation, averageVariation], 'Color', 'r', 'LineWidth', 2);
caption = sprintf('Weekly Standard Deviation, Averaged Over %d Weeks (%d trading days). Mean SD = %.2f', ...
numWeeks, 5*numWeeks+1, averageVariation);
title(caption, 'FontSize', fontSize);
MaximizeFigureWindow;
Historically the four highest volatility periods were all high sell off periods:
- the Oct 1987 crash
- the 2002 dot com bust
- the late 2008 financial crisis, and
- the Feb. 2020 COVID crash.
From the plots you can see that from 2003 to the present, the volatility was mostly below average (except for the two crashes) while the period early 1997 - early 2003 it was mostly above the long term average.
0 Comments
See Also
Categories
Find more on Spreadsheets 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!