Raspberry Pi uses TCPIP communication

Hi
I'm working on deploy my code to raspberry pi to control the temperature in house.But it always remind me:
Error calling 'networklibcoder.tcpclient.write'. This call-site passes more inputs to this function than it can accept.
I don't know how to write the code that can be deployed to Raspberry Pi,here is my code.Can you give me some advice?
T = tcpclient('IP for PC',5900);
Troom = read(T,1,"double");
t = 1:86400;
for k = 1:4
tout = (8*sin(2*pi/(12 * 3600)*t(k:k+3))+12)';
end
g = 41;
optimal = [];
for i = 1:g
all = coder.load('soldata.mat');
data = struct2cell(all);
H = data{1}{i}.H;
K = data{1}{i}.K;
Fi = data{1}{i}.Fi;
Gi = data{1}{i}.Gi;
if H*[Troom;tout] <= K
optimal(i) = Fi * [Troom;tout] + Gi;
else
optimal(i) = 1;
end
end
S_pre = min(optimal);
out = S_pre;
t = tcpclient("IP for PC", 18734);
write(t, out, "double");
Many thanks,
Bang

6 Comments

t = 1:86400;
%...
t = tcpclient("IP for PC", 18734);
When you are designing code for deployment, you should avoid using the same variable for two different types, as it might not be able to do proper type analysis.
Your out appears to already be type double, so you can probably omit the "double" option
all = coder.load('soldata.mat');
data = struct2cell(all);
Why are you doing that inside a loop? You are not changing the file during the loop.
I already aware of the question of 't' and fix it.But my question is the raspberry pi cannot identify the function 'write',so I cannot deploy it in raspberry pi.Is there any other function that can represent the same meaning?
The data is I solved the parameters obtained using EMPC in MATLAB,I want to use it in raspberry pi.It has 41 loops, and each loop has a different value.Because raspberry pie can only compute some low-level code,so I need to first solve for the parameters and then perform simple matrix operations in the raspberry pi.
The function
write(t, out);
would mean the same thing.
Is the file soldata.mat being changed while the code is executing?
I simulate 24 hours change-temperature,the step is 15 mins.Every step have 41 groups data,each group has different data.But each simulation has the same array,the code can run correctly.I just want to deploy it in raspberry pi to make some new things.
The data(H、K、Fi、Gi) is solved by EMPC in MATLAB.I set them in a struct to use it in raspberry pi.

Sign in to comment.

Answers (0)

Categories

Asked:

on 10 Nov 2023

Commented:

on 10 Nov 2023

Community Treasure Hunt

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

Start Hunting!