



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This matlab script outlines a function that sends data to multiple devices based on the number of nodes and their respective device names. For each node, the script reads an image and creates a struct with the 'simu' field containing the image data and the 'stat' field containing the status message. If the master device is selected, an error message is displayed instead. The function supports up to eight nodes.
Typology: Study Guides, Projects, Research
1 / 5
This page cannot be seen from the preview
Don't miss anything!




function s = sel(num,nodes,set_val) %% Just Master node: if num == 1 status = 'Error! Master Device selected'; x = imread('2.JPG'); s = struct('simu', x,'stat',status); end %% Two Nodes: if num == 2 & set_val == 1 status = 'Error! Master Device selected'; x = imread('4.JPG'); s = struct('simu', x,'stat',status); end if num == 2 & set_val == 2 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('5.JPG'); s = struct('simu', x,'stat',status); end %% Three Nodes: if num == 3 & set_val == 1 status = 'Error! Master Device selected'; x = imread('7.JPG'); s = struct('simu', x,'stat',status); end if num == 3 & set_val == 2 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('9.JPG'); s = struct('simu', x,'stat',status); end if num == 3 & set_val == 3 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('8.JPG'); s = struct('simu', x,'stat',status); end %% Four Nodes: if num == 4 & set_val == 1 status = 'Error! Master Device selected'; x = imread('11.JPG'); s = struct('simu', x,'stat',status); end if num == 4 & set_val == 2 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('13.JPG'); s = struct('simu', x,'stat',status); end
if num == 4 & set_val == 3 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('14.JPG'); s = struct('simu', x,'stat',status); end if num == 4 & set_val == 4 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('12.JPG'); s = struct('simu', x,'stat',status); end %% Five Nodes: if num == 5 & set_val == 1 status = 'Error! Master Device selected'; x = imread('16.JPG'); s = struct('simu', x,'stat',status); end if num == 5 & set_val == 2 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('18.JPG'); s = struct('simu', x,'stat',status); end if num == 5 & set_val == 3 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('19.JPG'); s = struct('simu', x,'stat',status); end if num == 5 & set_val == 4 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('20.JPG'); s = struct('simu', x,'stat',status); end if num == 5 & set_val == 5 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('17.JPG'); s = struct('simu', x,'stat',status); end %% Six Nodes: if num == 6 & set_val == 1 status = 'Error! Master Device selected'; x = imread('22.JPG'); s = struct('simu', x,'stat',status); end if num == 6 & set_val == 2 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('25.JPG'); s = struct('simu', x,'stat',status);
x = imread('32.JPG'); s = struct('simu', x,'stat',status); end if num == 7 & set_val == 6 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('31.JPG'); s = struct('simu', x,'stat',status); end if num == 7 & set_val == 7 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('30.JPG'); s = struct('simu', x,'stat',status); end %% Eight Nodes: if num == 8 & set_val == 1 status = 'Error! Master Device selected'; x = imread('37.JPG'); s = struct('simu', x,'stat',status); end if num == 8 & set_val == 2 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('39.JPG'); s = struct('simu', x,'stat',status); end if num == 8 & set_val == 3 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('42.JPG'); s = struct('simu', x,'stat',status); end if num == 8 & set_val == 4 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('41.JPG'); s = struct('simu', x,'stat',status); end if num == 8 & set_val == 5 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('44.JPG'); s = struct('simu', x,'stat',status); end if num == 8 & set_val == 6 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('43.JPG'); s = struct('simu', x,'stat',status); end
if num == 8 & set_val == 7 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('40.JPG'); s = struct('simu', x,'stat',status); end if num == 8 & set_val == 8 status = ['Sending data to ' nodes(set_val).Device_Name]; x = imread('38.JPG'); s = struct('simu', x,'stat',status); end