"T.Properties.VariableNames" will not allow me to include parentheses () or brackets [ ] in my column heading
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
James Long
am 18 Apr. 2017
Kommentiert: James Long
am 18 Apr. 2017
"T.Properties.VariableUnits" and "T.Properties.VariableDescriptions" also do not work to fix this issue. does anyone have a work around for this?
Here is my actual code:
%Constant Values
A=1; %VOLTS
b0=1; %DIMENSIONLESS
r=0.75; %DIMENSIONLESS
xn=ones(1,41); %Input Sequence as a matrix equal to the Unit-Step Sequence in VOLTS (always 1)
n=[0:1:40]; %Value of "n" ranges from 0 to 40 and are in 1 unit increments
%Impulse response of a 2nd-Order Infinite Impulse Response (IIR) Filter
hn=b0*(-r).^n.*(n+1); %Creates a matrix of values from h[0], h[1], h[2],...,h[n-1],[n]
%Cumulatively sums the values of h[n] which yields the Output Sequence "y[n]"
yn=cumsum(hn);
N=n(:); %Transforms matrix of values of "n" into a single column
XN=xn(:); %Transforms matrix of values of "xn" into a single column
HN=hn(:); %Transforms matrix of values of "h[n]" into a single column
YN=yn(:); %Transforms matrix of values of "y[n]" into a single column
T = table(N, XN, HN, YN) %Outputs a table with the values of "n," the input sequence "x[n],"
%the 2nd-Order (IIR) filter "h[n]," and the output sequence "y[n]."
%T.Properties.VariableNames = {'n' 'x[n] (V)' 'h[n]' 'y[n] (V)'}
T.Properties.VariableNames{2} = 'x[n] (V)'
2 Kommentare
the cyclist
am 18 Apr. 2017
I've formatted your code for you. Next time, please use the "{}Code" button.
Akzeptierte Antwort
Aniruddha Katre
am 18 Apr. 2017
You get this error message because 'x[n] (V)' is not a valid MATLAB variable name. The columns in a table are actually MATLAB variables, so the column header must be a valid variable name. There are 3 rules for a valid variable name that need to be followed:
- Can only have letters, number and underscores in a variable name. Nothing else is allowed.
- Variable names have to start with a letter.
- Variable names can be up to 63 characters long.
'x[n] (V)' -- starts with a letter but has special characters such as brackets, specs and parenthesis in it which makes it an invalid variable name.
If you replace that with:
T.Properties.VariableNames{2} = 'x_n_V'
or something along those lines, that will work.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!