MATLAB Answers

Unrecognized function or variable 'carsmall'

24 views (last 30 days)
Hello, I'm doing a very basic exercise which starts with importing carsmall.mat dataset and protting its data with gplotmatrix(). Here is the code I wrote:
clear all;
close all;
clc;
%% Initialization
load carsmall.mat;
figure()
gplotmatrix(carsmall');
The problem is that when I run the script I get this output message:
Unrecognized function or variable 'carsmall'.
Error in Exercise_3_1 (line 8)
gplotmatrix(carsmall);
I don't get it. I have the Statistics and Machine Learning Toolbox installed. I'he done the same exercise importing iris_dataset.mat and it all worked fine.
Can anybody please help me? I've also updated anything possible but nothing changed...
Thank you

  0 Comments

Sign in to comment.

Accepted Answer

John D'Errico
John D'Errico on 23 Mar 2020
Edited: John D'Errico on 23 Mar 2020
This is not a question of you updating your version. I can see what you did, but not what you were hoping to do. Suppose I try this:
load randomstuff.mat
Error using load
Unable to read file 'randomstuff.mat'. No such file or directory.
So, if I try loading a file that does not exist, it gives me an error, telling me the file does not exist, but NOT what you got.
What did you get?
Unrecognized function or variable 'carsmall'.
Error in Exercise_3_1 (line 8)
gplotmatrix(carsmall);
That tells me the load did work, but there is no variable named carsmall in that .mat file.
I would suggest you try this:
load carsmall.mat;
whos
Name Size Bytes Class Attributes
Acceleration 100x1 800 double
Cylinders 100x1 800 double
Displacement 100x1 800 double
Horsepower 100x1 800 double
MPG 100x1 800 double
Mfg 100x13 2600 char
Model 100x33 6600 char
Model_Year 100x1 800 double
Origin 100x7 1400 char
Weight 100x1 800 double
So there is indeed no variable by that name in the .mat file. Lots of other stuff, but not carsmall. What you want to do next is up to you.

  5 Comments

Show 2 older comments
Alberto Ongaro
Alberto Ongaro on 28 Mar 2020
No it doesn't, I just tried:
load iris_dataset
whos
% and here is what I get:
Name Size Bytes Class Attributes
irisInputs 4x150 4800 double
irisTargets 3x150 3600 double
My guess is that IF the dataset contains just numerical variables belonging to the same class, then we can call gplotmatrix() putting the name of the dataset inside the brackets; otherwise (like in carsmall dataset) we have to extract the desired variables belonging to the same class, place them in a vector, and then we can finally apply gplotmatrix().
Walter Roberson
Walter Roberson on 28 Mar 2020
gplotmatrix(iris_dataset');
iris_dataset is a function. In this context it returns the irisInputs variable from iris_dataset . You do not even have to load the dataset first.
My guess is that IF the dataset contains just numerical variables belonging to the same class, then we can call gplotmatrix() putting the name of the dataset inside the brackets;
No, it has nothing ot do with that. It is because iris_dataset is a function that is returning the values.
>> which iris_dataset
/Volumes/T5/T5 Applications/MATLAB_R2020a.app/toolbox/nnet/nndemos/nndatasets/iris_dataset.m
Alberto Ongaro
Alberto Ongaro on 28 Mar 2020
That makes a lot of sense then. Thank you so much!

Sign in to comment.

More Answers (0)

Sign in to answer this question.