Results for
I am trying to make a simulink model to use a MPC to reduce power consumption of HVAC system in an electric vehicle during cool down from ambient temperature to a set point temperature. Any help regarding this would be appreciated
Hi I'm a newbie, the data I'm sending from the weather station I'm trying hasn't reached me for about 1 week.
Or rather, the data is sent regularly from the station to Thingspeak which connects and sends, but looking on the site it seems that they are not received.
The latest data received, in fact, dates back to 7 days ago.
By chance, after sending the 8000 available data, does the service stop?
Hello, an intern working at MathWorks is finishing up his program soon and he would like to interview some MATLAB users. He is looking for people who can give their perspective on the question:
"What makes MATLAB and Simulink special in comparison to other languages?"
Ultimately he plans to condense the answers into 15-second videos or sound bites.
If people are willing to participate but want more time to talk about their experience with MATLAB, he doesn't have time left for in-depth interviews but he can find someone else to take over the project.
Please send me an email via my profle if you are interested.
Hi
I am a beginner in MATLAB. I am trying to stimulate RF energy harvesting. Is it possble to stimulate this using simulink? Kindly help me. Thank You.
im trying to draw a path for the aircraft. so the aircraft needs to avoid all the red zones in the radar image i have and should travel only on green zones even the waypoints are on redzones.
% Load the radar image
radar_image = imread('radar.jpg');
I = radar_image;
% Display the radar image
figure;
imshow(I);
% Select waypoints
disp('Select the waypoints:');
[x, y] = ginput;
waypoints = [x, y];
% Save waypoints
save('waypoints.mat', 'waypoints');
% Load saved waypoints
load('waypoints.mat');
% Plot waypoints and connect them with lines
hold on;
plot(waypoints(:, 1), waypoints(:, 2), 'ro', 'LineWidth', 2);
plot(waypoints(:, 1), waypoints(:, 2), 'r--', 'LineWidth', 1);
% Load aircraft icon image
aircraft_icon = imread('aircraft_icon.png');
% Resize the aircraft icon image
desired_size = 30; % Change this value to adjust the size of the aircraft icon
aircraft_icon_resized = imresize(aircraft_icon, [desired_size, desired_size]);
% Animate aircraft using AI algorithm
tolerance = 5; % Tolerance for reaching waypoints
max_steps = 100; % Maximum steps to reach the destination
step_size = 1; % Step size for potential field calculations
% Plot the initial position of the aircraft
current_pos = waypoints(1, :);
h = image(current_pos(1), current_pos(2), aircraft_icon_resized);
set(h, 'AlphaData', 0.7); % Set the transparency (optional)
for i = 1:size(waypoints, 1)-1
start = waypoints(i, :);
finish = waypoints(i+1, :);
% Perform A* algorithm to find an alternate path through green zones
alternate_path = A_star(start, finish);
for j = 1:size(alternate_path, 1)-1
% Initialize the position of the aircraft
current_pos = alternate_path(j, :);
next_waypoint = alternate_path(j+1, :);
% Continue to the next waypoint if the current position is already near the waypoint
if norm(current_pos - next_waypoint) <= tolerance
continue;
end
% Perform animation to move the aircraft through the potential field
animateAircraft(current_pos, next_waypoint, max_steps, step_size, h);
% Update the radar image I with the current position of the aircraft
I(round(current_pos(2)), round(current_pos(1))) = 0;
end
end
function animateAircraft(current_pos, next_waypoint, max_steps, step_size, h)
% Animate the aircraft to move from current_pos to next_waypoint
for t = 1:max_steps
% Check if the aircraft has reached the destination waypoint
if norm(current_pos - next_waypoint) <= tolerance
break;
end
% Calculate potential field forces
attractive_force = next_waypoint - current_pos;
repulsive_force = zeros(1, 2);
% Calculate the repulsive forces from each red and yellow region
red_regions = find(I == 1);
yellow_regions = find(I == 2);
for k = 1:length(red_regions)
[r, c] = ind2sub(size(I), red_regions(k));
obstacle = [c, r];
repulsive_force = repulsive_force + calculate_repulsive_force(current_pos, obstacle);
end
for k = 1:length(yellow_regions)
[r, c] = ind2sub(size(I), yellow_regions(k));
obstacle = [c, r];
repulsive_force = repulsive_force + calculate_repulsive_force(current_pos, obstacle);
end
% Combine the forces to get the total force
total_force = attractive_force + 0.5 * repulsive_force; % Reduce repulsive force to move through obstacles more easily
% Normalize the total force and move the aircraft
total_force = total_force / norm(total_force);
current_pos = current_pos + step_size * total_force;
% Update the aircraft position on the plot
set(h, 'XData', current_pos(1), 'YData', current_pos(2));
drawnow; % Force the plot to update
% Pause for a short duration to visualize the animation
pause(0.05);
end
end
function force = calculate_repulsive_force(position, obstacle, I)
% Constants for the potential field calculation
repulsive_gain = 1000; % Adjust this value to control the obstacle avoidance strength
min_distance = 5; % Minimum distance to avoid division by zero
% Calculate the distance and direction to the obstacle
distance = norm(position - obstacle);
direction = (position - obstacle) / distance;
% Check if the obstacle is a waypoint
is_waypoint = false;
waypoints = [1, 2; 3, 4; 5, 6]; % Replace this with the actual waypoints' coordinates
for i = 1:size(waypoints, 1)
if isequal(obstacle, waypoints(i, :))
is_waypoint = true;
break;
end
end
% Check the color of the obstacle in the radar image
color = I(round(obstacle(2)), round(obstacle(1)));
% Calculate the repulsive force
if ~is_waypoint && color ~= 0 % Obstacle is not a waypoint or 0
force = repulsive_gain / max(distance, min_distance)^2 * direction;
else
force = zeros(1, 2);
end
end
this the code im using. But according to the output im getting, the aircraft is still travelling through all the red and yellow zones.i have tagged the aircraft_icon.png and rada.jpg images which have been used in the code. can somebody help me out with this?


