Why do I get this error and is it something to do with my code?

I get this error when I try to run my code
code:
% a.) column vector of last names called last, using curly braces.
last={'Smith'; 'Jones'; 'Webb'; 'Anderson'}
% b.) column vector of first names called first, usinf curly braces.
first={'Fred'; 'Kathy'; 'Milton'; 'John'}
% c.) column vectors for age, height and weight.
age=[6; 22; 92; 45]
Height=[47; 66; 62; 72]
weight=[82; 140; 110; 190]
% d.) display information using the 'table' function.
table(last,first,age,Height,weight)
error:
Warning: Error occurred while executing the listener callback for event POST_REGION defined for class matlab.internal.language.RegionEvaluator:
Undefined function 'power' for input arguments of type 'table'.
)
h=(-(9.8/2).*t.^2)+(125.*t)+500;
tHeight = height(obj);
Error in matlab.internal.editor.VariableOutputPackager.isolatedDisplaying
Error in matlab.internal.editor.VariableOutputPackager.getStringFromVar
Error in matlab.internal.editor.VariableOutputPackager.getTruncatedStringFromVar
Error in matlab.internal.editor.interactiveVariables.InteractiveTabularUtils.getTruncatedStringFromTable
Error in matlab.internal.editor.interactiveVariables.InteractiveTablesPackager.packageVarTable
Error in matlab.internal.editor.interactiveVariables.InteractiveVariablesPackager.packageVarInteractive
Error in matlab.internal.editor.VariableOutputPackager.packageOutput

2 commentaires

If you run as such the lines, it should work:
% a.) column vector of last names called last, using curly braces.
last={'Smith'; 'Jones'; 'Webb'; 'Anderson'}
last = 4×1 cell array
{'Smith' } {'Jones' } {'Webb' } {'Anderson'}
% b.) column vector of first names called first, usinf curly braces.
first={'Fred'; 'Kathy'; 'Milton'; 'John'}
first = 4×1 cell array
{'Fred' } {'Kathy' } {'Milton'} {'John' }
% c.) column vectors for age, height and weight.
age=[6; 22; 92; 45]
age = 4×1
6 22 92 45
Height=[47; 66; 62; 72]
Height = 4×1
47 66 62 72
weight=[82; 140; 110; 190]
weight = 4×1
82 140 110 190
% d.) display information using the 'table' function.
table(last,first,age,Height,weight)
ans = 4×5 table
last first age Height weight ____________ __________ ___ ______ ______ {'Smith' } {'Fred' } 6 47 82 {'Jones' } {'Kathy' } 22 66 140 {'Webb' } {'Milton'} 92 62 110 {'Anderson'} {'John' } 45 72 190
It seems you are calling it in a gui...so the error says variable power is not defined. Error might be with someother lines then you mentioned.
it runs correctly without any change on my machine as well

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 16 Jan 2023
you created your own height.m that is interfering with the Mathworks height function

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by