Tag Archives: matlab
Layout scope Matlab online doesn’t work
Hi,
I have a scope with 4 inputs and I would like to show all plots separately, however, the layout option in scope doesn’t work. I’m using Matlab online, I’ve tried Brave, Chrome and Firefox. Any clue how to solve this?
ThanksHi,
I have a scope with 4 inputs and I would like to show all plots separately, however, the layout option in scope doesn’t work. I’m using Matlab online, I’ve tried Brave, Chrome and Firefox. Any clue how to solve this?
Thanks Hi,
I have a scope with 4 inputs and I would like to show all plots separately, however, the layout option in scope doesn’t work. I’m using Matlab online, I’ve tried Brave, Chrome and Firefox. Any clue how to solve this?
Thanks scope, layout MATLAB Answers — New Questions
to develop a MATLAB program for eigenvalue solving using MATRIX ITERATION method
I am trying to create a program which will compute eigenvalue using matrix iteration method. I just know some basic commands and still learning. I have created the following function but I know it has a lot of errors and is not complete. Can anyone plz help
function l = ww(m,k)
for i=1:1000
for j=1:1000
m = [i 0 0;0 2*i 0;0 0 i];
k = [2*j -j 0;-j 7*j -4*j;0 -4*j 5*j];
end
end
n = length(m);
y = [];
x = [];
for i = 1:n % starting vector
x(i) = m(i,1);
end;
l = 0;
blad = k; % starting value of error
while blad>=k
for i = 1:n % A*x
y(i) = 0;
for j = 1:n
y(i) = y(i) + m(i,j)*x(j);
end;
end;
blad = l;
l = 0; % Rayleigh
t = 0;
for i = 1:n
l = l + x(i)*y(i);
t = t + t(i)*x(i);
end;
l = l/t; % eigenvalue
blad = abs(l – blad); % error
x = y;
end;
endI am trying to create a program which will compute eigenvalue using matrix iteration method. I just know some basic commands and still learning. I have created the following function but I know it has a lot of errors and is not complete. Can anyone plz help
function l = ww(m,k)
for i=1:1000
for j=1:1000
m = [i 0 0;0 2*i 0;0 0 i];
k = [2*j -j 0;-j 7*j -4*j;0 -4*j 5*j];
end
end
n = length(m);
y = [];
x = [];
for i = 1:n % starting vector
x(i) = m(i,1);
end;
l = 0;
blad = k; % starting value of error
while blad>=k
for i = 1:n % A*x
y(i) = 0;
for j = 1:n
y(i) = y(i) + m(i,j)*x(j);
end;
end;
blad = l;
l = 0; % Rayleigh
t = 0;
for i = 1:n
l = l + x(i)*y(i);
t = t + t(i)*x(i);
end;
l = l/t; % eigenvalue
blad = abs(l – blad); % error
x = y;
end;
end I am trying to create a program which will compute eigenvalue using matrix iteration method. I just know some basic commands and still learning. I have created the following function but I know it has a lot of errors and is not complete. Can anyone plz help
function l = ww(m,k)
for i=1:1000
for j=1:1000
m = [i 0 0;0 2*i 0;0 0 i];
k = [2*j -j 0;-j 7*j -4*j;0 -4*j 5*j];
end
end
n = length(m);
y = [];
x = [];
for i = 1:n % starting vector
x(i) = m(i,1);
end;
l = 0;
blad = k; % starting value of error
while blad>=k
for i = 1:n % A*x
y(i) = 0;
for j = 1:n
y(i) = y(i) + m(i,j)*x(j);
end;
end;
blad = l;
l = 0; % Rayleigh
t = 0;
for i = 1:n
l = l + x(i)*y(i);
t = t + t(i)*x(i);
end;
l = l/t; % eigenvalue
blad = abs(l – blad); % error
x = y;
end;
end matrix iteration, eigenvalue MATLAB Answers — New Questions
How can I use the iswt2 from the wavelet toolbox with a different dwtmode?
The iswt2 is the inverse function of the swt2. In the swt2 the dwtmode is set to:
modeDWT = ‘per’;
I want to customize the swt2 to extend images in a symmetric manner, so changed the code to:
modeDWT = ‘sym’;
Unfortunately, I have not found an explicit parameter to consider the dwtmode in the iswt2. Is there a way to modify the iswt2 in this respect?The iswt2 is the inverse function of the swt2. In the swt2 the dwtmode is set to:
modeDWT = ‘per’;
I want to customize the swt2 to extend images in a symmetric manner, so changed the code to:
modeDWT = ‘sym’;
Unfortunately, I have not found an explicit parameter to consider the dwtmode in the iswt2. Is there a way to modify the iswt2 in this respect? The iswt2 is the inverse function of the swt2. In the swt2 the dwtmode is set to:
modeDWT = ‘per’;
I want to customize the swt2 to extend images in a symmetric manner, so changed the code to:
modeDWT = ‘sym’;
Unfortunately, I have not found an explicit parameter to consider the dwtmode in the iswt2. Is there a way to modify the iswt2 in this respect? wavelet, signal processing, image processing MATLAB Answers — New Questions
solution for steady flow at Re = 10. in coursera i took mathematics for engineers.for that i need to solve an assignment. For this code i cant get correct stream & vorticity
flow_around_cylinder_steady
function [psi, omega] = flow_around_cylinder_steady
Re=10;
%%%%% define the grid %%%%%
n=101; m=101; % number of grid points
N=n-1; M=m-1; % number of grid intervals
h=pi/M; % grid spacing based on theta variable
xi=(0:N)*h; theta=(0:M)*h; % xi and theta variables on the grid
%%%%% Initialize the flow fields %%%%%
psi=zeros(n,m);
omega=zeros(n,m);
psi(n,:)=0 % Free stream boundary condition (psi = 0 at the top edge)
%%%%% Set relax params, tol, extra variables %%%%%
r_psi=1.8; % Set the relaxation parameter here, psi equation
r_omega=0.9; % Set the relaxation parameter here, omega equation
delta=1.e-08; % error tolerance
error=2*delta; % initialize error variable
%%%%% Add any additional variable definitions here %%%%%
…
…
%%%%% Main SOR Loop %%%%%
while (error > delta)
psi_old = psi; omega_old = omega;
for i=2:n-1
for j=2:m-1
psi(i,j)=… % (1 – r_psi) * psi_old(i, j) + …
r_psi * 0.5 * (psi_old(i+1, j) + psi_old(i-1, j) + …
psi_old(i, j+1) + psi_old(i, j-1) – h^2 * omega(i, j));
end
end
error_psi=max(abs(psi(:)-psi_old(:)));
omega(1,:)=0 % Boundary condition at theta = 0
for i=2:n-1
for j=2:m-1
omega(i,j)=… % (1 – r_omega) * omega_old(i, j) + …
r_omega * ( (omega_old(i+1, j) + omega_old(i-1, j) + …
omega_old(i, j+1) + omega_old(i, j-1) – …
(4 – (2/h^2)) * omega_old(i, j)) / (4 – (2/h^2)) );
end
end
error_omega=max(abs(omega(:)-omega_old(:)));
error=max(error_psi, error_omega);
end
plot_Re10(psi);
end
Please refer to page 59 (64/69) of the PDF document for the ‘plot_Re10’ custom plotting function.
https://www.math.hkust.edu.hk/~machas/flow-around-a-cylinder.pdfflow_around_cylinder_steady
function [psi, omega] = flow_around_cylinder_steady
Re=10;
%%%%% define the grid %%%%%
n=101; m=101; % number of grid points
N=n-1; M=m-1; % number of grid intervals
h=pi/M; % grid spacing based on theta variable
xi=(0:N)*h; theta=(0:M)*h; % xi and theta variables on the grid
%%%%% Initialize the flow fields %%%%%
psi=zeros(n,m);
omega=zeros(n,m);
psi(n,:)=0 % Free stream boundary condition (psi = 0 at the top edge)
%%%%% Set relax params, tol, extra variables %%%%%
r_psi=1.8; % Set the relaxation parameter here, psi equation
r_omega=0.9; % Set the relaxation parameter here, omega equation
delta=1.e-08; % error tolerance
error=2*delta; % initialize error variable
%%%%% Add any additional variable definitions here %%%%%
…
…
%%%%% Main SOR Loop %%%%%
while (error > delta)
psi_old = psi; omega_old = omega;
for i=2:n-1
for j=2:m-1
psi(i,j)=… % (1 – r_psi) * psi_old(i, j) + …
r_psi * 0.5 * (psi_old(i+1, j) + psi_old(i-1, j) + …
psi_old(i, j+1) + psi_old(i, j-1) – h^2 * omega(i, j));
end
end
error_psi=max(abs(psi(:)-psi_old(:)));
omega(1,:)=0 % Boundary condition at theta = 0
for i=2:n-1
for j=2:m-1
omega(i,j)=… % (1 – r_omega) * omega_old(i, j) + …
r_omega * ( (omega_old(i+1, j) + omega_old(i-1, j) + …
omega_old(i, j+1) + omega_old(i, j-1) – …
(4 – (2/h^2)) * omega_old(i, j)) / (4 – (2/h^2)) );
end
end
error_omega=max(abs(omega(:)-omega_old(:)));
error=max(error_psi, error_omega);
end
plot_Re10(psi);
end
Please refer to page 59 (64/69) of the PDF document for the ‘plot_Re10’ custom plotting function.
https://www.math.hkust.edu.hk/~machas/flow-around-a-cylinder.pdf flow_around_cylinder_steady
function [psi, omega] = flow_around_cylinder_steady
Re=10;
%%%%% define the grid %%%%%
n=101; m=101; % number of grid points
N=n-1; M=m-1; % number of grid intervals
h=pi/M; % grid spacing based on theta variable
xi=(0:N)*h; theta=(0:M)*h; % xi and theta variables on the grid
%%%%% Initialize the flow fields %%%%%
psi=zeros(n,m);
omega=zeros(n,m);
psi(n,:)=0 % Free stream boundary condition (psi = 0 at the top edge)
%%%%% Set relax params, tol, extra variables %%%%%
r_psi=1.8; % Set the relaxation parameter here, psi equation
r_omega=0.9; % Set the relaxation parameter here, omega equation
delta=1.e-08; % error tolerance
error=2*delta; % initialize error variable
%%%%% Add any additional variable definitions here %%%%%
…
…
%%%%% Main SOR Loop %%%%%
while (error > delta)
psi_old = psi; omega_old = omega;
for i=2:n-1
for j=2:m-1
psi(i,j)=… % (1 – r_psi) * psi_old(i, j) + …
r_psi * 0.5 * (psi_old(i+1, j) + psi_old(i-1, j) + …
psi_old(i, j+1) + psi_old(i, j-1) – h^2 * omega(i, j));
end
end
error_psi=max(abs(psi(:)-psi_old(:)));
omega(1,:)=0 % Boundary condition at theta = 0
for i=2:n-1
for j=2:m-1
omega(i,j)=… % (1 – r_omega) * omega_old(i, j) + …
r_omega * ( (omega_old(i+1, j) + omega_old(i-1, j) + …
omega_old(i, j+1) + omega_old(i, j-1) – …
(4 – (2/h^2)) * omega_old(i, j)) / (4 – (2/h^2)) );
end
end
error_omega=max(abs(omega(:)-omega_old(:)));
error=max(error_psi, error_omega);
end
plot_Re10(psi);
end
Please refer to page 59 (64/69) of the PDF document for the ‘plot_Re10’ custom plotting function.
https://www.math.hkust.edu.hk/~machas/flow-around-a-cylinder.pdf matlab, steady flow MATLAB Answers — New Questions
How to change .txt format automatically into .m format
Dear all:
I have a lot of .txt files which I want to change them automatically into .m format files, in order for some later processing in Matlab.
Any guide will be very appreciated.Dear all:
I have a lot of .txt files which I want to change them automatically into .m format files, in order for some later processing in Matlab.
Any guide will be very appreciated. Dear all:
I have a lot of .txt files which I want to change them automatically into .m format files, in order for some later processing in Matlab.
Any guide will be very appreciated. txt, m, format, function, convert, change, text, m file, txt file MATLAB Answers — New Questions
dealing with and / (windows vs. unix) for path definition.
Hi everybody,
Simple question, let’s say I’m using mac osx and some colleagues use windows… and I have to share a matlab script. Problem, this script needs to look in folder to load data files or print figures:
load ./data/data.mat
plot(data(:,1),data(:,2))
print -dpdf ./graph/figure.pdf
this is how it is written on unix system, but on windows I have to replace all the / by
load .datadata.mat
…
Is there a way to deal with that or the only way to make it works on both systems is to add a conditional statement like
if isunix
load ./data/data.mat
else
load .datadata.mat
end
thanks for any help,
cheers
PieterHi everybody,
Simple question, let’s say I’m using mac osx and some colleagues use windows… and I have to share a matlab script. Problem, this script needs to look in folder to load data files or print figures:
load ./data/data.mat
plot(data(:,1),data(:,2))
print -dpdf ./graph/figure.pdf
this is how it is written on unix system, but on windows I have to replace all the / by
load .datadata.mat
…
Is there a way to deal with that or the only way to make it works on both systems is to add a conditional statement like
if isunix
load ./data/data.mat
else
load .datadata.mat
end
thanks for any help,
cheers
Pieter Hi everybody,
Simple question, let’s say I’m using mac osx and some colleagues use windows… and I have to share a matlab script. Problem, this script needs to look in folder to load data files or print figures:
load ./data/data.mat
plot(data(:,1),data(:,2))
print -dpdf ./graph/figure.pdf
this is how it is written on unix system, but on windows I have to replace all the / by
load .datadata.mat
…
Is there a way to deal with that or the only way to make it works on both systems is to add a conditional statement like
if isunix
load ./data/data.mat
else
load .datadata.mat
end
thanks for any help,
cheers
Pieter unix windows path dir MATLAB Answers — New Questions
Normal Distribution of the CDF Error Function Plotting
What command do I need to enter to plot:
f(z) = 794.5 (1 + erf((x – 97.69760856)/(25.85046741√2)))What command do I need to enter to plot:
f(z) = 794.5 (1 + erf((x – 97.69760856)/(25.85046741√2))) What command do I need to enter to plot:
f(z) = 794.5 (1 + erf((x – 97.69760856)/(25.85046741√2))) error function MATLAB Answers — New Questions
Appdesigner: Remove Simulink dependency
Hi everybody,
I have accidentaly added a Simulink component to my app and now I cannot compile it anymore.
I have the MATLAB compiler but not the Simulink compiler, to overcome the problem I have removed the simulink component but the dependency is still there, hence the appdesigner does not allow me to compile the app.
Is there any trick that I can use to fix this problem?
Best regards,
GiulioHi everybody,
I have accidentaly added a Simulink component to my app and now I cannot compile it anymore.
I have the MATLAB compiler but not the Simulink compiler, to overcome the problem I have removed the simulink component but the dependency is still there, hence the appdesigner does not allow me to compile the app.
Is there any trick that I can use to fix this problem?
Best regards,
Giulio Hi everybody,
I have accidentaly added a Simulink component to my app and now I cannot compile it anymore.
I have the MATLAB compiler but not the Simulink compiler, to overcome the problem I have removed the simulink component but the dependency is still there, hence the appdesigner does not allow me to compile the app.
Is there any trick that I can use to fix this problem?
Best regards,
Giulio appdesigner, compiler, dependency MATLAB Answers — New Questions
Anova-N output question
Hello community!
The closest prompt I could find that is similar to this would be: https://www.mathworks.com/matlabcentral/answers/1876737-anova-n-outputs-as-not-full-rank-returns-nan-p-value?s_tid=sug_su , but the reason their’s showed NaN was there was not enough values. For mine I have 5.4 thousand entries, so I’m not sure that is the problem.
To reduce clutter of the code, I am going to attach the .mat files and the one-line of code.
pTHalf = anovan(stats(:,1), {Patho CellLine MW},’model’,’interaction’,’varnames’, …
{‘Pathology’,’Cell Line’,’Molecular Weights’});
I ensured the data is of the same types allowed within the format of the Anova-n overview page. The only thing that I could think of was that there are more than two groups within the Cell Line and Molecular Weights groupings, but the only one that worked was the molecular weights, so I also doubt that is the reason.
This is the output below. Why do I have missing sections associated with a ‘not full rank’. I do not see anything on the anova-N page that discusses this.
Thanks community!
NickHello community!
The closest prompt I could find that is similar to this would be: https://www.mathworks.com/matlabcentral/answers/1876737-anova-n-outputs-as-not-full-rank-returns-nan-p-value?s_tid=sug_su , but the reason their’s showed NaN was there was not enough values. For mine I have 5.4 thousand entries, so I’m not sure that is the problem.
To reduce clutter of the code, I am going to attach the .mat files and the one-line of code.
pTHalf = anovan(stats(:,1), {Patho CellLine MW},’model’,’interaction’,’varnames’, …
{‘Pathology’,’Cell Line’,’Molecular Weights’});
I ensured the data is of the same types allowed within the format of the Anova-n overview page. The only thing that I could think of was that there are more than two groups within the Cell Line and Molecular Weights groupings, but the only one that worked was the molecular weights, so I also doubt that is the reason.
This is the output below. Why do I have missing sections associated with a ‘not full rank’. I do not see anything on the anova-N page that discusses this.
Thanks community!
Nick Hello community!
The closest prompt I could find that is similar to this would be: https://www.mathworks.com/matlabcentral/answers/1876737-anova-n-outputs-as-not-full-rank-returns-nan-p-value?s_tid=sug_su , but the reason their’s showed NaN was there was not enough values. For mine I have 5.4 thousand entries, so I’m not sure that is the problem.
To reduce clutter of the code, I am going to attach the .mat files and the one-line of code.
pTHalf = anovan(stats(:,1), {Patho CellLine MW},’model’,’interaction’,’varnames’, …
{‘Pathology’,’Cell Line’,’Molecular Weights’});
I ensured the data is of the same types allowed within the format of the Anova-n overview page. The only thing that I could think of was that there are more than two groups within the Cell Line and Molecular Weights groupings, but the only one that worked was the molecular weights, so I also doubt that is the reason.
This is the output below. Why do I have missing sections associated with a ‘not full rank’. I do not see anything on the anova-N page that discusses this.
Thanks community!
Nick anova-n, matlab, documentation MATLAB Answers — New Questions
Facing error in this example openExample(‘whdl/WHDLOFDMTransmitterExample’)
>>
openExample(‘whdl/WHDLOFDMTransmitterExample’)
runOFDMTransmitterModel
Error using runOFDMTransmitterModel>trBlkSize
Too many output arguments.
Error in runOFDMTransmitterModel (line 26)
trBlkSize(txParam(n).modOrder,txParam(n).codeRateIndex)*txParam(n).numFrames,…Error using runOFDMTransmitterModel>trBlkSizeToo many output arguments.Error in runOFDMTransmitterModel (line 26) trBlkSize(txParam(n).modOrder,txParam(n).codeRateIndex)*txParam(n).numFrames,…
I am gretting this error before I was not getting . can you help me.>>
openExample(‘whdl/WHDLOFDMTransmitterExample’)
runOFDMTransmitterModel
Error using runOFDMTransmitterModel>trBlkSize
Too many output arguments.
Error in runOFDMTransmitterModel (line 26)
trBlkSize(txParam(n).modOrder,txParam(n).codeRateIndex)*txParam(n).numFrames,…Error using runOFDMTransmitterModel>trBlkSizeToo many output arguments.Error in runOFDMTransmitterModel (line 26) trBlkSize(txParam(n).modOrder,txParam(n).codeRateIndex)*txParam(n).numFrames,…
I am gretting this error before I was not getting . can you help me. >>
openExample(‘whdl/WHDLOFDMTransmitterExample’)
runOFDMTransmitterModel
Error using runOFDMTransmitterModel>trBlkSize
Too many output arguments.
Error in runOFDMTransmitterModel (line 26)
trBlkSize(txParam(n).modOrder,txParam(n).codeRateIndex)*txParam(n).numFrames,…Error using runOFDMTransmitterModel>trBlkSizeToo many output arguments.Error in runOFDMTransmitterModel (line 26) trBlkSize(txParam(n).modOrder,txParam(n).codeRateIndex)*txParam(n).numFrames,…
I am gretting this error before I was not getting . can you help me. #matlab#hdl MATLAB Answers — New Questions
Bear tool box and input excel
While I am using the Bear toolbox to run time varying parameter model. I am bit confused how can I make my excel sheet to be recognized by the bear app. I import my own excel sheet that I used to collect data and every time I click a run button it says something like exo mean priors not found or something similar to this. I assume there is an excel sheet format that I am supposed to use in bear toolbox but I cannot really find it anywhere. Can anyone help me out?
For your reference: https://www.ecb.europa.eu/press/research-publications/working-papers/html/BEAR_toolbox_v5_1.pdf –> the slide 22 talks about input excel data file but I am confused.While I am using the Bear toolbox to run time varying parameter model. I am bit confused how can I make my excel sheet to be recognized by the bear app. I import my own excel sheet that I used to collect data and every time I click a run button it says something like exo mean priors not found or something similar to this. I assume there is an excel sheet format that I am supposed to use in bear toolbox but I cannot really find it anywhere. Can anyone help me out?
For your reference: https://www.ecb.europa.eu/press/research-publications/working-papers/html/BEAR_toolbox_v5_1.pdf –> the slide 22 talks about input excel data file but I am confused. While I am using the Bear toolbox to run time varying parameter model. I am bit confused how can I make my excel sheet to be recognized by the bear app. I import my own excel sheet that I used to collect data and every time I click a run button it says something like exo mean priors not found or something similar to this. I assume there is an excel sheet format that I am supposed to use in bear toolbox but I cannot really find it anywhere. Can anyone help me out?
For your reference: https://www.ecb.europa.eu/press/research-publications/working-papers/html/BEAR_toolbox_v5_1.pdf –> the slide 22 talks about input excel data file but I am confused. bear toolbox, ecb, excel sheet MATLAB Answers — New Questions
How can I update base body transformation matrix during visualization using ‘show’ function?
To visualize the rigidbody tree model from urdf file, the ‘show’ function can be used. However, it supports to set the base body position (x,y,z) and yaw angle, only… I want to arbitrary set the base body position and orientation.
For a internal function in the robotics toolbox, there is a little comment to use 6-DOF xyz & roll, ptich, yaw, thereby obtaining whole base body transformation matrix. But, the strict support does not provide or activate them.
How can I set arbitrary base body transformation matrix of rigidbody tree? I have to simulate the base body trasnform almost real-time, therefore I don’t want to add and remove body during simulation.To visualize the rigidbody tree model from urdf file, the ‘show’ function can be used. However, it supports to set the base body position (x,y,z) and yaw angle, only… I want to arbitrary set the base body position and orientation.
For a internal function in the robotics toolbox, there is a little comment to use 6-DOF xyz & roll, ptich, yaw, thereby obtaining whole base body transformation matrix. But, the strict support does not provide or activate them.
How can I set arbitrary base body transformation matrix of rigidbody tree? I have to simulate the base body trasnform almost real-time, therefore I don’t want to add and remove body during simulation. To visualize the rigidbody tree model from urdf file, the ‘show’ function can be used. However, it supports to set the base body position (x,y,z) and yaw angle, only… I want to arbitrary set the base body position and orientation.
For a internal function in the robotics toolbox, there is a little comment to use 6-DOF xyz & roll, ptich, yaw, thereby obtaining whole base body transformation matrix. But, the strict support does not provide or activate them.
How can I set arbitrary base body transformation matrix of rigidbody tree? I have to simulate the base body trasnform almost real-time, therefore I don’t want to add and remove body during simulation. robotics tool box, base body transformation update MATLAB Answers — New Questions
How should I structure the neural net based on my given input and output training data
I am trying to design a feedforward network that trains on a 4×5 matrix (5 samples of 4 separate inputs into the neural network) and its outputs are represented by a 4x5x1000 matrix (5 samples of 4 outputs where each component of the 4×1 output vector has 1000 points). This neural net is used to determine an optimal trajectory for a given terminal condition from a set of the same initial conditions . The code for this project will be placed below:
%% Neural Net Training Process
% Initial State
x1 = [0;0]; % Initial Positions
x2 = [1;1]; % Initial Velocities
xo = [x1;x2]; % 4×1 Initial State Vector
% Parsing Training Input Data
x_input = [xf1,xf2,xf4,xf5,xf6]; % 4×5 Terminal State Vector (each xf (4×1) represents a different terminal condition)
% Parsing Training Output Data
x_output = [];
for i=1:4
x_output(i,1,:) = x1(:,i);
x_output(i,2,:) = x2(:,i);
x_output(i,3,:) = x4(:,i);
x_output(i,4,:) = x5(:,i);
x_output(i,5,:) = x6(:,i);
end % 4x5x1000 Terminal State Matrix
% Parsing Validation Data
xf_valid = xf3;
x_valid = x3′;
% Neural Net Architecture Initialization
netconfig = 40;
net = feedforwardnet(netconfig);
net.numInputs = 4;
% Training the Network
for j=1:5
curr_xin = x_input(:,j);
curr_xout = x_output(:,j,:);
net = train(net,curr_xin,curr_xout);
end
From here, I am receieve an error in line 89, where I get the following error: Error using nntraining.setup>setupPerWorker (line 96)
Targets T is not two-dimensional. Any advice from here would be appreciated. Thanks.I am trying to design a feedforward network that trains on a 4×5 matrix (5 samples of 4 separate inputs into the neural network) and its outputs are represented by a 4x5x1000 matrix (5 samples of 4 outputs where each component of the 4×1 output vector has 1000 points). This neural net is used to determine an optimal trajectory for a given terminal condition from a set of the same initial conditions . The code for this project will be placed below:
%% Neural Net Training Process
% Initial State
x1 = [0;0]; % Initial Positions
x2 = [1;1]; % Initial Velocities
xo = [x1;x2]; % 4×1 Initial State Vector
% Parsing Training Input Data
x_input = [xf1,xf2,xf4,xf5,xf6]; % 4×5 Terminal State Vector (each xf (4×1) represents a different terminal condition)
% Parsing Training Output Data
x_output = [];
for i=1:4
x_output(i,1,:) = x1(:,i);
x_output(i,2,:) = x2(:,i);
x_output(i,3,:) = x4(:,i);
x_output(i,4,:) = x5(:,i);
x_output(i,5,:) = x6(:,i);
end % 4x5x1000 Terminal State Matrix
% Parsing Validation Data
xf_valid = xf3;
x_valid = x3′;
% Neural Net Architecture Initialization
netconfig = 40;
net = feedforwardnet(netconfig);
net.numInputs = 4;
% Training the Network
for j=1:5
curr_xin = x_input(:,j);
curr_xout = x_output(:,j,:);
net = train(net,curr_xin,curr_xout);
end
From here, I am receieve an error in line 89, where I get the following error: Error using nntraining.setup>setupPerWorker (line 96)
Targets T is not two-dimensional. Any advice from here would be appreciated. Thanks. I am trying to design a feedforward network that trains on a 4×5 matrix (5 samples of 4 separate inputs into the neural network) and its outputs are represented by a 4x5x1000 matrix (5 samples of 4 outputs where each component of the 4×1 output vector has 1000 points). This neural net is used to determine an optimal trajectory for a given terminal condition from a set of the same initial conditions . The code for this project will be placed below:
%% Neural Net Training Process
% Initial State
x1 = [0;0]; % Initial Positions
x2 = [1;1]; % Initial Velocities
xo = [x1;x2]; % 4×1 Initial State Vector
% Parsing Training Input Data
x_input = [xf1,xf2,xf4,xf5,xf6]; % 4×5 Terminal State Vector (each xf (4×1) represents a different terminal condition)
% Parsing Training Output Data
x_output = [];
for i=1:4
x_output(i,1,:) = x1(:,i);
x_output(i,2,:) = x2(:,i);
x_output(i,3,:) = x4(:,i);
x_output(i,4,:) = x5(:,i);
x_output(i,5,:) = x6(:,i);
end % 4x5x1000 Terminal State Matrix
% Parsing Validation Data
xf_valid = xf3;
x_valid = x3′;
% Neural Net Architecture Initialization
netconfig = 40;
net = feedforwardnet(netconfig);
net.numInputs = 4;
% Training the Network
for j=1:5
curr_xin = x_input(:,j);
curr_xout = x_output(:,j,:);
net = train(net,curr_xin,curr_xout);
end
From here, I am receieve an error in line 89, where I get the following error: Error using nntraining.setup>setupPerWorker (line 96)
Targets T is not two-dimensional. Any advice from here would be appreciated. Thanks. neural network, feedforwardnet, control, matlab MATLAB Answers — New Questions
Simscape – Source component – Input
I created a hydraulic system with my own custom components (pipes, elbows, tees, orifices,… ) in order to calculate the flow rate at the outlets.
The fluid temperature is changed with the help of a parameter at a "source component". This temperature is used at two lookuptables in order to determine the corresponding viscosity and density of the fluid.
Viscosity and density are domain parameters which are changed by the "source component" in order to provide these for the rest of the model.
Now I want to change the temperature at run time with the help of a "ramp block". Therefor I created an input at the "source component" and connected the "ramp block" by a "simulink-ps-converter".
The issue is now that of course I can´t use an input for lookuptables at the parameter section of the "source component".
I can move the lookuptables to the equations section, but this creates new issues with missing variables for viscosity and density.
Any Idee how I can solve this problem?
This is my source component…
component(Propagation=source) oil_properties
% Oil properties
%
% Temperature range: -15°C – 110°C
%
%
% Fluid type:
%
%Viscosity | CLP | CLP-PG | CLP-HC | *according Rickmeier – Viscosity/Temperature diagram
%
%——————————————————
%
% 100 | 1 | – | – |
%
% 150 | 2 | 6 | 10 |
%
% 220 | 3 | 7 | 11 |
%
% 320 | 4 | 8 | 12 |
%
% 460 | 5 | 9 | 13 |
%
%——————————————————
parameters
fluid_type = 11;
temperature ={20,’1′};
end
parameters (Access=private)
% Temperatur-Viskositätsdiagramm von Rickmeier
%CLP – Mineralöl
temp_CLP_100 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_100 = {[907 904 902 899 896 893 890 887 884 881 878 876 873 870 867 864 861 858 855 852 850 847 844 841 838 835 ], ‘kg/m^3’};
visk_CLP_100 = {[9300 5000 3000 1800 1100 750 500 350 240 170 130 100 70 60 46 38 32 27 22 19 16.5 14.5 12.5 11 9.6 8.6 ], ‘mm^2/s’};
temp_CLP_150 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_150 = {[908 905 903 900 897 894 891 888 885 882 879 877 874 871 868 865 862 859 856 853 850 848 845 842 839 836 ], ‘kg/m^3’};
visk_CLP_150 = {[18000 10000 5500 3400 2000 1200 800 550 380 280 200 150 110 85 65 54 44 36 30 25 22 18.5 16.5 14.5 12.5 11 ], ‘mm^2/s’};
temp_CLP_220 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_220 = {[912 910 907 904 901 898 895 892 889 886 883 880 878 875 872 869 866 863 860 857 854 851 848 846 843 840 ], ‘kg/m^3’};
visk_CLP_220 = {[34000 18000 10000 5500 3400 2000 1300 820 600 420 300 220 165 130 100 80 60 51 42 36 30 26 22 19 17 15 ], ‘mm^2/s’};
temp_CLP_320 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_320 = {[920 917 914 911 908 905 902 899 896 893 890 887 884 881 879 876 873 870 867 864 861 858 855 852 849 846 ], ‘kg/m^3’};
visk_CLP_320 = {[60000 30000 16000 9000 5500 3400 2200 1400 900 600 440 320 240 180 140 110 90 70 58 46 40 32 28 24 21 18.5 ], ‘mm^2/s’};
temp_CLP_460 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_460 = {[920 917 914 911 908 905 902 899 896 893 890 887 884 881 879 876 873 870 867 864 861 858 855 852 849 846 ], ‘kg/m^3’};
visk_CLP_460 = {[110000 50000 28000 16000 9000 5500 3400 2100 1400 900 650 460 340 260 200 150 120 95 75 60 50 44 36 31 27 23 ], ‘mm^2/s’};
%CLP PG – Synthetisches Öl auf Basis Polyglykole
temp_CLP_PG_150 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_PG_150 = {[1084 1080 1077 1073 1070 1066 1063 1060 1056 1053 1049 1046 1042 1039 1035 1032 1028 1025 1022 1018 1015 1011 1008 1004 1001 997 ], ‘kg/m^3’};
visk_CLP_PG_150 = {[7500 3900 2420 1650 1200 850 610 440 340 260 210 150 130 105 90 71 61 52 44 38 32 29 25.5 22.5 20 18.5 ], ‘mm^2/s’};
temp_CLP_PG_220 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_PG_220 = {[1084 1080 1077 1073 1070 1066 1063 1060 1056 1053 1049 1046 1042 1039 1035 1032 1028 1025 1022 1018 1015 1011 1008 1004 1001 997 ], ‘kg/m^3’};
visk_CLP_PG_220 = {[6100 4100 2800 2000 1400 1020 750 550 440 340 260 220 170 140 115 100 95 70 60 50 44 40 34 30 27 24 ], ‘mm^2/s’};
temp_CLP_PG_320 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_PG_320 = {[1091 1087 1084 1080 1077 1073 1070 1067 1063 1060 1056 1053 1049 1046 1042 1039 1035 1032 1028 1025 1021 1018 1014 1011 1007 1004 ], ‘kg/m^3’};
visk_CLP_PG_320 = {[5600 4000 3000 2200 1600 1220 950 775 600 480 400 320 272 225 190 165 140 120 105 92 80 70 62 55 50 45 ], ‘mm^2/s’};
temp_CLP_PG_460 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_PG_460 = {[1081 1077 1074 1070 1067 1063 1060 1057 1053 1050 1046 1043 1039 1036 1032 1029 1026 1022 1019 1015 1012 1008 1005 1001 998 995 ], ‘kg/m^3’};
visk_CLP_PG_460 = {[7300 5400 3900 2900 2200 1700 1300 1050 810 650 550 460 360 310 260 222 190 165 140 120 108 95 85 75 67 60 ], ‘mm^2/s’};
%CLP HC – Synthetisches Öl auf Basis Polyalphaolefine
temp_CLP_HC_150 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_HC_150 = {[871 868 865 862 860 857 854 851 848 846 843 840 837 835 832 829 826 823 821 818 815 812 810 807 804 801 ], ‘kg/m^3’};
visk_CLP_HC_150 = {[6900 4000 2450 1650 1120 800 560 420 310 230 180 150 110 90 71 60 50 42 35 31 27 23.3 20.3 18.2 16 14.5 ], ‘mm^2/s’};
temp_CLP_HC_220 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_HC_220 = {[876 873 870 867 865 862 859 856 853 851 848 845 842 839 837 834 831 828 825 823 820 817 814 812 809 806 ], ‘kg/m^3’};
visk_CLP_HC_220 = {[6900 4000 2600 1800 1300 950 680 510 380 300 230 190 150 120 100 81 70 60 50 44 38 32 29 26 23 21 ], ‘mm^2/s’};
temp_CLP_HC_320 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_HC_320 = {[879 876 873 870 868 865 862 859 856 854 851 848 845 842 840 837 834 831 828 826 823 820 817 814 812 809 ], ‘kg/m^3’};
visk_CLP_HC_320 = {[14500 9000 6000 4000 2700 1900 1350 960 720 540 420 320 260 205 165 137 115 95 80 65 59 50 43 38 33 29.5 ], ‘mm^2/s’};
temp_CLP_HC_460 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_HC_460 = {[881 878 875 872 870 867 864 861 858 856 853 850 847 844 842 839 836 833 830 827 825 822 819 816 813 811 ], ‘kg/m^3’};
visk_CLP_HC_460 = {[25000 14500 9500 6000 4000 2800 1900 1400 1000 720 550 420 340 260 210 170 140 115 95 80 68 59 51 44 38 34 ], ‘mm^2/s’};
temp = [temp_CLP_100; temp_CLP_150; temp_CLP_220; temp_CLP_320; temp_CLP_460; temp_CLP_PG_150; temp_CLP_PG_220; temp_CLP_PG_320; temp_CLP_PG_460; temp_CLP_HC_150; temp_CLP_HC_220; temp_CLP_HC_320; temp_CLP_HC_460];
dens = [dens_CLP_100; dens_CLP_150; dens_CLP_220; dens_CLP_320; dens_CLP_460; dens_CLP_PG_150; dens_CLP_PG_220; dens_CLP_PG_320; dens_CLP_PG_460; dens_CLP_HC_150; dens_CLP_HC_220; dens_CLP_HC_320; dens_CLP_HC_460];
visk = [visk_CLP_100; visk_CLP_150; visk_CLP_220; visk_CLP_320; visk_CLP_460; visk_CLP_PG_150; visk_CLP_PG_220; visk_CLP_PG_320; visk_CLP_PG_460; visk_CLP_HC_150; visk_CLP_HC_220; visk_CLP_HC_320; visk_CLP_HC_460];
density = tablelookup(temp(fluid_type,:) ,dens(fluid_type,:) ,temperature, interpolation = smooth);
viscosity_kin = tablelookup(temp(fluid_type,:) ,visk(fluid_type,:) ,temperature, interpolation = smooth);
end
%inputs
% temperature = {1 , ‘1’ }; % :left
%end
nodes
G = NORD.Hydraulics.Domain.hydraulic(density=density,viscosity_kin=viscosity_kin); % :right
end
end
… and this is my custom domain:
domain hydraulic
% Hydraulic Domain
variables % Across
p = {value={1,’bar’},imin={0,’bar’}}; % Pressure
end
variables(Balancing = true) % Through
q = {0,’lpm’ }; % Flow rate
end
parameters
viscosity_kin = {0,’mm^2/s’ }; % kinematische Viskosität
density = {0,’kg/m^3′ }; % Dichte des Öls
bulk = {0.8e9 ,’Pa’ }; % Bulk modulus at atm. pressure and no gas
alpha = {0.005 ,’1′ }; % Relative amount of trapped air
range_error = {2 ,’1′ }; % Pressure below absolute zero
RD_18 = {0.015, ‘m’ }; % Rohrdurchmesser NW18
RD_10 = {0.008, ‘m’ }; % Rohrdurchmesser NW10
RD_12_5 = {0.0125,’m’ }; % Rohrdurchmesser für DMO
RD_06 = {0.006, ‘m’ }; % Rohrdurchmesser für DMO
BR_18 = {0.060, ‘m’ }; % Biegeradius des Rohres NW18
BR_10 = {0.027, ‘m’ }; % Biegeradius des Rohres NW10
Zeta_R_AURO = {1 , ‘1’ }; % Zeta Wert für Ausfluß (AURO)
Zeta_U_90_18 = {0.110, ‘1’ }; % Zeta Wert für 90° Rohrbogen
Zeta_U_90_10 = {0.117, ‘1’ }; % Zeta Wert für 90° Rohrbogen
Zeta_U_WV = {1.07, ‘1’ }; % Zeta Wert für WV
end
endI created a hydraulic system with my own custom components (pipes, elbows, tees, orifices,… ) in order to calculate the flow rate at the outlets.
The fluid temperature is changed with the help of a parameter at a "source component". This temperature is used at two lookuptables in order to determine the corresponding viscosity and density of the fluid.
Viscosity and density are domain parameters which are changed by the "source component" in order to provide these for the rest of the model.
Now I want to change the temperature at run time with the help of a "ramp block". Therefor I created an input at the "source component" and connected the "ramp block" by a "simulink-ps-converter".
The issue is now that of course I can´t use an input for lookuptables at the parameter section of the "source component".
I can move the lookuptables to the equations section, but this creates new issues with missing variables for viscosity and density.
Any Idee how I can solve this problem?
This is my source component…
component(Propagation=source) oil_properties
% Oil properties
%
% Temperature range: -15°C – 110°C
%
%
% Fluid type:
%
%Viscosity | CLP | CLP-PG | CLP-HC | *according Rickmeier – Viscosity/Temperature diagram
%
%——————————————————
%
% 100 | 1 | – | – |
%
% 150 | 2 | 6 | 10 |
%
% 220 | 3 | 7 | 11 |
%
% 320 | 4 | 8 | 12 |
%
% 460 | 5 | 9 | 13 |
%
%——————————————————
parameters
fluid_type = 11;
temperature ={20,’1′};
end
parameters (Access=private)
% Temperatur-Viskositätsdiagramm von Rickmeier
%CLP – Mineralöl
temp_CLP_100 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_100 = {[907 904 902 899 896 893 890 887 884 881 878 876 873 870 867 864 861 858 855 852 850 847 844 841 838 835 ], ‘kg/m^3’};
visk_CLP_100 = {[9300 5000 3000 1800 1100 750 500 350 240 170 130 100 70 60 46 38 32 27 22 19 16.5 14.5 12.5 11 9.6 8.6 ], ‘mm^2/s’};
temp_CLP_150 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_150 = {[908 905 903 900 897 894 891 888 885 882 879 877 874 871 868 865 862 859 856 853 850 848 845 842 839 836 ], ‘kg/m^3’};
visk_CLP_150 = {[18000 10000 5500 3400 2000 1200 800 550 380 280 200 150 110 85 65 54 44 36 30 25 22 18.5 16.5 14.5 12.5 11 ], ‘mm^2/s’};
temp_CLP_220 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_220 = {[912 910 907 904 901 898 895 892 889 886 883 880 878 875 872 869 866 863 860 857 854 851 848 846 843 840 ], ‘kg/m^3’};
visk_CLP_220 = {[34000 18000 10000 5500 3400 2000 1300 820 600 420 300 220 165 130 100 80 60 51 42 36 30 26 22 19 17 15 ], ‘mm^2/s’};
temp_CLP_320 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_320 = {[920 917 914 911 908 905 902 899 896 893 890 887 884 881 879 876 873 870 867 864 861 858 855 852 849 846 ], ‘kg/m^3’};
visk_CLP_320 = {[60000 30000 16000 9000 5500 3400 2200 1400 900 600 440 320 240 180 140 110 90 70 58 46 40 32 28 24 21 18.5 ], ‘mm^2/s’};
temp_CLP_460 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_460 = {[920 917 914 911 908 905 902 899 896 893 890 887 884 881 879 876 873 870 867 864 861 858 855 852 849 846 ], ‘kg/m^3’};
visk_CLP_460 = {[110000 50000 28000 16000 9000 5500 3400 2100 1400 900 650 460 340 260 200 150 120 95 75 60 50 44 36 31 27 23 ], ‘mm^2/s’};
%CLP PG – Synthetisches Öl auf Basis Polyglykole
temp_CLP_PG_150 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_PG_150 = {[1084 1080 1077 1073 1070 1066 1063 1060 1056 1053 1049 1046 1042 1039 1035 1032 1028 1025 1022 1018 1015 1011 1008 1004 1001 997 ], ‘kg/m^3’};
visk_CLP_PG_150 = {[7500 3900 2420 1650 1200 850 610 440 340 260 210 150 130 105 90 71 61 52 44 38 32 29 25.5 22.5 20 18.5 ], ‘mm^2/s’};
temp_CLP_PG_220 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_PG_220 = {[1084 1080 1077 1073 1070 1066 1063 1060 1056 1053 1049 1046 1042 1039 1035 1032 1028 1025 1022 1018 1015 1011 1008 1004 1001 997 ], ‘kg/m^3’};
visk_CLP_PG_220 = {[6100 4100 2800 2000 1400 1020 750 550 440 340 260 220 170 140 115 100 95 70 60 50 44 40 34 30 27 24 ], ‘mm^2/s’};
temp_CLP_PG_320 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_PG_320 = {[1091 1087 1084 1080 1077 1073 1070 1067 1063 1060 1056 1053 1049 1046 1042 1039 1035 1032 1028 1025 1021 1018 1014 1011 1007 1004 ], ‘kg/m^3’};
visk_CLP_PG_320 = {[5600 4000 3000 2200 1600 1220 950 775 600 480 400 320 272 225 190 165 140 120 105 92 80 70 62 55 50 45 ], ‘mm^2/s’};
temp_CLP_PG_460 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_PG_460 = {[1081 1077 1074 1070 1067 1063 1060 1057 1053 1050 1046 1043 1039 1036 1032 1029 1026 1022 1019 1015 1012 1008 1005 1001 998 995 ], ‘kg/m^3’};
visk_CLP_PG_460 = {[7300 5400 3900 2900 2200 1700 1300 1050 810 650 550 460 360 310 260 222 190 165 140 120 108 95 85 75 67 60 ], ‘mm^2/s’};
%CLP HC – Synthetisches Öl auf Basis Polyalphaolefine
temp_CLP_HC_150 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_HC_150 = {[871 868 865 862 860 857 854 851 848 846 843 840 837 835 832 829 826 823 821 818 815 812 810 807 804 801 ], ‘kg/m^3’};
visk_CLP_HC_150 = {[6900 4000 2450 1650 1120 800 560 420 310 230 180 150 110 90 71 60 50 42 35 31 27 23.3 20.3 18.2 16 14.5 ], ‘mm^2/s’};
temp_CLP_HC_220 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_HC_220 = {[876 873 870 867 865 862 859 856 853 851 848 845 842 839 837 834 831 828 825 823 820 817 814 812 809 806 ], ‘kg/m^3’};
visk_CLP_HC_220 = {[6900 4000 2600 1800 1300 950 680 510 380 300 230 190 150 120 100 81 70 60 50 44 38 32 29 26 23 21 ], ‘mm^2/s’};
temp_CLP_HC_320 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_HC_320 = {[879 876 873 870 868 865 862 859 856 854 851 848 845 842 840 837 834 831 828 826 823 820 817 814 812 809 ], ‘kg/m^3’};
visk_CLP_HC_320 = {[14500 9000 6000 4000 2700 1900 1350 960 720 540 420 320 260 205 165 137 115 95 80 65 59 50 43 38 33 29.5 ], ‘mm^2/s’};
temp_CLP_HC_460 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_HC_460 = {[881 878 875 872 870 867 864 861 858 856 853 850 847 844 842 839 836 833 830 827 825 822 819 816 813 811 ], ‘kg/m^3’};
visk_CLP_HC_460 = {[25000 14500 9500 6000 4000 2800 1900 1400 1000 720 550 420 340 260 210 170 140 115 95 80 68 59 51 44 38 34 ], ‘mm^2/s’};
temp = [temp_CLP_100; temp_CLP_150; temp_CLP_220; temp_CLP_320; temp_CLP_460; temp_CLP_PG_150; temp_CLP_PG_220; temp_CLP_PG_320; temp_CLP_PG_460; temp_CLP_HC_150; temp_CLP_HC_220; temp_CLP_HC_320; temp_CLP_HC_460];
dens = [dens_CLP_100; dens_CLP_150; dens_CLP_220; dens_CLP_320; dens_CLP_460; dens_CLP_PG_150; dens_CLP_PG_220; dens_CLP_PG_320; dens_CLP_PG_460; dens_CLP_HC_150; dens_CLP_HC_220; dens_CLP_HC_320; dens_CLP_HC_460];
visk = [visk_CLP_100; visk_CLP_150; visk_CLP_220; visk_CLP_320; visk_CLP_460; visk_CLP_PG_150; visk_CLP_PG_220; visk_CLP_PG_320; visk_CLP_PG_460; visk_CLP_HC_150; visk_CLP_HC_220; visk_CLP_HC_320; visk_CLP_HC_460];
density = tablelookup(temp(fluid_type,:) ,dens(fluid_type,:) ,temperature, interpolation = smooth);
viscosity_kin = tablelookup(temp(fluid_type,:) ,visk(fluid_type,:) ,temperature, interpolation = smooth);
end
%inputs
% temperature = {1 , ‘1’ }; % :left
%end
nodes
G = NORD.Hydraulics.Domain.hydraulic(density=density,viscosity_kin=viscosity_kin); % :right
end
end
… and this is my custom domain:
domain hydraulic
% Hydraulic Domain
variables % Across
p = {value={1,’bar’},imin={0,’bar’}}; % Pressure
end
variables(Balancing = true) % Through
q = {0,’lpm’ }; % Flow rate
end
parameters
viscosity_kin = {0,’mm^2/s’ }; % kinematische Viskosität
density = {0,’kg/m^3′ }; % Dichte des Öls
bulk = {0.8e9 ,’Pa’ }; % Bulk modulus at atm. pressure and no gas
alpha = {0.005 ,’1′ }; % Relative amount of trapped air
range_error = {2 ,’1′ }; % Pressure below absolute zero
RD_18 = {0.015, ‘m’ }; % Rohrdurchmesser NW18
RD_10 = {0.008, ‘m’ }; % Rohrdurchmesser NW10
RD_12_5 = {0.0125,’m’ }; % Rohrdurchmesser für DMO
RD_06 = {0.006, ‘m’ }; % Rohrdurchmesser für DMO
BR_18 = {0.060, ‘m’ }; % Biegeradius des Rohres NW18
BR_10 = {0.027, ‘m’ }; % Biegeradius des Rohres NW10
Zeta_R_AURO = {1 , ‘1’ }; % Zeta Wert für Ausfluß (AURO)
Zeta_U_90_18 = {0.110, ‘1’ }; % Zeta Wert für 90° Rohrbogen
Zeta_U_90_10 = {0.117, ‘1’ }; % Zeta Wert für 90° Rohrbogen
Zeta_U_WV = {1.07, ‘1’ }; % Zeta Wert für WV
end
end I created a hydraulic system with my own custom components (pipes, elbows, tees, orifices,… ) in order to calculate the flow rate at the outlets.
The fluid temperature is changed with the help of a parameter at a "source component". This temperature is used at two lookuptables in order to determine the corresponding viscosity and density of the fluid.
Viscosity and density are domain parameters which are changed by the "source component" in order to provide these for the rest of the model.
Now I want to change the temperature at run time with the help of a "ramp block". Therefor I created an input at the "source component" and connected the "ramp block" by a "simulink-ps-converter".
The issue is now that of course I can´t use an input for lookuptables at the parameter section of the "source component".
I can move the lookuptables to the equations section, but this creates new issues with missing variables for viscosity and density.
Any Idee how I can solve this problem?
This is my source component…
component(Propagation=source) oil_properties
% Oil properties
%
% Temperature range: -15°C – 110°C
%
%
% Fluid type:
%
%Viscosity | CLP | CLP-PG | CLP-HC | *according Rickmeier – Viscosity/Temperature diagram
%
%——————————————————
%
% 100 | 1 | – | – |
%
% 150 | 2 | 6 | 10 |
%
% 220 | 3 | 7 | 11 |
%
% 320 | 4 | 8 | 12 |
%
% 460 | 5 | 9 | 13 |
%
%——————————————————
parameters
fluid_type = 11;
temperature ={20,’1′};
end
parameters (Access=private)
% Temperatur-Viskositätsdiagramm von Rickmeier
%CLP – Mineralöl
temp_CLP_100 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_100 = {[907 904 902 899 896 893 890 887 884 881 878 876 873 870 867 864 861 858 855 852 850 847 844 841 838 835 ], ‘kg/m^3’};
visk_CLP_100 = {[9300 5000 3000 1800 1100 750 500 350 240 170 130 100 70 60 46 38 32 27 22 19 16.5 14.5 12.5 11 9.6 8.6 ], ‘mm^2/s’};
temp_CLP_150 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_150 = {[908 905 903 900 897 894 891 888 885 882 879 877 874 871 868 865 862 859 856 853 850 848 845 842 839 836 ], ‘kg/m^3’};
visk_CLP_150 = {[18000 10000 5500 3400 2000 1200 800 550 380 280 200 150 110 85 65 54 44 36 30 25 22 18.5 16.5 14.5 12.5 11 ], ‘mm^2/s’};
temp_CLP_220 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_220 = {[912 910 907 904 901 898 895 892 889 886 883 880 878 875 872 869 866 863 860 857 854 851 848 846 843 840 ], ‘kg/m^3’};
visk_CLP_220 = {[34000 18000 10000 5500 3400 2000 1300 820 600 420 300 220 165 130 100 80 60 51 42 36 30 26 22 19 17 15 ], ‘mm^2/s’};
temp_CLP_320 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_320 = {[920 917 914 911 908 905 902 899 896 893 890 887 884 881 879 876 873 870 867 864 861 858 855 852 849 846 ], ‘kg/m^3’};
visk_CLP_320 = {[60000 30000 16000 9000 5500 3400 2200 1400 900 600 440 320 240 180 140 110 90 70 58 46 40 32 28 24 21 18.5 ], ‘mm^2/s’};
temp_CLP_460 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_460 = {[920 917 914 911 908 905 902 899 896 893 890 887 884 881 879 876 873 870 867 864 861 858 855 852 849 846 ], ‘kg/m^3’};
visk_CLP_460 = {[110000 50000 28000 16000 9000 5500 3400 2100 1400 900 650 460 340 260 200 150 120 95 75 60 50 44 36 31 27 23 ], ‘mm^2/s’};
%CLP PG – Synthetisches Öl auf Basis Polyglykole
temp_CLP_PG_150 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_PG_150 = {[1084 1080 1077 1073 1070 1066 1063 1060 1056 1053 1049 1046 1042 1039 1035 1032 1028 1025 1022 1018 1015 1011 1008 1004 1001 997 ], ‘kg/m^3’};
visk_CLP_PG_150 = {[7500 3900 2420 1650 1200 850 610 440 340 260 210 150 130 105 90 71 61 52 44 38 32 29 25.5 22.5 20 18.5 ], ‘mm^2/s’};
temp_CLP_PG_220 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_PG_220 = {[1084 1080 1077 1073 1070 1066 1063 1060 1056 1053 1049 1046 1042 1039 1035 1032 1028 1025 1022 1018 1015 1011 1008 1004 1001 997 ], ‘kg/m^3’};
visk_CLP_PG_220 = {[6100 4100 2800 2000 1400 1020 750 550 440 340 260 220 170 140 115 100 95 70 60 50 44 40 34 30 27 24 ], ‘mm^2/s’};
temp_CLP_PG_320 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_PG_320 = {[1091 1087 1084 1080 1077 1073 1070 1067 1063 1060 1056 1053 1049 1046 1042 1039 1035 1032 1028 1025 1021 1018 1014 1011 1007 1004 ], ‘kg/m^3’};
visk_CLP_PG_320 = {[5600 4000 3000 2200 1600 1220 950 775 600 480 400 320 272 225 190 165 140 120 105 92 80 70 62 55 50 45 ], ‘mm^2/s’};
temp_CLP_PG_460 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_PG_460 = {[1081 1077 1074 1070 1067 1063 1060 1057 1053 1050 1046 1043 1039 1036 1032 1029 1026 1022 1019 1015 1012 1008 1005 1001 998 995 ], ‘kg/m^3’};
visk_CLP_PG_460 = {[7300 5400 3900 2900 2200 1700 1300 1050 810 650 550 460 360 310 260 222 190 165 140 120 108 95 85 75 67 60 ], ‘mm^2/s’};
%CLP HC – Synthetisches Öl auf Basis Polyalphaolefine
temp_CLP_HC_150 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_HC_150 = {[871 868 865 862 860 857 854 851 848 846 843 840 837 835 832 829 826 823 821 818 815 812 810 807 804 801 ], ‘kg/m^3’};
visk_CLP_HC_150 = {[6900 4000 2450 1650 1120 800 560 420 310 230 180 150 110 90 71 60 50 42 35 31 27 23.3 20.3 18.2 16 14.5 ], ‘mm^2/s’};
temp_CLP_HC_220 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_HC_220 = {[876 873 870 867 865 862 859 856 853 851 848 845 842 839 837 834 831 828 825 823 820 817 814 812 809 806 ], ‘kg/m^3’};
visk_CLP_HC_220 = {[6900 4000 2600 1800 1300 950 680 510 380 300 230 190 150 120 100 81 70 60 50 44 38 32 29 26 23 21 ], ‘mm^2/s’};
temp_CLP_HC_320 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_HC_320 = {[879 876 873 870 868 865 862 859 856 854 851 848 845 842 840 837 834 831 828 826 823 820 817 814 812 809 ], ‘kg/m^3’};
visk_CLP_HC_320 = {[14500 9000 6000 4000 2700 1900 1350 960 720 540 420 320 260 205 165 137 115 95 80 65 59 50 43 38 33 29.5 ], ‘mm^2/s’};
temp_CLP_HC_460 = {[-15.00 -10.00 -5.00 0.00 5.00 10.00 15.00 20.00 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00], ‘1’};
dens_CLP_HC_460 = {[881 878 875 872 870 867 864 861 858 856 853 850 847 844 842 839 836 833 830 827 825 822 819 816 813 811 ], ‘kg/m^3’};
visk_CLP_HC_460 = {[25000 14500 9500 6000 4000 2800 1900 1400 1000 720 550 420 340 260 210 170 140 115 95 80 68 59 51 44 38 34 ], ‘mm^2/s’};
temp = [temp_CLP_100; temp_CLP_150; temp_CLP_220; temp_CLP_320; temp_CLP_460; temp_CLP_PG_150; temp_CLP_PG_220; temp_CLP_PG_320; temp_CLP_PG_460; temp_CLP_HC_150; temp_CLP_HC_220; temp_CLP_HC_320; temp_CLP_HC_460];
dens = [dens_CLP_100; dens_CLP_150; dens_CLP_220; dens_CLP_320; dens_CLP_460; dens_CLP_PG_150; dens_CLP_PG_220; dens_CLP_PG_320; dens_CLP_PG_460; dens_CLP_HC_150; dens_CLP_HC_220; dens_CLP_HC_320; dens_CLP_HC_460];
visk = [visk_CLP_100; visk_CLP_150; visk_CLP_220; visk_CLP_320; visk_CLP_460; visk_CLP_PG_150; visk_CLP_PG_220; visk_CLP_PG_320; visk_CLP_PG_460; visk_CLP_HC_150; visk_CLP_HC_220; visk_CLP_HC_320; visk_CLP_HC_460];
density = tablelookup(temp(fluid_type,:) ,dens(fluid_type,:) ,temperature, interpolation = smooth);
viscosity_kin = tablelookup(temp(fluid_type,:) ,visk(fluid_type,:) ,temperature, interpolation = smooth);
end
%inputs
% temperature = {1 , ‘1’ }; % :left
%end
nodes
G = NORD.Hydraulics.Domain.hydraulic(density=density,viscosity_kin=viscosity_kin); % :right
end
end
… and this is my custom domain:
domain hydraulic
% Hydraulic Domain
variables % Across
p = {value={1,’bar’},imin={0,’bar’}}; % Pressure
end
variables(Balancing = true) % Through
q = {0,’lpm’ }; % Flow rate
end
parameters
viscosity_kin = {0,’mm^2/s’ }; % kinematische Viskosität
density = {0,’kg/m^3′ }; % Dichte des Öls
bulk = {0.8e9 ,’Pa’ }; % Bulk modulus at atm. pressure and no gas
alpha = {0.005 ,’1′ }; % Relative amount of trapped air
range_error = {2 ,’1′ }; % Pressure below absolute zero
RD_18 = {0.015, ‘m’ }; % Rohrdurchmesser NW18
RD_10 = {0.008, ‘m’ }; % Rohrdurchmesser NW10
RD_12_5 = {0.0125,’m’ }; % Rohrdurchmesser für DMO
RD_06 = {0.006, ‘m’ }; % Rohrdurchmesser für DMO
BR_18 = {0.060, ‘m’ }; % Biegeradius des Rohres NW18
BR_10 = {0.027, ‘m’ }; % Biegeradius des Rohres NW10
Zeta_R_AURO = {1 , ‘1’ }; % Zeta Wert für Ausfluß (AURO)
Zeta_U_90_18 = {0.110, ‘1’ }; % Zeta Wert für 90° Rohrbogen
Zeta_U_90_10 = {0.117, ‘1’ }; % Zeta Wert für 90° Rohrbogen
Zeta_U_WV = {1.07, ‘1’ }; % Zeta Wert für WV
end
end domain parameters, inputs, source component, simscape MATLAB Answers — New Questions
How to simulate the io interface model of hil testing with Simulink?
I have already simulated the entire vehicle model, but I don’t know how to simulate the IO interface model that can interact with hardware data.I have already simulated the entire vehicle model, but I don’t know how to simulate the IO interface model that can interact with hardware data. I have already simulated the entire vehicle model, but I don’t know how to simulate the IO interface model that can interact with hardware data. simulink, io MATLAB Answers — New Questions
how to find the bit allocation factor?
how bit allocation factor affects the quality of a video? how this factor can be used to find the quality of video? how this factors can be calculated if i have a video?how bit allocation factor affects the quality of a video? how this factor can be used to find the quality of video? how this factors can be calculated if i have a video? how bit allocation factor affects the quality of a video? how this factor can be used to find the quality of video? how this factors can be calculated if i have a video? bit allocation factor MATLAB Answers — New Questions
How to generate Custom Bitstream for Zedboard to deploy Neural Network model?
imds = imageDatastore(‘Result_fish_images(NA)’, …
‘IncludeSubfolders’,true, …
‘LabelSource’,’foldernames’);
%%
[imdsTrain,imdsValidation,imdsTest] = splitEachLabel(imds,0.7,0.15,0.15,"randomized");
%%
numTrainImages = numel(imdsTrain.Labels);
idx = randperm(numTrainImages,16);
figure
for i = 1:16
subplot(4,4,i)
I = readimage(imdsTrain,idx(i));
imshow(I)
end
%%
classNames = categories(imdsTrain.Labels);
numClasses = numel(classNames)
%%
net = imagePretrainedNetwork("alexnet",NumClasses=numClasses);
net = setLearnRateFactor(net,"fc8/Weights",20);
net = setLearnRateFactor(net,"fc8/Bias",20);
%%
inputSize = net.Layers(1).InputSize
%%
pixelRange = [-30 30];
imageAugmenter = imageDataAugmenter( …
‘RandXReflection’,true, …
‘RandXTranslation’,pixelRange, …
‘RandYTranslation’,pixelRange);
augimdsTrain = augmentedImageDatastore(inputSize(1:2),imdsTrain, …
‘DataAugmentation’,imageAugmenter);
%%
augimdsValidation = augmentedImageDatastore(inputSize(1:2),imdsValidation);
%%
options = trainingOptions("sgdm", …
MiniBatchSize=10, …
MaxEpochs=6, …
Metrics="accuracy", …
InitialLearnRate=1e-4, …
Shuffle="every-epoch", …
ValidationData=augimdsValidation, …
ValidationFrequency=3, …
Verbose=false, …
Plots="training-progress");
%%
net = trainnet(augimdsTrain,net,"crossentropy",options);
%%
scores = minibatchpredict(net,augimdsValidation);
YPred = scores2label(scores,classNames);
%%
idx = randperm(numel(imdsValidation.Files),4);
figure
for i = 1:4
subplot(2,2,i)
I = readimage(imdsValidation,idx(i));
imshow(I)
label = YPred(idx(i));
title(string(label));
end
%%
YValidation = imdsValidation.Labels;
accuracy = mean(YPred == YValidation)
%%After the above we performed the quantization and saved the network in quantizedNet variable. We flashed the %%memory card with linux image for zedboard using SoC Blockset support package. We tested the communication between %%our zedboard and laptop via zynq() command and were able to retreive the IP Address of it. Now we want to deploy the %%trained model on zedboard platform using:
%%hTarget = dlhdl.Target(‘Xilinx’,’Interface’,’Ethernet’);
%%hW = dlhdl.Workflow(‘Network’,quantizedNet,’Bitstream’,’zcu102_int8′,’Target’,hTarget);
%%dn=hW.compile;
%%hW.deploy;
%%output=hW.predict(InputImg);
%%This should give us prediction result by performing the operation on FPGA and fetching back the result.
%%But here the pre built bit streams like zc0102 or zc706 are not available for zedboard. How to generate custom %%bitstream targetting zedboard ??imds = imageDatastore(‘Result_fish_images(NA)’, …
‘IncludeSubfolders’,true, …
‘LabelSource’,’foldernames’);
%%
[imdsTrain,imdsValidation,imdsTest] = splitEachLabel(imds,0.7,0.15,0.15,"randomized");
%%
numTrainImages = numel(imdsTrain.Labels);
idx = randperm(numTrainImages,16);
figure
for i = 1:16
subplot(4,4,i)
I = readimage(imdsTrain,idx(i));
imshow(I)
end
%%
classNames = categories(imdsTrain.Labels);
numClasses = numel(classNames)
%%
net = imagePretrainedNetwork("alexnet",NumClasses=numClasses);
net = setLearnRateFactor(net,"fc8/Weights",20);
net = setLearnRateFactor(net,"fc8/Bias",20);
%%
inputSize = net.Layers(1).InputSize
%%
pixelRange = [-30 30];
imageAugmenter = imageDataAugmenter( …
‘RandXReflection’,true, …
‘RandXTranslation’,pixelRange, …
‘RandYTranslation’,pixelRange);
augimdsTrain = augmentedImageDatastore(inputSize(1:2),imdsTrain, …
‘DataAugmentation’,imageAugmenter);
%%
augimdsValidation = augmentedImageDatastore(inputSize(1:2),imdsValidation);
%%
options = trainingOptions("sgdm", …
MiniBatchSize=10, …
MaxEpochs=6, …
Metrics="accuracy", …
InitialLearnRate=1e-4, …
Shuffle="every-epoch", …
ValidationData=augimdsValidation, …
ValidationFrequency=3, …
Verbose=false, …
Plots="training-progress");
%%
net = trainnet(augimdsTrain,net,"crossentropy",options);
%%
scores = minibatchpredict(net,augimdsValidation);
YPred = scores2label(scores,classNames);
%%
idx = randperm(numel(imdsValidation.Files),4);
figure
for i = 1:4
subplot(2,2,i)
I = readimage(imdsValidation,idx(i));
imshow(I)
label = YPred(idx(i));
title(string(label));
end
%%
YValidation = imdsValidation.Labels;
accuracy = mean(YPred == YValidation)
%%After the above we performed the quantization and saved the network in quantizedNet variable. We flashed the %%memory card with linux image for zedboard using SoC Blockset support package. We tested the communication between %%our zedboard and laptop via zynq() command and were able to retreive the IP Address of it. Now we want to deploy the %%trained model on zedboard platform using:
%%hTarget = dlhdl.Target(‘Xilinx’,’Interface’,’Ethernet’);
%%hW = dlhdl.Workflow(‘Network’,quantizedNet,’Bitstream’,’zcu102_int8′,’Target’,hTarget);
%%dn=hW.compile;
%%hW.deploy;
%%output=hW.predict(InputImg);
%%This should give us prediction result by performing the operation on FPGA and fetching back the result.
%%But here the pre built bit streams like zc0102 or zc706 are not available for zedboard. How to generate custom %%bitstream targetting zedboard ?? imds = imageDatastore(‘Result_fish_images(NA)’, …
‘IncludeSubfolders’,true, …
‘LabelSource’,’foldernames’);
%%
[imdsTrain,imdsValidation,imdsTest] = splitEachLabel(imds,0.7,0.15,0.15,"randomized");
%%
numTrainImages = numel(imdsTrain.Labels);
idx = randperm(numTrainImages,16);
figure
for i = 1:16
subplot(4,4,i)
I = readimage(imdsTrain,idx(i));
imshow(I)
end
%%
classNames = categories(imdsTrain.Labels);
numClasses = numel(classNames)
%%
net = imagePretrainedNetwork("alexnet",NumClasses=numClasses);
net = setLearnRateFactor(net,"fc8/Weights",20);
net = setLearnRateFactor(net,"fc8/Bias",20);
%%
inputSize = net.Layers(1).InputSize
%%
pixelRange = [-30 30];
imageAugmenter = imageDataAugmenter( …
‘RandXReflection’,true, …
‘RandXTranslation’,pixelRange, …
‘RandYTranslation’,pixelRange);
augimdsTrain = augmentedImageDatastore(inputSize(1:2),imdsTrain, …
‘DataAugmentation’,imageAugmenter);
%%
augimdsValidation = augmentedImageDatastore(inputSize(1:2),imdsValidation);
%%
options = trainingOptions("sgdm", …
MiniBatchSize=10, …
MaxEpochs=6, …
Metrics="accuracy", …
InitialLearnRate=1e-4, …
Shuffle="every-epoch", …
ValidationData=augimdsValidation, …
ValidationFrequency=3, …
Verbose=false, …
Plots="training-progress");
%%
net = trainnet(augimdsTrain,net,"crossentropy",options);
%%
scores = minibatchpredict(net,augimdsValidation);
YPred = scores2label(scores,classNames);
%%
idx = randperm(numel(imdsValidation.Files),4);
figure
for i = 1:4
subplot(2,2,i)
I = readimage(imdsValidation,idx(i));
imshow(I)
label = YPred(idx(i));
title(string(label));
end
%%
YValidation = imdsValidation.Labels;
accuracy = mean(YPred == YValidation)
%%After the above we performed the quantization and saved the network in quantizedNet variable. We flashed the %%memory card with linux image for zedboard using SoC Blockset support package. We tested the communication between %%our zedboard and laptop via zynq() command and were able to retreive the IP Address of it. Now we want to deploy the %%trained model on zedboard platform using:
%%hTarget = dlhdl.Target(‘Xilinx’,’Interface’,’Ethernet’);
%%hW = dlhdl.Workflow(‘Network’,quantizedNet,’Bitstream’,’zcu102_int8′,’Target’,hTarget);
%%dn=hW.compile;
%%hW.deploy;
%%output=hW.predict(InputImg);
%%This should give us prediction result by performing the operation on FPGA and fetching back the result.
%%But here the pre built bit streams like zc0102 or zc706 are not available for zedboard. How to generate custom %%bitstream targetting zedboard ?? zedboard, fpga, bitstream, neural network, alexnet MATLAB Answers — New Questions
replace sub-matrix values with zeros
Hello,
I have a large matrix C, which contains a number of matrices in the format C{i}{j}(k1,k2). The size of the matrix (value of k1 and k2) are different for different i and j values. I would like to set all k1 and k2 values to zero except for a certain i and j values. For example, i=1:7, and j varies from 1 to 128 for different i values. I want to keep the values of i=1, and j=1 and replace all other values to zero. e.g. C{1,1}{1,1}. Please help me to make the loop where i can keep the original size of the matrix but replace the values with zero except the target ones.
Related information: I encountered this problem when I am using curvelet. I decomposed the image into different scales and wedges. Now I want to do an inverse curvelet transform of the original image without a particular scale and wedge. I would like to separate and visualize the variations at different scales and wedges. I wonder how I can make the matrix right.
thanks a lot in advance.
please helpHello,
I have a large matrix C, which contains a number of matrices in the format C{i}{j}(k1,k2). The size of the matrix (value of k1 and k2) are different for different i and j values. I would like to set all k1 and k2 values to zero except for a certain i and j values. For example, i=1:7, and j varies from 1 to 128 for different i values. I want to keep the values of i=1, and j=1 and replace all other values to zero. e.g. C{1,1}{1,1}. Please help me to make the loop where i can keep the original size of the matrix but replace the values with zero except the target ones.
Related information: I encountered this problem when I am using curvelet. I decomposed the image into different scales and wedges. Now I want to do an inverse curvelet transform of the original image without a particular scale and wedge. I would like to separate and visualize the variations at different scales and wedges. I wonder how I can make the matrix right.
thanks a lot in advance.
please help Hello,
I have a large matrix C, which contains a number of matrices in the format C{i}{j}(k1,k2). The size of the matrix (value of k1 and k2) are different for different i and j values. I would like to set all k1 and k2 values to zero except for a certain i and j values. For example, i=1:7, and j varies from 1 to 128 for different i values. I want to keep the values of i=1, and j=1 and replace all other values to zero. e.g. C{1,1}{1,1}. Please help me to make the loop where i can keep the original size of the matrix but replace the values with zero except the target ones.
Related information: I encountered this problem when I am using curvelet. I decomposed the image into different scales and wedges. Now I want to do an inverse curvelet transform of the original image without a particular scale and wedge. I would like to separate and visualize the variations at different scales and wedges. I wonder how I can make the matrix right.
thanks a lot in advance.
please help matrix, conversion, curvelet, matrix manipulation MATLAB Answers — New Questions
Problem with estimating PDF (ksdensity)
Attached are two sets of data and I need to estimate the Probability density function (PDF) for both of them.
The attached variable detection has 32 elements and a unit of percentages (between 0 and 100 %), and the variable in_process has 96 elements and a unit of number of days (between 0 and 212 days).
I want to estimate the PDF of both variables. For that I am using ksdenity, with the ‘support’ option, because I don’t want the values on x-axis to be negative or over 100%.
Therefore,
for the estimation of PDF of the detection I use the following code:
detection(detection==0)=0.0001; %data must be between the support boundaries
detection(detection==100)=99.9999;
pts=0:0.1:100;
[f,x]=ksdensity(detection,pts,’support’,[0,100]);
plot(x,f);
and for the estimation of PDF of the in_process I use the same following code:
in_process(in_process==0)=1;
in_process(in_process==212)=211;
pts=0:0.1:212;
[f,x]=ksdensity(in_process,pts,’support’,[0 212]);
plot(x,f);
My problem is that the first one looks pretty well (has similar shape as the histogram of detection and looks similar to the PDF that is produced without the support option), while the other one looks bad (creates artificial bumps at the beginning and at the end of the interval).
I don’t undestand why is this happening? Why the first one looks good and the second one doesn’t.
Is this even a good approach and does it make sense to estimate pdf of these variables?
Thank you for your help.Attached are two sets of data and I need to estimate the Probability density function (PDF) for both of them.
The attached variable detection has 32 elements and a unit of percentages (between 0 and 100 %), and the variable in_process has 96 elements and a unit of number of days (between 0 and 212 days).
I want to estimate the PDF of both variables. For that I am using ksdenity, with the ‘support’ option, because I don’t want the values on x-axis to be negative or over 100%.
Therefore,
for the estimation of PDF of the detection I use the following code:
detection(detection==0)=0.0001; %data must be between the support boundaries
detection(detection==100)=99.9999;
pts=0:0.1:100;
[f,x]=ksdensity(detection,pts,’support’,[0,100]);
plot(x,f);
and for the estimation of PDF of the in_process I use the same following code:
in_process(in_process==0)=1;
in_process(in_process==212)=211;
pts=0:0.1:212;
[f,x]=ksdensity(in_process,pts,’support’,[0 212]);
plot(x,f);
My problem is that the first one looks pretty well (has similar shape as the histogram of detection and looks similar to the PDF that is produced without the support option), while the other one looks bad (creates artificial bumps at the beginning and at the end of the interval).
I don’t undestand why is this happening? Why the first one looks good and the second one doesn’t.
Is this even a good approach and does it make sense to estimate pdf of these variables?
Thank you for your help. Attached are two sets of data and I need to estimate the Probability density function (PDF) for both of them.
The attached variable detection has 32 elements and a unit of percentages (between 0 and 100 %), and the variable in_process has 96 elements and a unit of number of days (between 0 and 212 days).
I want to estimate the PDF of both variables. For that I am using ksdenity, with the ‘support’ option, because I don’t want the values on x-axis to be negative or over 100%.
Therefore,
for the estimation of PDF of the detection I use the following code:
detection(detection==0)=0.0001; %data must be between the support boundaries
detection(detection==100)=99.9999;
pts=0:0.1:100;
[f,x]=ksdensity(detection,pts,’support’,[0,100]);
plot(x,f);
and for the estimation of PDF of the in_process I use the same following code:
in_process(in_process==0)=1;
in_process(in_process==212)=211;
pts=0:0.1:212;
[f,x]=ksdensity(in_process,pts,’support’,[0 212]);
plot(x,f);
My problem is that the first one looks pretty well (has similar shape as the histogram of detection and looks similar to the PDF that is produced without the support option), while the other one looks bad (creates artificial bumps at the beginning and at the end of the interval).
I don’t undestand why is this happening? Why the first one looks good and the second one doesn’t.
Is this even a good approach and does it make sense to estimate pdf of these variables?
Thank you for your help. #ksdensity, #pdf MATLAB Answers — New Questions
HOW TO PLOT ON THE SAME FIGURE PLOTS OF DIFFERENT SCRIPTS
Hi, I’m in truble because I have two programs with the same variables and parameters. The main of the study is to change a value and plot the results. The problem is that I want them on the same plot but I use the same name for the variabes in the two different programs so when I use some function to join the figures togheter matlab resets the values obtained in the first program and runs only the second one.
Is there a method to avoid changing all the names of the variables in one of the two programs (because they have something like 500 lines)?Hi, I’m in truble because I have two programs with the same variables and parameters. The main of the study is to change a value and plot the results. The problem is that I want them on the same plot but I use the same name for the variabes in the two different programs so when I use some function to join the figures togheter matlab resets the values obtained in the first program and runs only the second one.
Is there a method to avoid changing all the names of the variables in one of the two programs (because they have something like 500 lines)? Hi, I’m in truble because I have two programs with the same variables and parameters. The main of the study is to change a value and plot the results. The problem is that I want them on the same plot but I use the same name for the variabes in the two different programs so when I use some function to join the figures togheter matlab resets the values obtained in the first program and runs only the second one.
Is there a method to avoid changing all the names of the variables in one of the two programs (because they have something like 500 lines)? transferred MATLAB Answers — New Questions