I am able to modify the chart setting to display the average data with a timescale of 30 minutes. However, when I export the csv file, it shows the reading of 15 seconds. How should I export the average per 30 minutes?
I live in thailand but out put temperature is 65.5 F
how to set match thailand
Yes, in my company that I own
35%
Yes, for someone else (or Univ.)
21%
Only for free, for charities
13%
Only in my charitable foundation
5%
No, I'd just play, travel, & relax
25%
15668 votes
so far, I could sign in with username and password to my private thingspeak account. Today, however, thingspeak rediverts me to the login page of my university (domain unipi.it). Having entered username and password there, I am now connected to matlab but thingspeak again asks me for username and password. How to proceed?
your support is highly appreciated.
I am getting a NaT from the datetime function because it doesn't interpretp the date as a date/time?
I currently use this data (time) as this:
{'2023-07-26T23:00:00Z'}
{'2023-07-26T23:30:00Z'}
{'2023-07-27' }
{'2023-07-27T00:30:00Z'}
{'2023-07-27T01:00:00Z'}
and I get tStamps as this:
27-Jul-2023 09:00:00
27-Jul-2023 09:30:00
NaT %how do I not get this NaT? but 27-Jul-2023 10:00:00 which is 27-Jul-2023 00:00:00 gmt/utc
27-Jul-2023 10:30:00
27-Jul-2023 11:00:00
using this code for the datetime function
infmt ='yyyy-MM-dd''T''HH:mm:00Z';
tStamps = datetime(time,"InputFormat",infmt,'TimeZone','Australia/Brisbane');
Since 4 days ago, ThingTweet has stopped sending messages to my Twitter account.
Good morning,
I am working on a smart garden project with an Arduino MKR WIFI 1010 and I am using Thingspeak as dashboard for monitoring some quantities (e.g. temperature, humidity, moisture, etc.). However, I would like to add a widget in order to change the state of my relay connected to the waterpump, for example if the variable "waterpump_state" is 0 turn off the pump, otherwise turning on. Do you think is it possible to implement it on Thingspeak? Among the predefined widget I have not found any useful in this sense.
Thanks in advance,
Lorenzo
i want to make a gps tracker with gps data from thingspeak..can i get the data realtime and implement it with google maps api?
Unable to sign in to ThingSpeak. Retry in a few minutes
I am trying to read some sensors from Atlas Scientific using their software.
It has instructions to connect to adafruit and mosquitto brokers, but I didn't see instructions to connect to a device in ThingSpeak
Has anyone being able to connect to the Atlas Scietific Software?
how to generate c code from simuling for using it with pic 24 microcinroller
Hello,
I am bit new here. I have tried to integrate a sample data from TTN to thingspeak but its not working. I am getting desired data in TTN Payload and uplink but its not reflecting here in thingspeak. Is it the timescale? How to trouble shoot this issue? How can i know that i am receieving the data? or where to check it? Is there anyway? I am attaching the screenshot here. Thank You
I am remotely monitoring solar energy. My monitors shut off at night to conserve battery power, ending data being sent to ThingSpeak, which is fine. I do want to be alerted quickly though during the day when data should be coming in. How can I do this? ReAct doesn't have any way to limit when actions will happen and TimeControl doesn't seem to be able to only perform during certain hours either. I've looked for examples where Matlab analysis might perform a task between certain hours but can't seem to find anything. FWIW, an email would be the preferred method of alert.
Kindly help me correct this code to function properly. I am just learning MATLAB. i cannot get the output in abc frame. This is the code:
%----------- Define input and state parameters-----------------------------
clc
v_dc = 350; % DC input voltage in V
m = 0.841; % modulation index
C = 4000e-6; % DC buss capacitance in uf
L_1 = 2.5e-3; % Inverter side inductance in mH
L_2 = 2.5e-3; % Load side inductance in mH
L = 0; % load inductance
C_f = 10e-6; % filter capacitance in uf
R_f = 0.7; % damping resistance in ohms
R_L = 20; % load resistance in ohms
f_s = 10e3; % switching frequency
f = 60; % System frequency
R_s = 0.01; % Capacitance of the DC circuit
I_d = 8.594; % steady state current
w = 2*pi*f; % System angular Frequency
% Define initial steady state values
v_c = 349.4; i_d = 8.594; i_q = -0.213; v_df = 285; v_qf = -120; i_Ld = 8.594; i_Lq = 0.85;
%------------------S V P W M Generator-------------------------------------
% Define reference vector Uref
U_mag = m*v_dc/2; % Magnitude of Uref
% Define switching vectors
U1 = [v_dc/2;0]; % Vector Q1
U2 = [v_dc/4;sqrt(3)*v_dc/4]; % Vector Q2
U3 = [-v_dc/4;sqrt(3)*v_dc/4]; % Vector Q3
U4 = [-v_dc/2;0]; % Vector Q4
U5 = [-v_dc/4;-sqrt(3)*v_dc/4]; % Vector Q5
U6 = [v_dc/4;-sqrt(3)*v_dc/4]; % Vector Q6
% Define sector angles
theta1 = pi/6;
theta2 = pi/2;
theta3 = 5*pi/6;
theta4 = 7*pi/6;
theta5 = 3*pi/2;
theta6 = 11*pi/6;
% Define duty cycles for each switch using a for loop
for t=0:1/f_s:1/f % Time variable from 0 to one cycle of system frequency with steps of switching frequency
U_phase = w*t; % Phase of Uref (t is time variable)
U_alpha = U_mag*cos(U_phase); % Alpha component of Uref
U_beta = U_mag*sin(U_phase); % Beta component of Uref
if (0 <= U_phase) && (U_phase < theta1) % Sector 1
T1 = (sqrt(3)*U_beta + U_alpha)/(2*v_dc);
T2 = (-sqrt(3)*U_beta + U_alpha)/(2*v_dc);
T0 = 1 - T1 - T2;
d_a(round(t)+1) = T1 + T0/2;
d_b(round(t)+1) = T2 + T0/2;
d_c(round(t)+1) = T0/2;
elseif (theta1 <= U_phase) && (U_phase < theta2) % Sector 2
T3 = (sqrt(3)*U_beta - U_alpha)/(2*v_dc);
T2 = (sqrt(3)*U_beta + U_alpha)/(2*v_dc);
T0 = 1 - T3 - T2;
d_a(round(t)+1) = T0/2;
d_b(round(t)+1) = T2 + T0/2;
d_c(round(t)+1) = T3 + T0/2;
elseif (theta2 <= U_phase) && (U_phase < theta3) % Sector 3
T3 = (sqrt(3)*U_beta - U_alpha)/(2*v_dc);
T4 = (-sqrt(3)*U_beta - U_alpha)/(2*v_dc);
T0 = 1 - T3 - T4;
d_a(round(t)+1) = T0/2;
d_b(round(t)+1) = T0/2;
d_c(round(t)+1) = T3 + T0/2;
elseif (theta3 <= U_phase) && (U_phase < theta4) % Sector 4
T5 = (-sqrt(3)*U_beta + U_alpha)/(2*v_dc);
T4 = (-sqrt(3)*U_beta - U_alpha)/(2*v_dc);
T0 = 1 - T5 - T4;
d_a(round(t)+1) = T5 + T0/2;
d_b(round(t)+1) = T0/2;
d_c(round(t)+1) = T4 + T0/2;
elseif (theta4 <= U_phase) && (U_phase < theta5) % Sector 5
T5 = (-sqrt(3)*U_beta + U_alpha)/(2*v_dc);
T6 = (sqrt(3)*U_beta + U_alpha)/(2*v_dc);
T0 = 1 - T5 - T6;
d_a(round(t)+1) = T5 + T0/2;
d_b(round(t)+1) = T6 + T0/2;
d_c(round(t)+1) = T0/2;
elseif (theta5 <= U_phase) && (U_phase < theta6) % Sector 6
T1 = (sqrt(3)*U_beta + U_alpha)/(2*v_dc);
T6 = (sqrt(3)*U_beta - U_alpha)/(2*v_dc);
T0 = 1 - T1 - T6;
d_a(round(t)+1) = T1 + T0/2;
d_b(round(t)+1) = T0/2;
d_c(round(t)+1) = T6 + T0/2;
end
end
%-------------------------Define system matrices---------------------------
% Create Three-phase SVPWM VSI Inverter
% System matrix Nx-by-Nx matrix
A = [-1/(C*R_s),-sqrt(3)*m/(2*C),0,0,0,0,0;
sqrt(3)*m/(3*L_1),-R_f/(3*L_1),w,-1/(2*L_1),-sqrt(3)/(6*L_1),-R_f/(3*L_1),0;
0,-w,-R_f/(3*L_1),-sqrt(3)/(6*L_1),-1/(2*L_1),0,R_f/(3*L_1);
0,1/(2*C_f),-sqrt(3)/(6*C_f),0,w,-1/(2*C_f),sqrt(3)/(6*C_f);
0,sqrt(3)/(6*C_f),1/(2*C_f),-w,0,-sqrt(3)/(6*C_f),-1/(2*C_f);
0,R_f/(3*(L_2+L)),0,1/(2*(L_2+L)),sqrt(3)/(6*(L_2+L)),((-3*R_L-R_f)/(3*(L_2+L))),w;
0, 0, R_f/(3*(L_2+L)), -sqrt(3)/(6*(L_2+L)), 1/(2*(L_2+L)), -w, ((-3*R_L-R_f)/(3*(L_2+L)))];
% Define input matrix
B = [1/(C*R_s),-sqrt(3)*i_d/(2*C);d_a*v_dc,(sqrt(3)*v_c)/L_1;d_b*v_dc,0;d_c*v_dc,0;0,0;0,0;0,0]; % Nx-by-Nu input matrix
% Define output matrix
C = [0 1 0 0 0 0 0; % Ny-by-Nx matrix
0 0 1 0 0 0 0;
0 0 0 1 0 0 0;
0 0 0 0 1 0 0;
0 0 0 0 0 1 0;
0 0 0 0 0 0 1];
% Feedthrough matrix
D = zeros(6, 2); % Ny-by-Nu matrix
% create state-space model object
sys = ss(A,B,C,D);
% Define initial conditions and input
x0 = [v_c; i_d; i_q; v_df; v_qf; i_Ld; i_Lq]; % Initial state vector
t = 0:1e-6:0.5; % Time vector for simulation
u = repmat([v_dc;m],1,length(t)); % repeat u for each time step
% Simulate the system
[y, ~, x] = lsim(sys, u, t, x0);
% Extract the states
v_c_sim = x(:, 1);
i_d_sim = x(:, 2);
i_q_sim = x(:, 3);
v_df_sim = x(:, 4);
v_qf_sim = x(:, 5);
i_Ld_sim = x(:, 6);
i_Lq_sim = x(:, 7);
% Extract the outputs
v_abc_sim = y(:, 1:3);
i_abc_sim = y(:, 4:6);
v_dq_sim = y(:, 4:5);
i_dq_sim = y(:, 2:3);
% Plot the variables
figure;
subplot(4, 2, 1);
plot(t, v_c_sim);
xlabel('Time');
ylabel('v_c');
title('Capacitor Voltage');
subplot(4, 2, 2);
plot(t, i_d_sim);
xlabel('Time');
ylabel('i_d');
title('d-Axis Current');
subplot(4, 2, 3);
plot(t, i_q_sim);
xlabel('Time');
ylabel('i_q');
title('q-Axis Current');
subplot(4, 2, 4);
plot(t, v_df_sim);
xlabel('Time');
ylabel('v_df');
title('d-Component Filter Voltage');
subplot(4, 2, 5);
plot(t, v_qf_sim);
xlabel('Time');
ylabel('v_qf');
title('q-Component Filter Voltage');
subplot(4, 2, 6);
plot(t, i_Ld_sim);
xlabel('Time');
ylabel('i_Ld');
title('d-Axis Load Current');
subplot(4, 2, 7);
plot(t, i_Lq_sim);
xlabel('Time');
ylabel('i_Lq');
title('q-Axis Load Current');
% Perform coordinate transformation from dq frame to abc frame for currents
i_a_sim = cos(w*t)*i_d_sim - sin(w*t)*i_q_sim;
i_b_sim = cos(w*t - 2*pi/3)*i_d_sim - sin(w*t - 2*pi/3)*i_q_sim;
i_c_sim = cos(w*t + 2*pi/3)*i_d_sim - sin(w*t + 2*pi/3)*i_q_sim;
% Perform coordinate transformation from dq frame to abc frame for voltages
v_a_sim = cos(w*t)*v_df_sim - sin(w*t)*v_qf_sim;
v_b_sim = cos(w*t - 2*pi/3)*v_df_sim - sin(w*t - 2*pi/3)*v_qf_sim;
v_c_sim = cos(w*t + 2*pi/3)*v_df_sim - sin(w*t + 2*pi/3)*v_qf_sim;
Many thanks
Hello! I am working on a project involving the use of CNNs for text classification. I found a very clear example on MathWorks that demonstrates how to transform text using an encoding process and provide it as input to a neural network. One of the initial layers of the network is the word embedding layer, which is responsible for capturing the semantic relationships between words. I'm wondering how this layer can work without directly using the words, but instead working with a numerical representation of them.
Thank you very much in advance to anyone who will reply to me.