about assigning the values to a column vectors.
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Patel jaykumar Dipakbhai
el 8 de Jul. de 2019
Respondida: Guillaume
el 9 de Jul. de 2019
lets suppose i have 4 column vectors such as v1,v2,v3,v4
now what should i do to assign values to the elements of column v1 ( each element ) to that of vector v2.
the number of entries in both the coloumn are same.
same i want to do for v3 and v4.
and add the entries of v2 and v4 particulary for when the (v1 =~v3). the vectors here contains the numerical entries .
5 comentarios
madhan ravi
el 9 de Jul. de 2019
Patel always post the code and the expected output so that the readers gets the grasp of your idea quickly.
Respuesta aceptada
Guillaume
el 9 de Jul. de 2019
As Madhan said, always post the code as text, not as pictures which we can't copy paste into matlab.
There is usually no need for table2array. Typically people use it because they don't know how to manipulate tables directly.
eq is exactly the same as ==. I suspect that you used it to try to work around some problem. It won't solve it.
If all you want to do is add the corresponding of elements of FD to FC when matching elements of |EC and DE are equal, then it's simply:
toadd = EC == DE; %logical vector
FC(toadd) = FD(toadd) + FC(toadd);
Note that all these variables are extremely poorly named. It's very easy to mistype one for the other, introducing bugs in your code, and the variable names don't mean anything. Since all these variable appear to come from the same table data, you could simply manipulate the table directly:
toadd = round(data{:, 3}) == data{:, 1};
data{toadd, 2} = data{toadd, 2} + data{toadd, 4};
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical 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!