Month: June 2025
Serial Receive Block Variable Data Size
Hi,
I’m working with a data logger that sends measurements over a USB serial interface. I’d like to read the data using Simulink’s Serial Receive block, but I’m running into a problem: the block requires a fixed message length, while my measurements vary in digit count, so each message can be longer or shorter.
I’ve tried setting a maximum data size, but then the block misses the terminator since it relies solely on the fixed length. I’ve also experimented with a smaller fixed size in non-blocking mode, buffering incoming bytes and then parsing complete messages—but approaches that i tried introduce delays that are unacceptable for my application.
I’d appreciate any suggestions or solutions to handle variable-length serial messages in Simulink without significant latency.Hi,
I’m working with a data logger that sends measurements over a USB serial interface. I’d like to read the data using Simulink’s Serial Receive block, but I’m running into a problem: the block requires a fixed message length, while my measurements vary in digit count, so each message can be longer or shorter.
I’ve tried setting a maximum data size, but then the block misses the terminator since it relies solely on the fixed length. I’ve also experimented with a smaller fixed size in non-blocking mode, buffering incoming bytes and then parsing complete messages—but approaches that i tried introduce delays that are unacceptable for my application.
I’d appreciate any suggestions or solutions to handle variable-length serial messages in Simulink without significant latency. Hi,
I’m working with a data logger that sends measurements over a USB serial interface. I’d like to read the data using Simulink’s Serial Receive block, but I’m running into a problem: the block requires a fixed message length, while my measurements vary in digit count, so each message can be longer or shorter.
I’ve tried setting a maximum data size, but then the block misses the terminator since it relies solely on the fixed length. I’ve also experimented with a smaller fixed size in non-blocking mode, buffering incoming bytes and then parsing complete messages—but approaches that i tried introduce delays that are unacceptable for my application.
I’d appreciate any suggestions or solutions to handle variable-length serial messages in Simulink without significant latency. serial receive, serielle schnitstelle, variable data size MATLAB Answers — New Questions
Please Help! : Unrecognized function or variable ‘crandn’.
% simple SIMO system
m = 2;
l = 20;
alphabet = [ exp(j*pi/4); exp(j*3/4*pi); exp(j*5/4*pi); exp(j*7/4*pi) ];
h0 = crandn(m, 1);
h1 = crandn(l, 1);
h2 = crandn(m, l);
hmatrix1 = diag(h1);
ptx = 1;
vinit = alphabet(round(4*rand(l, 1)+0.5));
htotinit = (h0+h2*diag(vinit)*h1)*sqrt(ptx);
ginit = htotinit/(1+htotinit’*htotinit);
mseinit = 1/(1+htotinit’*htotinit);
gold = ginit;
vold = vinit;
mseold = mseinit;
iter = 1;
while 1 == 1,
a = hmatrix1’*h2’*gold;
b = gold’*h0-1;
vcand = b/abs(b)*a./abs(a);
vnew = zeros(l, 1);
vnew = sqrt(2)*((real(vnew) > 0)-0.5+j*(imag(vnew) > 0)-0.5);
if round(norm(vnew-vold)) == 0,
break;
end
htotnew = (h0+h2*diag(vnew)*h1)*sqrt(ptx);
gold = 1/(1+htotnew’*htotnew)*htotnew;
mseold = 1/(1+htotnew’*htotnew);
msenew = mseold
vold = vnew;
iter = iter+1;
end
disp(sprintf("MSEinit=%f", mseinit))
disp(sprintf("MSEupdated=%f", msenew))
disp(sprintf("number of iterations=%i", iter))
Why is my matlab showing this error?
I am able to run my code here but not in my matlab program.
Can anyone help?% simple SIMO system
m = 2;
l = 20;
alphabet = [ exp(j*pi/4); exp(j*3/4*pi); exp(j*5/4*pi); exp(j*7/4*pi) ];
h0 = crandn(m, 1);
h1 = crandn(l, 1);
h2 = crandn(m, l);
hmatrix1 = diag(h1);
ptx = 1;
vinit = alphabet(round(4*rand(l, 1)+0.5));
htotinit = (h0+h2*diag(vinit)*h1)*sqrt(ptx);
ginit = htotinit/(1+htotinit’*htotinit);
mseinit = 1/(1+htotinit’*htotinit);
gold = ginit;
vold = vinit;
mseold = mseinit;
iter = 1;
while 1 == 1,
a = hmatrix1’*h2’*gold;
b = gold’*h0-1;
vcand = b/abs(b)*a./abs(a);
vnew = zeros(l, 1);
vnew = sqrt(2)*((real(vnew) > 0)-0.5+j*(imag(vnew) > 0)-0.5);
if round(norm(vnew-vold)) == 0,
break;
end
htotnew = (h0+h2*diag(vnew)*h1)*sqrt(ptx);
gold = 1/(1+htotnew’*htotnew)*htotnew;
mseold = 1/(1+htotnew’*htotnew);
msenew = mseold
vold = vnew;
iter = iter+1;
end
disp(sprintf("MSEinit=%f", mseinit))
disp(sprintf("MSEupdated=%f", msenew))
disp(sprintf("number of iterations=%i", iter))
Why is my matlab showing this error?
I am able to run my code here but not in my matlab program.
Can anyone help? % simple SIMO system
m = 2;
l = 20;
alphabet = [ exp(j*pi/4); exp(j*3/4*pi); exp(j*5/4*pi); exp(j*7/4*pi) ];
h0 = crandn(m, 1);
h1 = crandn(l, 1);
h2 = crandn(m, l);
hmatrix1 = diag(h1);
ptx = 1;
vinit = alphabet(round(4*rand(l, 1)+0.5));
htotinit = (h0+h2*diag(vinit)*h1)*sqrt(ptx);
ginit = htotinit/(1+htotinit’*htotinit);
mseinit = 1/(1+htotinit’*htotinit);
gold = ginit;
vold = vinit;
mseold = mseinit;
iter = 1;
while 1 == 1,
a = hmatrix1’*h2’*gold;
b = gold’*h0-1;
vcand = b/abs(b)*a./abs(a);
vnew = zeros(l, 1);
vnew = sqrt(2)*((real(vnew) > 0)-0.5+j*(imag(vnew) > 0)-0.5);
if round(norm(vnew-vold)) == 0,
break;
end
htotnew = (h0+h2*diag(vnew)*h1)*sqrt(ptx);
gold = 1/(1+htotnew’*htotnew)*htotnew;
mseold = 1/(1+htotnew’*htotnew);
msenew = mseold
vold = vnew;
iter = iter+1;
end
disp(sprintf("MSEinit=%f", mseinit))
disp(sprintf("MSEupdated=%f", msenew))
disp(sprintf("number of iterations=%i", iter))
Why is my matlab showing this error?
I am able to run my code here but not in my matlab program.
Can anyone help? error, matlab function, missing toolbox MATLAB Answers — New Questions
Error in powergui while running a PV array model, Error reported by S-function ‘fun_spssw_discc_DSS’.
I am runnin a grid connected PV array (number of PV module connected in series and parallel) model, for fault analysis in PV array. While running simulation i got an error message:
=== Simulation (Elapsed: 56 sec) ===
Error:An error occurred while running the simulation and the simulation was terminated
Caused by:
Error reported by S-function ‘sfun_spssw_discc_DSS’ in ‘file_name/powergui/EquivalentModel1/State-Space’:
Nonlinear element(s) (RnonLin, Lsat) failed to converge after 100 iterations, t=0.80005 sec
How to rectify the error, and what is the cause of error, as error is reported in powergui. Please suggest something.I am runnin a grid connected PV array (number of PV module connected in series and parallel) model, for fault analysis in PV array. While running simulation i got an error message:
=== Simulation (Elapsed: 56 sec) ===
Error:An error occurred while running the simulation and the simulation was terminated
Caused by:
Error reported by S-function ‘sfun_spssw_discc_DSS’ in ‘file_name/powergui/EquivalentModel1/State-Space’:
Nonlinear element(s) (RnonLin, Lsat) failed to converge after 100 iterations, t=0.80005 sec
How to rectify the error, and what is the cause of error, as error is reported in powergui. Please suggest something. I am runnin a grid connected PV array (number of PV module connected in series and parallel) model, for fault analysis in PV array. While running simulation i got an error message:
=== Simulation (Elapsed: 56 sec) ===
Error:An error occurred while running the simulation and the simulation was terminated
Caused by:
Error reported by S-function ‘sfun_spssw_discc_DSS’ in ‘file_name/powergui/EquivalentModel1/State-Space’:
Nonlinear element(s) (RnonLin, Lsat) failed to converge after 100 iterations, t=0.80005 sec
How to rectify the error, and what is the cause of error, as error is reported in powergui. Please suggest something. powergui, simulink, pv array, s-function, nonlinear element, matlab MATLAB Answers — New Questions
Hello everyone, I need help. I am working on a robot arm project using MATLAB and a webcam to detect colors. Do you have any lessons or tutorials for me?
Hello everyone, I’m working on a robot arm project using MATLAB and Arduino. I use my phone as a webcam to detect colors (like red or green). If the system detects a red object, the robot arm moves and picks it up, then puts it in the red storage area.
Now, I want to improve the project. Instead of the robot always picking red automatically, I want to click on an object in the camera video (GUI in MATLAB) to choose which color to pick — for example, if I click on a red object, it will pick up red. If I click on green, it will pick up green.
I find it hard to research or find tutorials. Can someone help me or guide me with examples or lessons?Hello everyone, I’m working on a robot arm project using MATLAB and Arduino. I use my phone as a webcam to detect colors (like red or green). If the system detects a red object, the robot arm moves and picks it up, then puts it in the red storage area.
Now, I want to improve the project. Instead of the robot always picking red automatically, I want to click on an object in the camera video (GUI in MATLAB) to choose which color to pick — for example, if I click on a red object, it will pick up red. If I click on green, it will pick up green.
I find it hard to research or find tutorials. Can someone help me or guide me with examples or lessons? Hello everyone, I’m working on a robot arm project using MATLAB and Arduino. I use my phone as a webcam to detect colors (like red or green). If the system detects a red object, the robot arm moves and picks it up, then puts it in the red storage area.
Now, I want to improve the project. Instead of the robot always picking red automatically, I want to click on an object in the camera video (GUI in MATLAB) to choose which color to pick — for example, if I click on a red object, it will pick up red. If I click on green, it will pick up green.
I find it hard to research or find tutorials. Can someone help me or guide me with examples or lessons? arduino, arm, webcam, color, detection, color segmentation MATLAB Answers — New Questions
How do you match the width of figures in a tiledlayout when using axis equal?
There are 4 figures combined in a tiledlayout. The respective ratio of their dimensions is 1:1, using axis equal. However, their widths do not match. How can this be adapted? See the MWE:
clear variables; close all; clc;
tiledlayout(4,1)
amplitudes = [200e-3,50e-3,10e-3,200e-6];
wavelenghts = [50,500e-3,50e-3,500e-6];
for i = 1:numel(amplitudes)
nexttile
axis equal
x = 0:(wavelenghts(i)/100):(wavelenghts(i)/2);
y = amplitudes(i)*(1-cospi(2*1/wavelenghts(i)*x));
hold on
area(-x,y)
area(x,y)
xlim([-1 1]*wavelenghts(i)/2)
ylim([0 max(y)])
clear x y;
endThere are 4 figures combined in a tiledlayout. The respective ratio of their dimensions is 1:1, using axis equal. However, their widths do not match. How can this be adapted? See the MWE:
clear variables; close all; clc;
tiledlayout(4,1)
amplitudes = [200e-3,50e-3,10e-3,200e-6];
wavelenghts = [50,500e-3,50e-3,500e-6];
for i = 1:numel(amplitudes)
nexttile
axis equal
x = 0:(wavelenghts(i)/100):(wavelenghts(i)/2);
y = amplitudes(i)*(1-cospi(2*1/wavelenghts(i)*x));
hold on
area(-x,y)
area(x,y)
xlim([-1 1]*wavelenghts(i)/2)
ylim([0 max(y)])
clear x y;
end There are 4 figures combined in a tiledlayout. The respective ratio of their dimensions is 1:1, using axis equal. However, their widths do not match. How can this be adapted? See the MWE:
clear variables; close all; clc;
tiledlayout(4,1)
amplitudes = [200e-3,50e-3,10e-3,200e-6];
wavelenghts = [50,500e-3,50e-3,500e-6];
for i = 1:numel(amplitudes)
nexttile
axis equal
x = 0:(wavelenghts(i)/100):(wavelenghts(i)/2);
y = amplitudes(i)*(1-cospi(2*1/wavelenghts(i)*x));
hold on
area(-x,y)
area(x,y)
xlim([-1 1]*wavelenghts(i)/2)
ylim([0 max(y)])
clear x y;
end matlab, figure, tiledlayout, axis euqal MATLAB Answers — New Questions
Automating Microsoft 365 with PowerShell Second Edition
Completely Revised Version of Automating Microsoft 365 with PowerShell

