In a table, when I try assigning a value to a new column based on some criteria, I get error that “assignment to elements using simple assignment statement is not supported”
I have a table for which I create an index where the values in a particular column are not NaN. I then try to use this index to create an entry into a new array and replace the values at the corresponding index (preloaded with ‘0000’) with ‘0001’. I will then add this array to the table as a new column.
My intention is to fill the corresponding indx in the column with ‘0001’, if the value in the newTable.PEM1_GA_Current_Estimate_Error a valid number (not NaN).
PEM1b =’0001′;
PEM2b =’0010′;
PEM3b = ‘0100’;
PEM4 = ‘1000’;
temp={};
indx=(find(newTable.PEM1_GA_Current_Estimate_Error ~= NaN))
temp ={repmat(‘0000’,size(newTable,1),1)}
temp{indx} = PEM1b
%…and add this array as a new column to the table
the last assigment in the code above generates this error:
Assigning to 2609 elements using a simple assignment statement is not supported. Consider using comma-separated list assignment.
I don’t think I should need a for loop to iterate through each row and replace the value at the "indx" location –what am I doing wrong?
I included the data….thank you.I have a table for which I create an index where the values in a particular column are not NaN. I then try to use this index to create an entry into a new array and replace the values at the corresponding index (preloaded with ‘0000’) with ‘0001’. I will then add this array to the table as a new column.
My intention is to fill the corresponding indx in the column with ‘0001’, if the value in the newTable.PEM1_GA_Current_Estimate_Error a valid number (not NaN).
PEM1b =’0001′;
PEM2b =’0010′;
PEM3b = ‘0100’;
PEM4 = ‘1000’;
temp={};
indx=(find(newTable.PEM1_GA_Current_Estimate_Error ~= NaN))
temp ={repmat(‘0000’,size(newTable,1),1)}
temp{indx} = PEM1b
%…and add this array as a new column to the table
the last assigment in the code above generates this error:
Assigning to 2609 elements using a simple assignment statement is not supported. Consider using comma-separated list assignment.
I don’t think I should need a for loop to iterate through each row and replace the value at the "indx" location –what am I doing wrong?
I included the data….thank you. I have a table for which I create an index where the values in a particular column are not NaN. I then try to use this index to create an entry into a new array and replace the values at the corresponding index (preloaded with ‘0000’) with ‘0001’. I will then add this array to the table as a new column.
My intention is to fill the corresponding indx in the column with ‘0001’, if the value in the newTable.PEM1_GA_Current_Estimate_Error a valid number (not NaN).
PEM1b =’0001′;
PEM2b =’0010′;
PEM3b = ‘0100’;
PEM4 = ‘1000’;
temp={};
indx=(find(newTable.PEM1_GA_Current_Estimate_Error ~= NaN))
temp ={repmat(‘0000’,size(newTable,1),1)}
temp{indx} = PEM1b
%…and add this array as a new column to the table
the last assigment in the code above generates this error:
Assigning to 2609 elements using a simple assignment statement is not supported. Consider using comma-separated list assignment.
I don’t think I should need a for loop to iterate through each row and replace the value at the "indx" location –what am I doing wrong?
I included the data….thank you. cell array, indexing MATLAB Answers — New Questions