Multiple linear regression with table?

2 Ansichten (letzte 30 Tage)
Tayaba Abbasi
Tayaba Abbasi am 17 Feb. 2018
Kommentiert: dpb am 17 Feb. 2018
I am trying to perform multiple linear regression through md1 function in matlab. I am trying to create table through tbl however I am getting error saying that Undefined function or variable 'part1cdata'. Please explain how to define input for tbl?
The code is:
Load the sample data and store the independent and response variables in a table.
load part1cdata
%tbl = table(part1c(:,1),part1c(:,2),part1c(:,3),part1c(:,4), ...
% 'VariableNames',{'ATP','airboosterdisc','Airtempcold','Motoairtemp'});
% tbl = table(part1c(:,1),part1c(:,2),part1c(:,3),part1c(:,4),part1c(:,5),part1c(:,6),part1c(:,7), ...
% part1c(:,8),part1c(:,9),part1c(:,10),part1c(:,11),part1c(:,12),part1c(:,13),part1c(:,14), ...
% 'VariableNames',{'ATP','airboosterdisc','current','power','RTD1','RTD2','RTD3','RTD4','RTD5','Airtempcold','Motoairtemp','voltage','pressuredischarge','temperaturedischarge'});
tbl = table(part1c(:,1),part1c(:,2),part1c(:,3),part1c(:,4),part1c(:,5),part1c(:,6), ...
'VariableNames',{'ATP','ABD','AIRTEMPCOLD','MOTOAIRTEMP','PRESSDISCH','TEMPDISCH'});
% Fit a linear regression model.
mdl = fitlm(tbl)
figure
plotResiduals(mdl)
I have read the documentation but don't know where I am wrong
  1 Kommentar
dpb
dpb am 17 Feb. 2018
You seem to have confusion between variable names and functions; the Matlab GLM function is fitlm the returned LM object is the LH variable mdl. Similar confusion is seen between table and the LH variable tbl.
Presuming the part1cdata .mat file contains an array, it would be much easier to use
tbl = array2table(part1c, ...
'VariableNames', ...
{'ATP','ABD','AIRTEMPCOLD','MOTOAIRTEMP','PRESSDISCH','TEMPDISCH'});
to create the table.
BUT, the problem seems to be some problem that isn't consistent with the error; if the .mat file were not there, then would get an error with load like
>> load part1cdata
Error using load
Unable to read file 'part1cdata'. No such file or directory.
>>
but if there's an error referring to part1cdata, then there's no other code in the pasted snippet that refers to that variable name.
We need the precise code and error message in context; attaching the .mat file would also help if there's still confusion on "who's who in the zoo"...

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by