Assigning values from one array to string values of another array
5 views (last 30 days)
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!
KSSV on 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')