Last year, the Office 365 for IT Pros team took the decision to carve out a chapter covering using PowerShell with Microsoft 365 and create a separate eBook. This doesn’t mean that the Office 365 for IT Pros eBook doesn’t include PowerShell examples because it still does feature many examples, especially for Teams, SharePoint Online, and Exchange Online. However, we were conscious of the growing influence and importance of the Microsoft Graph APIs and the Microsoft Graph PowerShell SDK and wanted to reflect the critical nature of these components. There’s no doubt that if tenant administrators understand how to interact with Microsoft 365 resources via the APIs (and PowerShell makes this relatively straightforward), it’s much easier to understand how Microsoft 365 works.
This realization brought us to create Automating Microsoft 365 with PowerShell, which we believe is the most complete treatment of using PowerShell to get things done inside a Microsoft 365 tenant that’s available today. Certainly, when you combine all the examples from Automating Office 365 with PowerShell and Office 365 for IT Pros, there’s lots of informative and useful PowerShell code to automate operations in a Microsoft 365 tenant.
An Imperfect First Edition
The first edition wasn’t perfect. Pulling out a bunch of PowerShell content from a book and attempting to make it a coherent story is always a challenge. The challenge becomes more complicated with the changes Microsoft made to the Graph APIs and the Microsoft Graph PowerShell SDK, many of which were to fix problems that should never have happened.
We’ve been working to make the coverage smoother, more informative, and more impactful since the launch of the first edition and have just completed a full end-to-end review of everything in the book. Code has been corrected, tightened, and expanded to make it more useful, and we have added a bunch of new material. We even included the late-breaking news that Microsoft has set a retirement date for the AzureAD module for mid-October 2025. The need for good information about how to migrate scripts that use the AzureAD module to the Microsoft Graph PowerShell SDK has never been more obvious.
The result of that work is delivered in the second edition, which is available today.
Second Edition Available Free to Subscribers
Because we appreciate the support of people who subscribe to our books and understand that sometimes the quality of the first edition of Automating Microsoft 365 with PowerShell wasn’t where we wanted it to be, we are making the second edition available free of charge to anyone who subscribed to the first edition. If you’re a subscriber, all you need to do is use the download link in the receipt emailed to you when you bought the subscription. This link always downloads the latest version of the book, and it will now download the second edition files (EPUB and PDF).
Automating Microsoft 365 with PowerShell is also included in the Office 365 for IT Pros eBook bundle. Subscribers to Office 365 for IT Pros 2026 edition, which we anticipate releasing tomorrow (July 1, 2025) will get the second edition along with the files for Office 365 for IT Pros (2026 edition). We’re also making the second edition available to subscribers to Office 365 for IT Pros (2025 edition). Once again, use the download link in your receipt to fetch the updated files.
Subscribers who download the second edition are eligible to receive updates up to and including June 30, 2026.
Regretfully, we cannot update the paperback version of the book that people have bought. However, the updated text is now available from Amazon.com, for those who like their technical material in a printed form.
Looking Forward to 2026
We’ll continue to work on the second edition of Automating Microsoft 365 with PowerShell over the coming months. There will be new Graph APIs to cover, gaps to fill in, and we know that the Microsoft Graph PowerShell SDK has some work to do to restore its reputation with customers. Nearly four million downloads of V2.25 of the Microsoft Graph PowerShell SDK speak to its popularity and usefulness. What everyone needs now is better quality and stability in the Graph APIs and SDK. When Microsoft delivers new versions, we’ll be there to parse, analyze, and report on the news.
Need some assistance to write and manage PowerShell scripts for Microsoft 365? Get a copy of the Automating Microsoft 365 with PowerShell eBook, available standalone or as part of the Office 365 for IT Pros eBook bundle.
Reading column vectors from table with header text as variable name
I have an excel file with first row as header name for the corresponding column, each column has 4999 entries and 85 different readings. I want to load all the column vectors as a seperate variable. The variable name should be same as the header name from the excel file.
T = readtable("sample_data.csv");
S = T.Properties.VariableNames;
for i = 1:length(S)
assignin("base", S{i}, T.(S{i}))
end
This is what I came up with, but someone suggested not to use assignin command. Can some one suggest better alternative to this, also I don’t want to seperate the column vectors manually.
Thank you.I have an excel file with first row as header name for the corresponding column, each column has 4999 entries and 85 different readings. I want to load all the column vectors as a seperate variable. The variable name should be same as the header name from the excel file.
T = readtable("sample_data.csv");
S = T.Properties.VariableNames;
for i = 1:length(S)
assignin("base", S{i}, T.(S{i}))
end
This is what I came up with, but someone suggested not to use assignin command. Can some one suggest better alternative to this, also I don’t want to seperate the column vectors manually.
Thank you. I have an excel file with first row as header name for the corresponding column, each column has 4999 entries and 85 different readings. I want to load all the column vectors as a seperate variable. The variable name should be same as the header name from the excel file.
T = readtable("sample_data.csv");
S = T.Properties.VariableNames;
for i = 1:length(S)
assignin("base", S{i}, T.(S{i}))
end
This is what I came up with, but someone suggested not to use assignin command. Can some one suggest better alternative to this, also I don’t want to seperate the column vectors manually.
Thank you. importing excel data, variables, text file, solve MATLAB Answers — New Questions
Why cannot i learn simscape battery on ramp?
Post Content Post Content matlab MATLAB Answers — New Questions
Changing from 2D plot to 3D plot and to STL file
Hello everyone, I have these following codes: All of them creates a 2D plot, now I really want to create a 3D plot with Z: the thickness of plot XY. Then I want to convert it to STL file.
clc;
clear all;
close all;
% Input
R0 = 0.15;
a = 25*pi/180;
theta = 0:pi/1000:3*pi;
theta2 = theta + pi;
delta = pi/2;
%% Curl 1
R1 = R0*exp(a*(theta-delta));
X1 = R1.*cos(theta-delta);
Y1 = R1.*sin(theta-delta);
%% Curl 2
R2 = R0*exp(a*(theta-delta));
X2 = R2.*cos(theta);
Y2 = R2.*sin(theta);
%% Curl 3
R3 = R0*exp(a*(theta2-delta));
X3 = R1.*cos(theta2-delta);
Y3 = R1.*sin(theta2-delta);
%% Curl 4
R4 = R0*exp(a*(theta2 – delta));
X4 = R2.*cos(theta2);
Y4 = R2.*sin(theta2);
%% Extra plot (arc)
radius = R0*exp(a*(3*pi-pi/2));
a1 = pi/2;
b1 = pi;
h = 0;
k = 0;
t1 = linspace(a1,b1,3001);
X_arc1 = radius*cos(t1) + h;
Y_arc1 = radius*sin(t1) + k;
a2 = -pi/2;
b2 = 0;
t2 = linspace(a2,b2,3001);
X_arc2 = radius*cos(t2) + h;
Y_arc2 = radius*sin(t2) + k;
R5 = 0.05;
X5 = R5.*cos(theta);
Y5 = R5.*sin(theta);
%% Plot
figure(1);
plot(X1,Y1, ‘k’, ‘LineWidth’, 3); hold on
plot(X2,Y2, ‘k’, ‘LineWidth’, 3); hold on
P1 = plot(X_arc1, Y_arc1, ‘k’);
set(P1,’linewidth’,3);
axis([h-radius-1 h+radius+1 k-radius-1 k+radius+1])
axis square; hold on;
plot(X3,Y3, ‘k’, ‘LineWidth’, 3);hold on
plot(X4,Y4, ‘k’, ‘LineWidth’, 3);hold on
plot(X5,Y5, ‘k’, ‘LineWidth’, 3); hold on
P2 = plot(X_arc2, Y_arc2, ‘k’);
set(P2,’linewidth’,3);
axis(‘equal’);
title(‘Two-arm equiangular spiral antenna’, ‘fontsize’,14, ‘fontweight’,’bold’);
hold on
%% Filling with black color
patch([X1; flipud(X2)], [Y1; flipud(Y2)],’k’);
patch([X3; flipud(X4)], [Y3; flipud(Y4)],’k’);
X_arc1_bonus = horzcat(X_arc1, -4, -2.2, -2, -1, -0.3);
Y_arc1_bonus = horzcat(Y_arc1, 0.8, 2.2, 2.6, 3, 3.2);
fill(X_arc1_bonus, Y_arc1_bonus,’k’);
X_arc2_bonus = horzcat(X_arc2, 4, 2.2, 2, 1, 0.3);
Y_arc2_bonus = horzcat(Y_arc2, -0.8, -2.2, -2.6, -3, -3.2);
fill(X_arc2_bonus, Y_arc2_bonus,’k’);Hello everyone, I have these following codes: All of them creates a 2D plot, now I really want to create a 3D plot with Z: the thickness of plot XY. Then I want to convert it to STL file.
clc;
clear all;
close all;
% Input
R0 = 0.15;
a = 25*pi/180;
theta = 0:pi/1000:3*pi;
theta2 = theta + pi;
delta = pi/2;
%% Curl 1
R1 = R0*exp(a*(theta-delta));
X1 = R1.*cos(theta-delta);
Y1 = R1.*sin(theta-delta);
%% Curl 2
R2 = R0*exp(a*(theta-delta));
X2 = R2.*cos(theta);
Y2 = R2.*sin(theta);
%% Curl 3
R3 = R0*exp(a*(theta2-delta));
X3 = R1.*cos(theta2-delta);
Y3 = R1.*sin(theta2-delta);
%% Curl 4
R4 = R0*exp(a*(theta2 – delta));
X4 = R2.*cos(theta2);
Y4 = R2.*sin(theta2);
%% Extra plot (arc)
radius = R0*exp(a*(3*pi-pi/2));
a1 = pi/2;
b1 = pi;
h = 0;
k = 0;
t1 = linspace(a1,b1,3001);
X_arc1 = radius*cos(t1) + h;
Y_arc1 = radius*sin(t1) + k;
a2 = -pi/2;
b2 = 0;
t2 = linspace(a2,b2,3001);
X_arc2 = radius*cos(t2) + h;
Y_arc2 = radius*sin(t2) + k;
R5 = 0.05;
X5 = R5.*cos(theta);
Y5 = R5.*sin(theta);
%% Plot
figure(1);
plot(X1,Y1, ‘k’, ‘LineWidth’, 3); hold on
plot(X2,Y2, ‘k’, ‘LineWidth’, 3); hold on
P1 = plot(X_arc1, Y_arc1, ‘k’);
set(P1,’linewidth’,3);
axis([h-radius-1 h+radius+1 k-radius-1 k+radius+1])
axis square; hold on;
plot(X3,Y3, ‘k’, ‘LineWidth’, 3);hold on
plot(X4,Y4, ‘k’, ‘LineWidth’, 3);hold on
plot(X5,Y5, ‘k’, ‘LineWidth’, 3); hold on
P2 = plot(X_arc2, Y_arc2, ‘k’);
set(P2,’linewidth’,3);
axis(‘equal’);
title(‘Two-arm equiangular spiral antenna’, ‘fontsize’,14, ‘fontweight’,’bold’);
hold on
%% Filling with black color
patch([X1; flipud(X2)], [Y1; flipud(Y2)],’k’);
patch([X3; flipud(X4)], [Y3; flipud(Y4)],’k’);
X_arc1_bonus = horzcat(X_arc1, -4, -2.2, -2, -1, -0.3);
Y_arc1_bonus = horzcat(Y_arc1, 0.8, 2.2, 2.6, 3, 3.2);
fill(X_arc1_bonus, Y_arc1_bonus,’k’);
X_arc2_bonus = horzcat(X_arc2, 4, 2.2, 2, 1, 0.3);
Y_arc2_bonus = horzcat(Y_arc2, -0.8, -2.2, -2.6, -3, -3.2);
fill(X_arc2_bonus, Y_arc2_bonus,’k’); Hello everyone, I have these following codes: All of them creates a 2D plot, now I really want to create a 3D plot with Z: the thickness of plot XY. Then I want to convert it to STL file.
clc;
clear all;
close all;
% Input
R0 = 0.15;
a = 25*pi/180;
theta = 0:pi/1000:3*pi;
theta2 = theta + pi;
delta = pi/2;
%% Curl 1
R1 = R0*exp(a*(theta-delta));
X1 = R1.*cos(theta-delta);
Y1 = R1.*sin(theta-delta);
%% Curl 2
R2 = R0*exp(a*(theta-delta));
X2 = R2.*cos(theta);
Y2 = R2.*sin(theta);
%% Curl 3
R3 = R0*exp(a*(theta2-delta));
X3 = R1.*cos(theta2-delta);
Y3 = R1.*sin(theta2-delta);
%% Curl 4
R4 = R0*exp(a*(theta2 – delta));
X4 = R2.*cos(theta2);
Y4 = R2.*sin(theta2);
%% Extra plot (arc)
radius = R0*exp(a*(3*pi-pi/2));
a1 = pi/2;
b1 = pi;
h = 0;
k = 0;
t1 = linspace(a1,b1,3001);
X_arc1 = radius*cos(t1) + h;
Y_arc1 = radius*sin(t1) + k;
a2 = -pi/2;
b2 = 0;
t2 = linspace(a2,b2,3001);
X_arc2 = radius*cos(t2) + h;
Y_arc2 = radius*sin(t2) + k;
R5 = 0.05;
X5 = R5.*cos(theta);
Y5 = R5.*sin(theta);
%% Plot
figure(1);
plot(X1,Y1, ‘k’, ‘LineWidth’, 3); hold on
plot(X2,Y2, ‘k’, ‘LineWidth’, 3); hold on
P1 = plot(X_arc1, Y_arc1, ‘k’);
set(P1,’linewidth’,3);
axis([h-radius-1 h+radius+1 k-radius-1 k+radius+1])
axis square; hold on;
plot(X3,Y3, ‘k’, ‘LineWidth’, 3);hold on
plot(X4,Y4, ‘k’, ‘LineWidth’, 3);hold on
plot(X5,Y5, ‘k’, ‘LineWidth’, 3); hold on
P2 = plot(X_arc2, Y_arc2, ‘k’);
set(P2,’linewidth’,3);
axis(‘equal’);
title(‘Two-arm equiangular spiral antenna’, ‘fontsize’,14, ‘fontweight’,’bold’);
hold on
%% Filling with black color
patch([X1; flipud(X2)], [Y1; flipud(Y2)],’k’);
patch([X3; flipud(X4)], [Y3; flipud(Y4)],’k’);
X_arc1_bonus = horzcat(X_arc1, -4, -2.2, -2, -1, -0.3);
Y_arc1_bonus = horzcat(Y_arc1, 0.8, 2.2, 2.6, 3, 3.2);
fill(X_arc1_bonus, Y_arc1_bonus,’k’);
X_arc2_bonus = horzcat(X_arc2, 4, 2.2, 2, 1, 0.3);
Y_arc2_bonus = horzcat(Y_arc2, -0.8, -2.2, -2.6, -3, -3.2);
fill(X_arc2_bonus, Y_arc2_bonus,’k’); 2d plot to 3d plot MATLAB Answers — New Questions
Matlab Editor does not respond to keyboard inputs
Hi Everyone,
My Matlab editor stopped responding to most (but not all!) keyboard inputs. All letters+numbers stopped working, and SPACE as well, but BACKSPACE still works. And Ctrl+C/V also works, but not C or V???
Matlab editor is the only one with this problem, my command window does not have any problems.
I’m flabbergasted!
Laurens
ps. Version is R2013a, running on Windows 7 Professional, 64-bit.
ps #2. The problem disappears on restarting Matlab. I’m still very curious though, so if anyone has any ideas…Hi Everyone,
My Matlab editor stopped responding to most (but not all!) keyboard inputs. All letters+numbers stopped working, and SPACE as well, but BACKSPACE still works. And Ctrl+C/V also works, but not C or V???
Matlab editor is the only one with this problem, my command window does not have any problems.
I’m flabbergasted!
Laurens
ps. Version is R2013a, running on Windows 7 Professional, 64-bit.
ps #2. The problem disappears on restarting Matlab. I’m still very curious though, so if anyone has any ideas… Hi Everyone,
My Matlab editor stopped responding to most (but not all!) keyboard inputs. All letters+numbers stopped working, and SPACE as well, but BACKSPACE still works. And Ctrl+C/V also works, but not C or V???
Matlab editor is the only one with this problem, my command window does not have any problems.
I’m flabbergasted!
Laurens
ps. Version is R2013a, running on Windows 7 Professional, 64-bit.
ps #2. The problem disappears on restarting Matlab. I’m still very curious though, so if anyone has any ideas… keyboard, editor MATLAB Answers — New Questions
How to rotate domain, but the lon and lat are on the contour (not on the axis)
Dear all, as far we know Matlab will traditionally generate 4 white areas when using the following script on rotate domain:
figure;
p=pcolor(lon_rho,lat_rho,h2a);shading interp;
An example illustration is attached. Instead of generating a map like the illustration, I want the lon and lat to be directly placed on the generated contour, note the black numbers in the attachment (not on the matlab x and y axis). Is this possible?
and this is a perfect example of what I want to get:
https://discourse.julialang.org/t/how-to-plot-a-2d-rotated-array/47603/10Dear all, as far we know Matlab will traditionally generate 4 white areas when using the following script on rotate domain:
figure;
p=pcolor(lon_rho,lat_rho,h2a);shading interp;
An example illustration is attached. Instead of generating a map like the illustration, I want the lon and lat to be directly placed on the generated contour, note the black numbers in the attachment (not on the matlab x and y axis). Is this possible?
and this is a perfect example of what I want to get:
https://discourse.julialang.org/t/how-to-plot-a-2d-rotated-array/47603/10 Dear all, as far we know Matlab will traditionally generate 4 white areas when using the following script on rotate domain:
figure;
p=pcolor(lon_rho,lat_rho,h2a);shading interp;
An example illustration is attached. Instead of generating a map like the illustration, I want the lon and lat to be directly placed on the generated contour, note the black numbers in the attachment (not on the matlab x and y axis). Is this possible?
and this is a perfect example of what I want to get:
https://discourse.julialang.org/t/how-to-plot-a-2d-rotated-array/47603/10 rotate domain, pcolor, axis MATLAB Answers — New Questions
How to Add Measured Output Disturbance to my State Space Model for MPC Controller?
Hello Respectable Community,
I am looking for attention of experts from following background state space modeling and model predictive controller.
Subject: I want to add affect of "Zd" step disturbance to my current plant state space equation which will be use as measured disturbance in mpc controller block.
I am designing an MPC controller, which should be robust to disturbance rejection and I have a known Measured Disturbance which I want to add to "md", but I am getting some errors.
I have following state space equation of my plant, which I found using system identification technique.
%Transfer Function By System identification
num = [-1.324 6.6e05 -6.914e09 5.128e13 -1.054e19]
den = [1 1.99e04 1.371e09 1.145e13 4.037e17]
%Conversion to SS
plant = tf([num],[den], ‘OutputDelay’,1)
% Simplify the model to remove insignificant poles and zeros
SSpzt = ss(plant) %This gives continuous time linear state space model of TFpzt
Ac = SSpzt.A;
Bc = SSpzt.B;
Cc = SSpzt.C;
Dc = SSpzt.D;
Ts = 3.1309e-05 %Sampling time actual = 3.1309e-05
Td = 0.009; %time Delay baed on frequency data
%Contineous Model to discrete Statespace Matrices
SSpzt_dis = c2dm(Ac,Bc,Cc,Dc,Ts)
[Ad,Bd,Cd,Dd] = c2dm(Ac, Bc, Cc, Dc, Ts)
Dd = 0
sysdis = ss(Ad,Bd,Cd,Dd,Ts)
sysdis shows my plant discrete statespace model which i used to design mpc controller. but when I add md as step, it gives me following error and I know this is because I think I need to add some rows and coloum to my matrix B or C for measured disturbance, but I am not sure how to add them. So, I am asking here for help.
But when I use MPC Controller without md it works fine, but it is not robust to disturbance rejection, and my main concern is to eliminate the disturbance effectively. Even it doesn’t respond to disturbance. I am looking for help in this regards. Attached is the files of my design. First run PZTModel1.m file then load PID_Controller22_December, and DisRejection_27December files and open MPC_simulink1.Hello Respectable Community,
I am looking for attention of experts from following background state space modeling and model predictive controller.
Subject: I want to add affect of "Zd" step disturbance to my current plant state space equation which will be use as measured disturbance in mpc controller block.
I am designing an MPC controller, which should be robust to disturbance rejection and I have a known Measured Disturbance which I want to add to "md", but I am getting some errors.
I have following state space equation of my plant, which I found using system identification technique.
%Transfer Function By System identification
num = [-1.324 6.6e05 -6.914e09 5.128e13 -1.054e19]
den = [1 1.99e04 1.371e09 1.145e13 4.037e17]
%Conversion to SS
plant = tf([num],[den], ‘OutputDelay’,1)
% Simplify the model to remove insignificant poles and zeros
SSpzt = ss(plant) %This gives continuous time linear state space model of TFpzt
Ac = SSpzt.A;
Bc = SSpzt.B;
Cc = SSpzt.C;
Dc = SSpzt.D;
Ts = 3.1309e-05 %Sampling time actual = 3.1309e-05
Td = 0.009; %time Delay baed on frequency data
%Contineous Model to discrete Statespace Matrices
SSpzt_dis = c2dm(Ac,Bc,Cc,Dc,Ts)
[Ad,Bd,Cd,Dd] = c2dm(Ac, Bc, Cc, Dc, Ts)
Dd = 0
sysdis = ss(Ad,Bd,Cd,Dd,Ts)
sysdis shows my plant discrete statespace model which i used to design mpc controller. but when I add md as step, it gives me following error and I know this is because I think I need to add some rows and coloum to my matrix B or C for measured disturbance, but I am not sure how to add them. So, I am asking here for help.
But when I use MPC Controller without md it works fine, but it is not robust to disturbance rejection, and my main concern is to eliminate the disturbance effectively. Even it doesn’t respond to disturbance. I am looking for help in this regards. Attached is the files of my design. First run PZTModel1.m file then load PID_Controller22_December, and DisRejection_27December files and open MPC_simulink1. Hello Respectable Community,
I am looking for attention of experts from following background state space modeling and model predictive controller.
Subject: I want to add affect of "Zd" step disturbance to my current plant state space equation which will be use as measured disturbance in mpc controller block.
I am designing an MPC controller, which should be robust to disturbance rejection and I have a known Measured Disturbance which I want to add to "md", but I am getting some errors.
I have following state space equation of my plant, which I found using system identification technique.
%Transfer Function By System identification
num = [-1.324 6.6e05 -6.914e09 5.128e13 -1.054e19]
den = [1 1.99e04 1.371e09 1.145e13 4.037e17]
%Conversion to SS
plant = tf([num],[den], ‘OutputDelay’,1)
% Simplify the model to remove insignificant poles and zeros
SSpzt = ss(plant) %This gives continuous time linear state space model of TFpzt
Ac = SSpzt.A;
Bc = SSpzt.B;
Cc = SSpzt.C;
Dc = SSpzt.D;
Ts = 3.1309e-05 %Sampling time actual = 3.1309e-05
Td = 0.009; %time Delay baed on frequency data
%Contineous Model to discrete Statespace Matrices
SSpzt_dis = c2dm(Ac,Bc,Cc,Dc,Ts)
[Ad,Bd,Cd,Dd] = c2dm(Ac, Bc, Cc, Dc, Ts)
Dd = 0
sysdis = ss(Ad,Bd,Cd,Dd,Ts)
sysdis shows my plant discrete statespace model which i used to design mpc controller. but when I add md as step, it gives me following error and I know this is because I think I need to add some rows and coloum to my matrix B or C for measured disturbance, but I am not sure how to add them. So, I am asking here for help.
But when I use MPC Controller without md it works fine, but it is not robust to disturbance rejection, and my main concern is to eliminate the disturbance effectively. Even it doesn’t respond to disturbance. I am looking for help in this regards. Attached is the files of my design. First run PZTModel1.m file then load PID_Controller22_December, and DisRejection_27December files and open MPC_simulink1. mpc, model predective controller, model predictive controller, mpxc, state space modeling, ss modeling, control system toolbox MATLAB Answers — New Questions
I want to generate code combining Platform Architecture(MCU Peripherals), Functional Architecture, Logical Architecture with Schedular so how i can connect all components.
I want to understand how i can generare RTE layer(schedular) in system composer.
i want to use Platform Architecture for MCU Drivers code in S-function. which will be connected to schedular component (Statechart). And schedular will be connected to Functional Architecture and Functional Architecture will be linked to Logical Architecture and with theirs simulink behavior models.
can i generate deployable code by system composer by following avobe workflow?
how i should connect schedular(Port interface for function call) to functional Archicteure and how i can send response of task complition to Schedular component?I want to understand how i can generare RTE layer(schedular) in system composer.
i want to use Platform Architecture for MCU Drivers code in S-function. which will be connected to schedular component (Statechart). And schedular will be connected to Functional Architecture and Functional Architecture will be linked to Logical Architecture and with theirs simulink behavior models.
can i generate deployable code by system composer by following avobe workflow?
how i should connect schedular(Port interface for function call) to functional Archicteure and how i can send response of task complition to Schedular component? I want to understand how i can generare RTE layer(schedular) in system composer.
i want to use Platform Architecture for MCU Drivers code in S-function. which will be connected to schedular component (Statechart). And schedular will be connected to Functional Architecture and Functional Architecture will be linked to Logical Architecture and with theirs simulink behavior models.
can i generate deployable code by system composer by following avobe workflow?
how i should connect schedular(Port interface for function call) to functional Archicteure and how i can send response of task complition to Schedular component? model, code generation, system composer MATLAB Answers — New Questions
How to make Rounded Edges of rectangle corners with polyshape function ?
hello, everybody
I would like to make the rounded rectangle and I would like them to translated and rotated.
First I tried with rectangle function using ‘Curvature’ of 1. then I can make the rounded rectangle.
However, it is not possible for them to translated and rotated.
Therefore, I made the rectangle with polyshape function. and it is okay for them to translated and rotated.
However, i do not know how I can make them to have rounded edges.
Could you please helpe me how to make them to rounded edges with polyshape function?
clear; close all; clc;
figure(1); hold on; axis equal
% Before translating and rotating
rectangle(‘Position’,[-14.1276, 226.1976, 6.5929, 9.4184],’FaceColor’,’r’,’Curvature’,1)
% After translating and rotating
% translate and rotate polygon
x = [-14.1276; -14.1276+6.5929; -14.1276+6.5929; -14.1276];
y = [226.1976; 226.1976; 226.1976+9.4184; 226.1976+9.4184];
p = [x,y];
pgon = polyshape(p);
pgon = translate(pgon,50,-75);
pgon = rotate(pgon,18,[57, 349]);
plot(pgon,’FaceColor’,’red’,’FaceAlpha’,1)
% object by rectangle function can not translated and rotated.hello, everybody
I would like to make the rounded rectangle and I would like them to translated and rotated.
First I tried with rectangle function using ‘Curvature’ of 1. then I can make the rounded rectangle.
However, it is not possible for them to translated and rotated.
Therefore, I made the rectangle with polyshape function. and it is okay for them to translated and rotated.
However, i do not know how I can make them to have rounded edges.
Could you please helpe me how to make them to rounded edges with polyshape function?
clear; close all; clc;
figure(1); hold on; axis equal
% Before translating and rotating
rectangle(‘Position’,[-14.1276, 226.1976, 6.5929, 9.4184],’FaceColor’,’r’,’Curvature’,1)
% After translating and rotating
% translate and rotate polygon
x = [-14.1276; -14.1276+6.5929; -14.1276+6.5929; -14.1276];
y = [226.1976; 226.1976; 226.1976+9.4184; 226.1976+9.4184];
p = [x,y];
pgon = polyshape(p);
pgon = translate(pgon,50,-75);
pgon = rotate(pgon,18,[57, 349]);
plot(pgon,’FaceColor’,’red’,’FaceAlpha’,1)
% object by rectangle function can not translated and rotated. hello, everybody
I would like to make the rounded rectangle and I would like them to translated and rotated.
First I tried with rectangle function using ‘Curvature’ of 1. then I can make the rounded rectangle.
However, it is not possible for them to translated and rotated.
Therefore, I made the rectangle with polyshape function. and it is okay for them to translated and rotated.
However, i do not know how I can make them to have rounded edges.
Could you please helpe me how to make them to rounded edges with polyshape function?
clear; close all; clc;
figure(1); hold on; axis equal
% Before translating and rotating
rectangle(‘Position’,[-14.1276, 226.1976, 6.5929, 9.4184],’FaceColor’,’r’,’Curvature’,1)
% After translating and rotating
% translate and rotate polygon
x = [-14.1276; -14.1276+6.5929; -14.1276+6.5929; -14.1276];
y = [226.1976; 226.1976; 226.1976+9.4184; 226.1976+9.4184];
p = [x,y];
pgon = polyshape(p);
pgon = translate(pgon,50,-75);
pgon = rotate(pgon,18,[57, 349]);
plot(pgon,’FaceColor’,’red’,’FaceAlpha’,1)
% object by rectangle function can not translated and rotated. curvature MATLAB Answers — New Questions
Please help me to run this code
function sol= proj
clc;clf;clear;
%Relation of base fluid
rhof=997.1*10^-3;kf=0.613*10^5;cpf=4179*10^4;muf=10^-3*10;
alfaf=kf/(rhof*cpf);
bef=21*10^-5;
ky=muf/rhof;
disp(‘ky’);disp((muf/rhof));
%sigf=0.05*10^-8;
%Ag
ph1=0.01;
rho1=10500*10^-3;
cp1=235*10^4;
k1=429*10^5;be1=21*10^-5;
%sig1=0.74*10^-2;
%copper
ph2=0.01;
rho2=8933*10^-3;
cp2=385*10^4;
k2=400*10^5;
%sig2=5.96*10^-1;
be2=1.67*10^-5;
%Alumina
ph3=0.01;
rho3=3970*10^-3;
cp3=765*10^4;
k3=40*10^5;
be3=0.85*10^-5;
%sig3=3.5*10^-1;
%Relation of ternary hyprid
kn=kf*((k3+2*kf-2*ph3*(kf-k3))/(k3+2*kf+ph3*(kf-k3)));
kh=kn*((k2+2*kn-2*ph2*(kn-k2))/(k2+2*kn+ph2*(kn-k2)));
kt=kh*((k1+2*kh-2*ph1*(kh-k1))/(k1+2*kh+ph1*(kh-k1)));
mut= muf/((1-ph1)^2.5*(1-ph2)^2.5*(1-ph3)^2.5);
rhot=(1-ph1)*((1-ph2)*((1-ph3)+ph3*(rho3/rhof))+ph2*(rho2/rhof))+ph1*(rho1/rhof);
%vt=rhot*cpt
vt =(1-ph1)*((1-ph2)*((1-ph3)+ph3*((rho3*cp3)/(rhof*cpf)))+ph2*((rho2*cp2)/(rhof*cpf)))+ph1*((rho1*cp1)/(rhof*cpf));
%disp(‘vt’);disp(vt);
%vb=rho*betb
vb =(1-ph1)*((1-ph2)*((1-ph3)+ph3*((rho3*be3)/(rhof*bef)))+ph2*((rho2*be2)/(rhof*bef)))+ph1*((rho1*be1)/(rhof*bef));
%disp(‘vb’);disp(vb);disp(ky);
myLegend1 = {};myLegend2 = {};
%for i =1:numel(rr)
rr = [0 1 2];
numGr = numel(rr);
m = linspace(0,1);
a=-0.001;b=0.0001;p=-0.15/((1-0.01)*(mut/muf)*(rhof/rhot));
Ec=0.5;
gamma=pi/4;
prf=6.9;Rd=0.5;
Tw=273+50;Ti=273+27;deltaT=Tw-Ti;
disp(‘coe’);disp((mut/muf)*(rhof/rhot));
Lf=rhof*kf;
y0 = [1,0,1,0,0,1,0,1];options =bvpset(‘stats’,’on’,’RelTol’,1e-5);
%solinit = bvpinit(m,y0);
% sol= bvp4c(@projfun,@projbc,solinit,options);
Z = zeros(numGr, length(m));
for i = 1:numGr
Gr= rr(i);
solinit = bvpinit(m, y0);
sol = bvp4c(@projfun, @projbc, solinit, options);
Z(i, 🙂 = deval(sol,m,1); % Store the z-axis data
end
[X, Y] = meshgrid(m, rr);
figure;
surf(X, Y, Z);
xlabel(‘x’);
ylabel(‘Prf’);
zlabel(‘Solution y(6,:)’);
title(‘Surface Plot of Solution’);
grid on;
function dy= projfun(~,y)
dy= zeros(8,1);
% alignComments
E = y(1);
dE = y(2);
F = y(3);
dF= y(4);
w = y(5);
dw=y(6);
t = y(7);
dt = y(8);
dy(1) = dE;
dy(2) = (((rhot/mut)*(a*(muf/rhof)^0.5*(E*F+E^2)+a*(muf/rhof)*w*dE-(mut/muf)*(rhof/rhot)*p*(1-0.01)*E+Gr*a*(muf/rhof)*sin(gamma)*(vb/(rhof*bef))*t)));
dy(3) = dF;
dy(4) = (((rhot/mut)*(b*(muf/rhof)^0.5*(F^2+F*E)+(muf/rhof)*b^0.5*a^(1.5)*dF)));
dy(5) =-(a*F+b*E);
dy(6) = (((rhot/mut)*((muf/rhof)^0.5*w*dw+Gr*b*(muf/rhof)*cos(gamma)*(vb/(rhof*bef))*t)));
dy(7) = dt;
dy(8)=prf*(1/(kt/kf))*(1/(1+((prf*Rd)/((kt/kf)))))*((vt/(rhof*cpf))*(muf/rhof)^0.5*w*dt-(mut/muf)*Ec*1*dw^2) ;
end
end
function res= projbc(ya,yb)
res= [ya(1)+1;
ya(3)-1;
ya(5);
ya(6);
ya(7)-1-(1/0.9)*ya(8);
yb(1)-0.01;
yb(3);
yb(7);
% yb(7);
];
endfunction sol= proj
clc;clf;clear;
%Relation of base fluid
rhof=997.1*10^-3;kf=0.613*10^5;cpf=4179*10^4;muf=10^-3*10;
alfaf=kf/(rhof*cpf);
bef=21*10^-5;
ky=muf/rhof;
disp(‘ky’);disp((muf/rhof));
%sigf=0.05*10^-8;
%Ag
ph1=0.01;
rho1=10500*10^-3;
cp1=235*10^4;
k1=429*10^5;be1=21*10^-5;
%sig1=0.74*10^-2;
%copper
ph2=0.01;
rho2=8933*10^-3;
cp2=385*10^4;
k2=400*10^5;
%sig2=5.96*10^-1;
be2=1.67*10^-5;
%Alumina
ph3=0.01;
rho3=3970*10^-3;
cp3=765*10^4;
k3=40*10^5;
be3=0.85*10^-5;
%sig3=3.5*10^-1;
%Relation of ternary hyprid
kn=kf*((k3+2*kf-2*ph3*(kf-k3))/(k3+2*kf+ph3*(kf-k3)));
kh=kn*((k2+2*kn-2*ph2*(kn-k2))/(k2+2*kn+ph2*(kn-k2)));
kt=kh*((k1+2*kh-2*ph1*(kh-k1))/(k1+2*kh+ph1*(kh-k1)));
mut= muf/((1-ph1)^2.5*(1-ph2)^2.5*(1-ph3)^2.5);
rhot=(1-ph1)*((1-ph2)*((1-ph3)+ph3*(rho3/rhof))+ph2*(rho2/rhof))+ph1*(rho1/rhof);
%vt=rhot*cpt
vt =(1-ph1)*((1-ph2)*((1-ph3)+ph3*((rho3*cp3)/(rhof*cpf)))+ph2*((rho2*cp2)/(rhof*cpf)))+ph1*((rho1*cp1)/(rhof*cpf));
%disp(‘vt’);disp(vt);
%vb=rho*betb
vb =(1-ph1)*((1-ph2)*((1-ph3)+ph3*((rho3*be3)/(rhof*bef)))+ph2*((rho2*be2)/(rhof*bef)))+ph1*((rho1*be1)/(rhof*bef));
%disp(‘vb’);disp(vb);disp(ky);
myLegend1 = {};myLegend2 = {};
%for i =1:numel(rr)
rr = [0 1 2];
numGr = numel(rr);
m = linspace(0,1);
a=-0.001;b=0.0001;p=-0.15/((1-0.01)*(mut/muf)*(rhof/rhot));
Ec=0.5;
gamma=pi/4;
prf=6.9;Rd=0.5;
Tw=273+50;Ti=273+27;deltaT=Tw-Ti;
disp(‘coe’);disp((mut/muf)*(rhof/rhot));
Lf=rhof*kf;
y0 = [1,0,1,0,0,1,0,1];options =bvpset(‘stats’,’on’,’RelTol’,1e-5);
%solinit = bvpinit(m,y0);
% sol= bvp4c(@projfun,@projbc,solinit,options);
Z = zeros(numGr, length(m));
for i = 1:numGr
Gr= rr(i);
solinit = bvpinit(m, y0);
sol = bvp4c(@projfun, @projbc, solinit, options);
Z(i, 🙂 = deval(sol,m,1); % Store the z-axis data
end
[X, Y] = meshgrid(m, rr);
figure;
surf(X, Y, Z);
xlabel(‘x’);
ylabel(‘Prf’);
zlabel(‘Solution y(6,:)’);
title(‘Surface Plot of Solution’);
grid on;
function dy= projfun(~,y)
dy= zeros(8,1);
% alignComments
E = y(1);
dE = y(2);
F = y(3);
dF= y(4);
w = y(5);
dw=y(6);
t = y(7);
dt = y(8);
dy(1) = dE;
dy(2) = (((rhot/mut)*(a*(muf/rhof)^0.5*(E*F+E^2)+a*(muf/rhof)*w*dE-(mut/muf)*(rhof/rhot)*p*(1-0.01)*E+Gr*a*(muf/rhof)*sin(gamma)*(vb/(rhof*bef))*t)));
dy(3) = dF;
dy(4) = (((rhot/mut)*(b*(muf/rhof)^0.5*(F^2+F*E)+(muf/rhof)*b^0.5*a^(1.5)*dF)));
dy(5) =-(a*F+b*E);
dy(6) = (((rhot/mut)*((muf/rhof)^0.5*w*dw+Gr*b*(muf/rhof)*cos(gamma)*(vb/(rhof*bef))*t)));
dy(7) = dt;
dy(8)=prf*(1/(kt/kf))*(1/(1+((prf*Rd)/((kt/kf)))))*((vt/(rhof*cpf))*(muf/rhof)^0.5*w*dt-(mut/muf)*Ec*1*dw^2) ;
end
end
function res= projbc(ya,yb)
res= [ya(1)+1;
ya(3)-1;
ya(5);
ya(6);
ya(7)-1-(1/0.9)*ya(8);
yb(1)-0.01;
yb(3);
yb(7);
% yb(7);
];
end function sol= proj
clc;clf;clear;
%Relation of base fluid
rhof=997.1*10^-3;kf=0.613*10^5;cpf=4179*10^4;muf=10^-3*10;
alfaf=kf/(rhof*cpf);
bef=21*10^-5;
ky=muf/rhof;
disp(‘ky’);disp((muf/rhof));
%sigf=0.05*10^-8;
%Ag
ph1=0.01;
rho1=10500*10^-3;
cp1=235*10^4;
k1=429*10^5;be1=21*10^-5;
%sig1=0.74*10^-2;
%copper
ph2=0.01;
rho2=8933*10^-3;
cp2=385*10^4;
k2=400*10^5;
%sig2=5.96*10^-1;
be2=1.67*10^-5;
%Alumina
ph3=0.01;
rho3=3970*10^-3;
cp3=765*10^4;
k3=40*10^5;
be3=0.85*10^-5;
%sig3=3.5*10^-1;
%Relation of ternary hyprid
kn=kf*((k3+2*kf-2*ph3*(kf-k3))/(k3+2*kf+ph3*(kf-k3)));
kh=kn*((k2+2*kn-2*ph2*(kn-k2))/(k2+2*kn+ph2*(kn-k2)));
kt=kh*((k1+2*kh-2*ph1*(kh-k1))/(k1+2*kh+ph1*(kh-k1)));
mut= muf/((1-ph1)^2.5*(1-ph2)^2.5*(1-ph3)^2.5);
rhot=(1-ph1)*((1-ph2)*((1-ph3)+ph3*(rho3/rhof))+ph2*(rho2/rhof))+ph1*(rho1/rhof);
%vt=rhot*cpt
vt =(1-ph1)*((1-ph2)*((1-ph3)+ph3*((rho3*cp3)/(rhof*cpf)))+ph2*((rho2*cp2)/(rhof*cpf)))+ph1*((rho1*cp1)/(rhof*cpf));
%disp(‘vt’);disp(vt);
%vb=rho*betb
vb =(1-ph1)*((1-ph2)*((1-ph3)+ph3*((rho3*be3)/(rhof*bef)))+ph2*((rho2*be2)/(rhof*bef)))+ph1*((rho1*be1)/(rhof*bef));
%disp(‘vb’);disp(vb);disp(ky);
myLegend1 = {};myLegend2 = {};
%for i =1:numel(rr)
rr = [0 1 2];
numGr = numel(rr);
m = linspace(0,1);
a=-0.001;b=0.0001;p=-0.15/((1-0.01)*(mut/muf)*(rhof/rhot));
Ec=0.5;
gamma=pi/4;
prf=6.9;Rd=0.5;
Tw=273+50;Ti=273+27;deltaT=Tw-Ti;
disp(‘coe’);disp((mut/muf)*(rhof/rhot));
Lf=rhof*kf;
y0 = [1,0,1,0,0,1,0,1];options =bvpset(‘stats’,’on’,’RelTol’,1e-5);
%solinit = bvpinit(m,y0);
% sol= bvp4c(@projfun,@projbc,solinit,options);
Z = zeros(numGr, length(m));
for i = 1:numGr
Gr= rr(i);
solinit = bvpinit(m, y0);
sol = bvp4c(@projfun, @projbc, solinit, options);
Z(i, 🙂 = deval(sol,m,1); % Store the z-axis data
end
[X, Y] = meshgrid(m, rr);
figure;
surf(X, Y, Z);
xlabel(‘x’);
ylabel(‘Prf’);
zlabel(‘Solution y(6,:)’);
title(‘Surface Plot of Solution’);
grid on;
function dy= projfun(~,y)
dy= zeros(8,1);
% alignComments
E = y(1);
dE = y(2);
F = y(3);
dF= y(4);
w = y(5);
dw=y(6);
t = y(7);
dt = y(8);
dy(1) = dE;
dy(2) = (((rhot/mut)*(a*(muf/rhof)^0.5*(E*F+E^2)+a*(muf/rhof)*w*dE-(mut/muf)*(rhof/rhot)*p*(1-0.01)*E+Gr*a*(muf/rhof)*sin(gamma)*(vb/(rhof*bef))*t)));
dy(3) = dF;
dy(4) = (((rhot/mut)*(b*(muf/rhof)^0.5*(F^2+F*E)+(muf/rhof)*b^0.5*a^(1.5)*dF)));
dy(5) =-(a*F+b*E);
dy(6) = (((rhot/mut)*((muf/rhof)^0.5*w*dw+Gr*b*(muf/rhof)*cos(gamma)*(vb/(rhof*bef))*t)));
dy(7) = dt;
dy(8)=prf*(1/(kt/kf))*(1/(1+((prf*Rd)/((kt/kf)))))*((vt/(rhof*cpf))*(muf/rhof)^0.5*w*dt-(mut/muf)*Ec*1*dw^2) ;
end
end
function res= projbc(ya,yb)
res= [ya(1)+1;
ya(3)-1;
ya(5);
ya(6);
ya(7)-1-(1/0.9)*ya(8);
yb(1)-0.01;
yb(3);
yb(7);
% yb(7);
];
end bvp4c, ordinary differential equation MATLAB Answers — New Questions
WANT A HELP IN DTM MATLAP CODE
THIS IS A FILE DESCRIBE THE EQUATION AND THE , the Lagrangian -derived equations of motionTHIS IS A FILE DESCRIBE THE EQUATION AND THE , the Lagrangian -derived equations of motion THIS IS A FILE DESCRIBE THE EQUATION AND THE , the Lagrangian -derived equations of motion matlab, mathematics, code MATLAB Answers — New Questions
Question about convert PPO agent to ONNX
Greetings,
I encountered the error shown in figure when I tried to execute the ONNX on ubuntu at the first time.
Then I found it was the problem caused by rlContinuousGaussianActor, so I removed the mp_out and sdev layers and it worked!
But I don’t understand why it worked due to as my knowledge after I removed those layers it will mess up the PPO structure.
So what should I do? Keep working without mp_out and sdev layers or trying to fix them?
however, I have no idea about how to fix them, so I am confused.
Thank your time for watching or answering me.
Best wish,
HUANGreetings,
I encountered the error shown in figure when I tried to execute the ONNX on ubuntu at the first time.
Then I found it was the problem caused by rlContinuousGaussianActor, so I removed the mp_out and sdev layers and it worked!
But I don’t understand why it worked due to as my knowledge after I removed those layers it will mess up the PPO structure.
So what should I do? Keep working without mp_out and sdev layers or trying to fix them?
however, I have no idea about how to fix them, so I am confused.
Thank your time for watching or answering me.
Best wish,
HUAN Greetings,
I encountered the error shown in figure when I tried to execute the ONNX on ubuntu at the first time.
Then I found it was the problem caused by rlContinuousGaussianActor, so I removed the mp_out and sdev layers and it worked!
But I don’t understand why it worked due to as my knowledge after I removed those layers it will mess up the PPO structure.
So what should I do? Keep working without mp_out and sdev layers or trying to fix them?
however, I have no idea about how to fix them, so I am confused.
Thank your time for watching or answering me.
Best wish,
HUAN ppo, onnx, rlcontinuousgaussianactor MATLAB Answers — New Questions
Error using integral2Calc>integral2t/tensor (line 231) Input function must return ‘double’ or ‘single’ values. Found ‘sym’.
I’d like to know where the mistake in this code, and the solution
h = 0.00172; rho = 1620;
L = 100*h; c=L*L/4;
M=10; N=10;
syms xi eta
shape_w=sym(zeros(M,N)); x_m=sym(zeros(M,1)); y_n=sym(zeros(N,1));
for m=1:M
for n=1:N
x_m(m)=(xi^m)*(1+xi);
y_n(n)=(eta^n)*(1-eta)*(1+eta)^2;
shape_w(m,n)=x_m(m)*y_n(n);
end
end
fun=(shape_w*shape_w’);
M_w =c*(rho*h)*integral2(@(xi,eta)fun,-1,1,-1,1);I’d like to know where the mistake in this code, and the solution
h = 0.00172; rho = 1620;
L = 100*h; c=L*L/4;
M=10; N=10;
syms xi eta
shape_w=sym(zeros(M,N)); x_m=sym(zeros(M,1)); y_n=sym(zeros(N,1));
for m=1:M
for n=1:N
x_m(m)=(xi^m)*(1+xi);
y_n(n)=(eta^n)*(1-eta)*(1+eta)^2;
shape_w(m,n)=x_m(m)*y_n(n);
end
end
fun=(shape_w*shape_w’);
M_w =c*(rho*h)*integral2(@(xi,eta)fun,-1,1,-1,1); I’d like to know where the mistake in this code, and the solution
h = 0.00172; rho = 1620;
L = 100*h; c=L*L/4;
M=10; N=10;
syms xi eta
shape_w=sym(zeros(M,N)); x_m=sym(zeros(M,1)); y_n=sym(zeros(N,1));
for m=1:M
for n=1:N
x_m(m)=(xi^m)*(1+xi);
y_n(n)=(eta^n)*(1-eta)*(1+eta)^2;
shape_w(m,n)=x_m(m)*y_n(n);
end
end
fun=(shape_w*shape_w’);
M_w =c*(rho*h)*integral2(@(xi,eta)fun,-1,1,-1,1); how i can fix error using integral2calc integral2t/tensor (line 231)? MATLAB Answers — New Questions
What are the data confidentiality settings for MATLAB Copilot?
As some of the code being developed in MATLAB could be confidential, I am wondering if there are some Terms and Conditions or configuration parameters that must be set so that the MATLAB Copilot does not:
Get trained from the code
Uploads this protected information online
Expose to MathWorks or third parties the protected content
Could you explain how does it work regarding data confidentiality and how to set it up to prevent sharing or training from this confidential information?As some of the code being developed in MATLAB could be confidential, I am wondering if there are some Terms and Conditions or configuration parameters that must be set so that the MATLAB Copilot does not:
Get trained from the code
Uploads this protected information online
Expose to MathWorks or third parties the protected content
Could you explain how does it work regarding data confidentiality and how to set it up to prevent sharing or training from this confidential information? As some of the code being developed in MATLAB could be confidential, I am wondering if there are some Terms and Conditions or configuration parameters that must be set so that the MATLAB Copilot does not:
Get trained from the code
Uploads this protected information online
Expose to MathWorks or third parties the protected content
Could you explain how does it work regarding data confidentiality and how to set it up to prevent sharing or training from this confidential information? matlab, copilot, matlab-copilot MATLAB Answers — New Questions