about assigning the values to a column vectors.
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Patel jaykumar Dipakbhai
il 8 Lug 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 Commenti
madhan ravi
il 9 Lug 2019
Patel always post the code and the expected output so that the readers gets the grasp of your idea quickly.
Risposta accettata
Guillaume
il 9 Lug 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!