comparing and updating fields in a structure

2 views (last 30 days)
i have this part of code where i want to do a comparison for a loop of (i) to compare the name SSID then if it is write it have to update the RSSI field
([wifiScanDataStruct.UserData.Dev(i).SSID num2str(wifiScanDataStruct.UserData.Dev(i).RSSI)]) %% the stated structure without updating
([tmp.SSID(1) num2str(tmp.RSSI(1))]) %% the recived values
  2 Comments
Walter Roberson
Walter Roberson on 18 Feb 2019
That is not clear.
Is the num2str() part intended to mean that the field name you want to update will not be SSID but will instead be SSID followed by a number that happens to be the RSSI ? So if the RSSI were -32 you would want to update field SSID32 ??
Hamda Altamimi
Hamda Altamimi on 18 Feb 2019
to make it clear:
I will be reciving an SSID and its RSSI value
and I have a table of SSID (certain number of devices) , so the SSID will recieve many devices I want it to start comparing the original table if the SSID which is save in (wifiScanDataStruct.UserData.Dev(i).SSID) and the recievd is saved in (tmp.SSID(1))
so when it will start comparing and checking if it is right so we need to update the RSSI value of ( (wifiScanDataStruct.UserData.Dev(i).RSSI)) taking the value from the corresponding (tmp.RSSI(1))
And for the (i) is to do a loop for the number of devices I have (missing part of code Dev_SSID_Table = [ "DD-WRT", "KU-AUH-STUDENTS", "KU-AUH-STAFF", "KU-AUH-GUEST", "eduroam"];)
I hope it is clear now

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 18 Feb 2019
If you have an SSID and you want to find out where in a list of SSIDs that the given one occurs, then you can
[wasfound, idx] = ismember(TheSSIDToTest, CellArrayOfSSIDs);
if ~wasfound
%it was not on the list, you have not heard of this one before. You might need to create a new entry
else
%TheSSIDToTest matches CellArrayOfSSIDs{idx}
RRSID_table(idx) = Updated_RRSID_information_would_be_here;
end

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!