undefined function 'corrplot

조회 수: 24 (최근 30일)
Alwin
Alwin 2012년 6월 25일
댓글: Adam Danz 2023년 7월 12일
Hi, I wanted to create a graphical correlation matrix according using the corrplot function ( http://www.mathworks.com/help/toolbox/econ/corrplot.html) but when I try using the function I get the following message:
Undefined function 'corrplot' for input arguments of type 'double'.
I also looked for the function using 'which'- command. And I couldn't find the functiin. Is it possible that my Matlab version (2011b) doesn't have the function? Is it possible to download the function on the Mathworks website?
Thank you.

답변 (3개)

Adam Danz
Adam Danz 2020년 5월 17일
편집: Adam Danz 2023년 6월 25일
corrplot is part of the Econometrics Toolbox. Run this command to determine if you have the Econometrics Toolbox installed on your machine. It returns true (1) or false (0).
license('test','econometrics_toolbox')
Alternative
plotmatrix() is quite similar and with just a few additional lines, you can recreate most of the corrplot().
Here's a demo.
% Load data
load('carsmall')
% Unlike corrplot, plotmatrix cannot receive a table.
% Form a matrix of variables in each column.
data = [Horsepower, Weight, Acceleration, MPG];
nVars = size(data,2);
% Remove any rows that contain NaN values. Otherwise corr() will
% return NaN.
data(any(isnan(data),2), :) = [];
% Create plotmatrix
figure('Name', 'carsmall_data')
[sh, ax, ~, hh] = plotmatrix(data);
% Add axis labels
arrayfun(@(h,lab)ylabel(h,lab),ax(:,1), {'Horsepower','Weight','Accel.','MPG'}')
arrayfun(@(h,lab)xlabel(h,lab),ax(end,:), {'Horsepower','Weight','Accel.','MPG'})
% Compute correlation for each scatter plot axis
[r,p] = arrayfun(@(h)corr(h.Children.XData(:),h.Children.YData(:)),ax(~eye(nVars)));
% Label the correlation and p values
arrayfun(@(h,r,p)text(h,min(xlim(h))+range(xlim(h))*.05,max(ylim(h)),...
sprintf('r=%.2f, p=%.3f',r,p),'Horiz','Left','Vert','top','FontSize',8,'Color','r'),...
ax(~eye(nVars)),r,p)
% Change marker appearance
set(sh, 'Marker', 'o','MarkerSize', 2, 'MarkerEdgeColor', ax(1).ColorOrder(1,:))
lsh = arrayfun(@(h)lsline(h),ax(~eye(nVars)));
% Add least square regression line.
set(lsh,'color', 'm')
  댓글 수: 3
ClaireB
ClaireB 2023년 7월 12일
Thanks for the nice example. i would like to use Spearman correlation instead of pearson but unsure where to add this in the following function
[r,p] = arrayfun(@(h)corr(h.Children.XData(:),h.Children.YData(:)),ax(~eye(nVars)));
Adam Danz
Adam Danz 2023년 7월 12일
Set the correlation type using a name-value pair
[r,p] = arrayfun(@(h)corr(h.Children.XData(:),h.Children.YData(:),'Type','Spearman'),ax(~eye(nVars)));

댓글을 달려면 로그인하십시오.


owr
owr 2012년 6월 25일
It looks like it was added in 2012A. I dont think there is anywhere to download just one function, too many dependencies, best thing would be to install 2012A if possible.

Anni K
Anni K 2023년 6월 24일
Hi, I had the same problem. After downloading the toolbox Econometric Modeler, corrplot worked for me.
Good luck!

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by