How to send Table using UDP in MATLAB
显示 更早的评论
Hello, I hope you are doing well. I want to send Table using UDP. How can i do that?
I have write the following code but it does not working. Can anyone help me with that
client_port = 10011;
clientAddress = '192.168.100.202';
% Define the table
C = {5 "cereal" 110 "C+"; 12 "pizza" 140 "B";...
23 "salmon" 367 "A"; 2 "cookies" 160 "D"};
T = cell2table(C, 'VariableNames', {'Age', 'FavoriteFood', 'Calories', 'NutritionGrade'});
% Open a UDP port
u2 = udpport("IPV4",'LocalPort',client_port);
% Send the data
write(u2, clientAddress, client_port, T);
1 个评论
Image Analyst
2024-3-4
Save yourself some work and add only tags that are actually related to your question, not 22 unrelated (like image processing) or useless tags such as matlab, matlab code, code, etc.
回答(1 个)
Voss
2024-3-3
0 个投票
"Vector of values to write, specified as a row (1-by-N) or column (N-by-1) array of numeric data, string, or character vector."
A table is none of those things.
Also, the order of the inputs is:
"write(u,data,destinationAddress,destinationPort)"
or
"write(u,data,datatype,destinationAddress,destinationPort)"
7 个评论
Med Future
2024-3-3
Voss
2024-3-3
If the table contains numeric data, strings, and/or character vectors only, then you can write its contents in multiple write calls, where each call writes data only of one class, e.g., by writing one column of the table at a time.
Med Future
2024-3-3
Voss
2024-3-3
for ii = 1:numel(C)
write(u2, C{ii}, class(C{ii}), clientAddress, client_port);
end
Med Future
2024-3-3
Med Future
2024-3-4
类别
在 帮助中心 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!