Conversion to cell from double is not possible

I am trying to do some column calculations in MATLAB Gui columns. Like 2*pi*column1 gives column 3... So I used the code
dataC = get(handles.uitable1, 'Data'); dataC(:,3) = cell2mat(dataC(:,1)) * pi * 2;
Ans this gives error of conversion to cell from double is not possible in reference to the last line of the code.

 Respuesta aceptada

Stephen23
Stephen23 el 16 de Ag. de 2019
Editada: Stephen23 el 16 de Ag. de 2019
A = cell2mat(dataC(:,1));
B = A * pi * 2;
dataC(:,3) = num2cell(B); % <- you need NUM2CELL!

6 comentarios

Tolulope Abiola
Tolulope Abiola el 16 de Ag. de 2019
Thanks so much for your reaponse but it just changed the error to.
Unable to perform assignment because the size of the left side is 20 by 1 and the size of the right side is 20 by 2
Stephen23
Stephen23 el 16 de Ag. de 2019
What size is A ?
madhan ravi
madhan ravi el 16 de Ag. de 2019
By the looks of error message , perhaps A is of size 20 x 2. Perhaps just change num2cell(B) to num2cell(B,2).
Tolulope Abiola
Tolulope Abiola el 24 de Ag. de 2019
On the same code please i have the following issues
dataC = get(handles.uitable1, 'Data'); Data = cell2mat(dataC(:,1)); C = 2* Data(:,1) * pi; dataC(:,3) = num2cell(C(:,1)); set(handles.uitable1, 'Data', dataC) With this code it adds 48 to each digit input before performing the task. And when two digits number is entered like 56 it only calculate for 5 which is the first figure alone. Anyone please help out.
Stephen23
Stephen23 el 25 de Ag. de 2019
@Tolulope Abiola: either make sure that the uitable column is numeric, or convert to numeric after obtaining the data from the uitable.
nice!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 16 de Ag. de 2019

Comentada:

el 19 de Jul. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by