Assigning values from one array to string values of another array
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi! Im writing a script that is supposed to count votes for ideas (using 3 score categories) and then rank the ideas. The values are given by a csv file. My code currently imports the data and counts the scores for each idea (using a for loop) and stores the scores in a vector. It also counts the number of ideas that have come in, names them and stores the names as a string vactor. The vectors are the same length and the ideaname and scorevalue have the same indexes. To be able to rank the ideas I would need to connect each string value with a score number and then sort the ideas from high to low according to their scores. How do I do this?
If you happen to know neat ways to visuaise the results that would also be very valuable!
The vectors are 1x9 but the length of them are defined by a variable called NumIdeas, as I want the csv file to be editable. Currently they look like this:
ideanumber = ["idea1", "idea2", ..., "idea9"]
scorevector = [5.7065, 3.2885, 7.8947, 5.8056, 5.7619, 4.2955, 5.0740, 3.0227, 7.4564]
I tried using a table function (syntax: scoreboard = table(ideanumber, scorevector) ) but the following error message was displayed; "Error using () Unrecognised row name "idea1".
I am fairly new to Matlab and would greatly appreciate any guidance you can give :) Thank you!
0 Kommentare
Antworten (2)
KSSV
am 15 Jul. 2022
ideanumber = ["idea1", "idea2","idea3", "idea4","idea5", "idea6","idea7", "idea8", "idea9"] ;
scorevector = [5.7065, 3.2885, 7.8947, 5.8056, 5.7619, 4.2955, 5.0740, 3.0227, 7.4564] ;
T = table(ideanumber',scorevector')
Siehe auch
Kategorien
Mehr zu Financial Data finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!