Writing a result on an existing table?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Claudio Nahmad
el 30 de Ag. de 2016
Comentada: Claudio Nahmad
el 30 de Ag. de 2016
I am new to Matlab. I made a variable named datosraw, it is a 18x3 matrix that contains diameter data, voltage data and current data corresponding to each column.
What i want to do next is multiply the first column (diameter) times 3.1416 and store the result in the SAME variable "datosraw" but in column 4 or alternately on a new variable, i don't know how to do that, appreciate your help!
This is my code:
dprom=datosraw(:,1); %diametro promedio
v=datosraw(:,2); %voltaje
i=datosraw(:,3); %corriente
A=dprom*3.1416;
writetable(A,datosraw);
0 comentarios
Respuesta aceptada
George
el 30 de Ag. de 2016
Are you using matrices or tables? It's not completely clear to me in your post. If it's a matrix you can do the calculation and concatenation in one step.
>> datosraw = [datosraw datosraw(:,1) * pi]
This takes the original value of datosraw and concatenates it with the first column of datosraw * pi, placing that column at the end.
If you're using tables you can just assign the new table variable as the result of a calculation.
>> T
T =
promedio voltaje corriente
________ _______ _________
0.119 0.81428 0.075854
0.49836 0.24352 0.05395
0.95974 0.92926 0.5308
0.34039 0.34998 0.77917
0.58527 0.1966 0.93401
0.22381 0.25108 0.12991
0.75127 0.61604 0.56882
0.2551 0.47329 0.46939
0.50596 0.35166 0.011902
0.69908 0.83083 0.33712
0.8909 0.58526 0.16218
0.95929 0.54972 0.79428
0.54722 0.91719 0.31122
0.13862 0.28584 0.52853
0.14929 0.7572 0.16565
0.25751 0.75373 0.60198
0.84072 0.38045 0.26297
0.25428 0.56782 0.65408
>> T.result = T.promedio * pi
T =
promedio voltaje corriente result
________ _______ _________ _______
0.119 0.81428 0.075854 0.37384
0.49836 0.24352 0.05395 1.5657
0.95974 0.92926 0.5308 3.0151
0.34039 0.34998 0.77917 1.0694
0.58527 0.1966 0.93401 1.8387
0.22381 0.25108 0.12991 0.70313
0.75127 0.61604 0.56882 2.3602
0.2551 0.47329 0.46939 0.8014
0.50596 0.35166 0.011902 1.5895
0.69908 0.83083 0.33712 2.1962
0.8909 0.58526 0.16218 2.7989
0.95929 0.54972 0.79428 3.0137
0.54722 0.91719 0.31122 1.7191
0.13862 0.28584 0.52853 0.4355
0.14929 0.7572 0.16565 0.46902
0.25751 0.75373 0.60198 0.80899
0.84072 0.38045 0.26297 2.6412
0.25428 0.56782 0.65408 0.79885
>>
Más respuestas (0)
Ver también
Categorías
Más información sobre Tables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!