Category: Matlab
Category Archives: Matlab
Is “simset” not available in MATLAB R2020b anymore ?
I am trying to use "simset" inside a function and it is not assigning the "hidden workspace" to the workspace in my model it keeps trying to grab the base workspace variables and therefore a lot of my variables in the model are not being found.I am trying to use "simset" inside a function and it is not assigning the "hidden workspace" to the workspace in my model it keeps trying to grab the base workspace variables and therefore a lot of my variables in the model are not being found. I am trying to use "simset" inside a function and it is not assigning the "hidden workspace" to the workspace in my model it keeps trying to grab the base workspace variables and therefore a lot of my variables in the model are not being found. simset, simulink, matlab MATLAB Answers — New Questions
how to make distance affect on attenuation factor?
This is so far my distance effect function, but the attenuation factor(Att_linear) doens’t work with input signal(inwave_lowpass) arrays have incompatible sizes for this operation, I tried to use convolve to solve it, but it will make the output (attenuated_signal) sounds like broken noise. I also tried filter(Att_linear, 1, inwave_lowpass) but it make the output sounds like broken also.
[inwave,fs]=audioread("anechoic_voice.wav");
%LOW-PASS FILTER%
% Define filter specifications
cutoff_frequency = 20000;
sampling_frequency = fs;
filter_order = 4;
%matlab lowpass filter
inwave_lowpass = lowpass(inwave,cutoff_frequency,sampling_frequency) ;
%ABSORPTION context%
%citing dissipation function by Densil C.(2015)
%alpha=absorption coeff (dB/m)
f_desired=(20:20000);
alpha = dissipation (f_desired, 20, 50,100,1);
%definie destination
r=1;
%decay factor in dB
Att=alpha.*r;
% Convert attenuation factor to linear scale
Att_linear = 10.^(Att/20);
% Apply attenuation to the input signal%
%attenuated_signal =inwave_lowpass.*Att_linear; %Problem: .*not work cuz arrays have incompatible sizes for this operation.%
attenuated_signal =conv(inwave_lowpass,Att_linear);%Problem: convolve not work for r when output.%
% Plot the frequency response of the attenuation filter
freqz(Att_linear, 1, 1024, fs);
% Play the attenuated signal
sound(attenuated_signal, fs);
Thank you for your time!This is so far my distance effect function, but the attenuation factor(Att_linear) doens’t work with input signal(inwave_lowpass) arrays have incompatible sizes for this operation, I tried to use convolve to solve it, but it will make the output (attenuated_signal) sounds like broken noise. I also tried filter(Att_linear, 1, inwave_lowpass) but it make the output sounds like broken also.
[inwave,fs]=audioread("anechoic_voice.wav");
%LOW-PASS FILTER%
% Define filter specifications
cutoff_frequency = 20000;
sampling_frequency = fs;
filter_order = 4;
%matlab lowpass filter
inwave_lowpass = lowpass(inwave,cutoff_frequency,sampling_frequency) ;
%ABSORPTION context%
%citing dissipation function by Densil C.(2015)
%alpha=absorption coeff (dB/m)
f_desired=(20:20000);
alpha = dissipation (f_desired, 20, 50,100,1);
%definie destination
r=1;
%decay factor in dB
Att=alpha.*r;
% Convert attenuation factor to linear scale
Att_linear = 10.^(Att/20);
% Apply attenuation to the input signal%
%attenuated_signal =inwave_lowpass.*Att_linear; %Problem: .*not work cuz arrays have incompatible sizes for this operation.%
attenuated_signal =conv(inwave_lowpass,Att_linear);%Problem: convolve not work for r when output.%
% Plot the frequency response of the attenuation filter
freqz(Att_linear, 1, 1024, fs);
% Play the attenuated signal
sound(attenuated_signal, fs);
Thank you for your time! This is so far my distance effect function, but the attenuation factor(Att_linear) doens’t work with input signal(inwave_lowpass) arrays have incompatible sizes for this operation, I tried to use convolve to solve it, but it will make the output (attenuated_signal) sounds like broken noise. I also tried filter(Att_linear, 1, inwave_lowpass) but it make the output sounds like broken also.
[inwave,fs]=audioread("anechoic_voice.wav");
%LOW-PASS FILTER%
% Define filter specifications
cutoff_frequency = 20000;
sampling_frequency = fs;
filter_order = 4;
%matlab lowpass filter
inwave_lowpass = lowpass(inwave,cutoff_frequency,sampling_frequency) ;
%ABSORPTION context%
%citing dissipation function by Densil C.(2015)
%alpha=absorption coeff (dB/m)
f_desired=(20:20000);
alpha = dissipation (f_desired, 20, 50,100,1);
%definie destination
r=1;
%decay factor in dB
Att=alpha.*r;
% Convert attenuation factor to linear scale
Att_linear = 10.^(Att/20);
% Apply attenuation to the input signal%
%attenuated_signal =inwave_lowpass.*Att_linear; %Problem: .*not work cuz arrays have incompatible sizes for this operation.%
attenuated_signal =conv(inwave_lowpass,Att_linear);%Problem: convolve not work for r when output.%
% Plot the frequency response of the attenuation filter
freqz(Att_linear, 1, 1024, fs);
% Play the attenuated signal
sound(attenuated_signal, fs);
Thank you for your time! attenuation, dsp MATLAB Answers — New Questions
i need to find frequency eqaution and then compute for the non zero natural frequencies the five degree of freedom system using damping ,mass and stiffness matrices
% Construct mass matrix
M = [m1, 0, 0, 0, 0;
0, m2, 0, 0, 0;
0, 0, m3, 0, 0;
0, 0, 0, m4, 0;
0, 0, 0, 0, m5]
% Construct damping matrix
C = [c2, -c2, 0, 0, 0;
-c2, c2+c3, -c3, 0, 0;
0, -c3, c3+c4, -c4, 0;
0, 0, -c4, c4+c5, -c5;
0, 0, 0, -c5, c5];
C= 1000*C
% Construct stiffness matrix
K = [k2, -k2, 0, 0, 0;
-k2, k2+k3, -k3, 0, 0;
0, -k3, k3+k4, k4, 0;
0, 0, -k4, k4+k5, -k5;
0, 0, 0, -k5, k5];% Construct mass matrix
M = [m1, 0, 0, 0, 0;
0, m2, 0, 0, 0;
0, 0, m3, 0, 0;
0, 0, 0, m4, 0;
0, 0, 0, 0, m5]
% Construct damping matrix
C = [c2, -c2, 0, 0, 0;
-c2, c2+c3, -c3, 0, 0;
0, -c3, c3+c4, -c4, 0;
0, 0, -c4, c4+c5, -c5;
0, 0, 0, -c5, c5];
C= 1000*C
% Construct stiffness matrix
K = [k2, -k2, 0, 0, 0;
-k2, k2+k3, -k3, 0, 0;
0, -k3, k3+k4, k4, 0;
0, 0, -k4, k4+k5, -k5;
0, 0, 0, -k5, k5]; % Construct mass matrix
M = [m1, 0, 0, 0, 0;
0, m2, 0, 0, 0;
0, 0, m3, 0, 0;
0, 0, 0, m4, 0;
0, 0, 0, 0, m5]
% Construct damping matrix
C = [c2, -c2, 0, 0, 0;
-c2, c2+c3, -c3, 0, 0;
0, -c3, c3+c4, -c4, 0;
0, 0, -c4, c4+c5, -c5;
0, 0, 0, -c5, c5];
C= 1000*C
% Construct stiffness matrix
K = [k2, -k2, 0, 0, 0;
-k2, k2+k3, -k3, 0, 0;
0, -k3, k3+k4, k4, 0;
0, 0, -k4, k4+k5, -k5;
0, 0, 0, -k5, k5]; matlab, vibration MATLAB Answers — New Questions
The mathematical details of using regression kernel for incremental learning
You state that in incremental learning using regression kernel "binary Gaussian kernel regression model for incremental learning. The kernel model maps data in a low-dimensional space into a high-dimensional space, then fits a linear model in the high-dimensional space."
I am writing a paper so I need mathematical details of mapping that maps data to high dimensional spaceYou state that in incremental learning using regression kernel "binary Gaussian kernel regression model for incremental learning. The kernel model maps data in a low-dimensional space into a high-dimensional space, then fits a linear model in the high-dimensional space."
I am writing a paper so I need mathematical details of mapping that maps data to high dimensional space You state that in incremental learning using regression kernel "binary Gaussian kernel regression model for incremental learning. The kernel model maps data in a low-dimensional space into a high-dimensional space, then fits a linear model in the high-dimensional space."
I am writing a paper so I need mathematical details of mapping that maps data to high dimensional space incremental learning, svm, machine learning MATLAB Answers — New Questions
Assignment help… Inputting double array into function.
Hello everyone. This is my first post here. I have no coding experience and am a current student at U.C. Berkeley studying Engineering Physics. I am taking a programming course that is using matlab and I am TERRIBLE at programming. Anyway thanks for all the help and support in advance.
The assignment is to calculate the surface area and volume of a cylinder. I don’t want a solution because I really need to learn this and some day wish to be pretty proficient with matlab as I will use it a lot for my major.
This is what I’ve done so far. It seems very basic.
function [ S , V ] = myCylinder( R,H )
S = (2*pi*R*H) + (2*pi*(R^2)); % Calculates the surface area of Cylinder.
V = (pi*(R^2)*H); % Calculates the volume of the Cylinder.
The problem I am having is it says I should be able to input the data as a double array.
So I could write
myCylinder([1,2],[2,4])
My attempt:
I was trying to use array indexing and reading up on that section in the text book but for the life of me after a long while I can not figure it out. Any tips and suggestions would be greatly appreciated. Thanks Guys!!
Anthony
PS having issues with inputting code into the forum. If anyone could explain an easier way for future use that would also be awesome.Hello everyone. This is my first post here. I have no coding experience and am a current student at U.C. Berkeley studying Engineering Physics. I am taking a programming course that is using matlab and I am TERRIBLE at programming. Anyway thanks for all the help and support in advance.
The assignment is to calculate the surface area and volume of a cylinder. I don’t want a solution because I really need to learn this and some day wish to be pretty proficient with matlab as I will use it a lot for my major.
This is what I’ve done so far. It seems very basic.
function [ S , V ] = myCylinder( R,H )
S = (2*pi*R*H) + (2*pi*(R^2)); % Calculates the surface area of Cylinder.
V = (pi*(R^2)*H); % Calculates the volume of the Cylinder.
The problem I am having is it says I should be able to input the data as a double array.
So I could write
myCylinder([1,2],[2,4])
My attempt:
I was trying to use array indexing and reading up on that section in the text book but for the life of me after a long while I can not figure it out. Any tips and suggestions would be greatly appreciated. Thanks Guys!!
Anthony
PS having issues with inputting code into the forum. If anyone could explain an easier way for future use that would also be awesome. Hello everyone. This is my first post here. I have no coding experience and am a current student at U.C. Berkeley studying Engineering Physics. I am taking a programming course that is using matlab and I am TERRIBLE at programming. Anyway thanks for all the help and support in advance.
The assignment is to calculate the surface area and volume of a cylinder. I don’t want a solution because I really need to learn this and some day wish to be pretty proficient with matlab as I will use it a lot for my major.
This is what I’ve done so far. It seems very basic.
function [ S , V ] = myCylinder( R,H )
S = (2*pi*R*H) + (2*pi*(R^2)); % Calculates the surface area of Cylinder.
V = (pi*(R^2)*H); % Calculates the volume of the Cylinder.
The problem I am having is it says I should be able to input the data as a double array.
So I could write
myCylinder([1,2],[2,4])
My attempt:
I was trying to use array indexing and reading up on that section in the text book but for the life of me after a long while I can not figure it out. Any tips and suggestions would be greatly appreciated. Thanks Guys!!
Anthony
PS having issues with inputting code into the forum. If anyone could explain an easier way for future use that would also be awesome. double array MATLAB Answers — New Questions
Issue with Configuring Plant Model from ECU TEST tool
Im currentyl working on setting up an ECU TEST project for my remote Test bench. I face the following error while trying to conenct to the test bench model port,
Could anyone help me resolve this issue?
Thank you,
Best Regards,
DhivyaIm currentyl working on setting up an ECU TEST project for my remote Test bench. I face the following error while trying to conenct to the test bench model port,
Could anyone help me resolve this issue?
Thank you,
Best Regards,
Dhivya Im currentyl working on setting up an ECU TEST project for my remote Test bench. I face the following error while trying to conenct to the test bench model port,
Could anyone help me resolve this issue?
Thank you,
Best Regards,
Dhivya simulink, ecu-test, model MATLAB Answers — New Questions
How to generating LDPC parity-check matrices with arbitrary sizes?
I want to use comm.LDPCEncoder/comm.LDPCDecoder and i know to use this encoder decoder in Matlab the H matrices should be Systematic (support Systematic codes only) otherwise i will receive this error.
"the last (N-K) columns of the parity-check matrix must be invertible in GF(2)."
I know two methods from MATLAB that will generate parity-check matrices:
H = dvbs2ldpc(r)
h = hammgen(m)
However, these methods are restricted to a certain ratio between rows and columns. I tried some other third-party scripts to generate the matrix, but some of them don’t seem to return a valid matrix, since "comm.LDPCDecoder" will fail with the same error.
I used some predefined H matrices of Mackay, but no way.
lent of my code-word is not fix it’s about 1000 to 3000 it depend to the situation of my simulation(for example code-word length is equal to 1536 or another case 2048), that’s why i should create a spars matrix then use it.
Now how to generate the LDPC parity-check matrices with arbitrary sizes[depend to length of my code-word]?
How to generating LDPC parity-check matrices with arbitrary sizes?I want to use comm.LDPCEncoder/comm.LDPCDecoder and i know to use this encoder decoder in Matlab the H matrices should be Systematic (support Systematic codes only) otherwise i will receive this error.
"the last (N-K) columns of the parity-check matrix must be invertible in GF(2)."
I know two methods from MATLAB that will generate parity-check matrices:
H = dvbs2ldpc(r)
h = hammgen(m)
However, these methods are restricted to a certain ratio between rows and columns. I tried some other third-party scripts to generate the matrix, but some of them don’t seem to return a valid matrix, since "comm.LDPCDecoder" will fail with the same error.
I used some predefined H matrices of Mackay, but no way.
lent of my code-word is not fix it’s about 1000 to 3000 it depend to the situation of my simulation(for example code-word length is equal to 1536 or another case 2048), that’s why i should create a spars matrix then use it.
Now how to generate the LDPC parity-check matrices with arbitrary sizes[depend to length of my code-word]?
How to generating LDPC parity-check matrices with arbitrary sizes? I want to use comm.LDPCEncoder/comm.LDPCDecoder and i know to use this encoder decoder in Matlab the H matrices should be Systematic (support Systematic codes only) otherwise i will receive this error.
"the last (N-K) columns of the parity-check matrix must be invertible in GF(2)."
I know two methods from MATLAB that will generate parity-check matrices:
H = dvbs2ldpc(r)
h = hammgen(m)
However, these methods are restricted to a certain ratio between rows and columns. I tried some other third-party scripts to generate the matrix, but some of them don’t seem to return a valid matrix, since "comm.LDPCDecoder" will fail with the same error.
I used some predefined H matrices of Mackay, but no way.
lent of my code-word is not fix it’s about 1000 to 3000 it depend to the situation of my simulation(for example code-word length is equal to 1536 or another case 2048), that’s why i should create a spars matrix then use it.
Now how to generate the LDPC parity-check matrices with arbitrary sizes[depend to length of my code-word]?
How to generating LDPC parity-check matrices with arbitrary sizes? ldpc, parity-check matrices, h matrices, comm.ldpcencoder, comm.ldpcdecoder MATLAB Answers — New Questions
How to view or change the driving cycle used in this model
Hi,
Can anyone help me find the table the import block is referring to to feed the reference velocities to the model. And also what would be the steps if i want to create such a input for a new model?
When I go to the "block parameters" for the inport block , then "Connect Input". Here I fond no signal pre selected variable.
I downloaded this model from https://in.mathworks.com/matlabcentral/fileexchange/63823-matlab-and-simulink-racing-lounge-vehicle-modeling
Thanks.Hi,
Can anyone help me find the table the import block is referring to to feed the reference velocities to the model. And also what would be the steps if i want to create such a input for a new model?
When I go to the "block parameters" for the inport block , then "Connect Input". Here I fond no signal pre selected variable.
I downloaded this model from https://in.mathworks.com/matlabcentral/fileexchange/63823-matlab-and-simulink-racing-lounge-vehicle-modeling
Thanks. Hi,
Can anyone help me find the table the import block is referring to to feed the reference velocities to the model. And also what would be the steps if i want to create such a input for a new model?
When I go to the "block parameters" for the inport block , then "Connect Input". Here I fond no signal pre selected variable.
I downloaded this model from https://in.mathworks.com/matlabcentral/fileexchange/63823-matlab-and-simulink-racing-lounge-vehicle-modeling
Thanks. simulink, vehicle model MATLAB Answers — New Questions
How can I get RAW capture with webcam function(without Image Acqusitio Toolbox)?
Hi,
I’m developing a depth camera and the camera using UVC(= webcam).
The output of the camera is not YUV or RGB but RAW16.
I tested that it is working with ‘webcam’ function in Matlab.
However, webcam function can only deliver the RGB image format with ‘snapshot’,(480x640x3(uint8)).
Can I get the RAW16(uint16) data using webcam/snapthot function?
I cannot find any options to do this.
BR,
Chanyong.Hi,
I’m developing a depth camera and the camera using UVC(= webcam).
The output of the camera is not YUV or RGB but RAW16.
I tested that it is working with ‘webcam’ function in Matlab.
However, webcam function can only deliver the RGB image format with ‘snapshot’,(480x640x3(uint8)).
Can I get the RAW16(uint16) data using webcam/snapthot function?
I cannot find any options to do this.
BR,
Chanyong. Hi,
I’m developing a depth camera and the camera using UVC(= webcam).
The output of the camera is not YUV or RGB but RAW16.
I tested that it is working with ‘webcam’ function in Matlab.
However, webcam function can only deliver the RGB image format with ‘snapshot’,(480x640x3(uint8)).
Can I get the RAW16(uint16) data using webcam/snapthot function?
I cannot find any options to do this.
BR,
Chanyong. webcam MATLAB Answers — New Questions
MATLAB Online command window not showing “>>” with no response in any input
Post Content Post Content command MATLAB Answers — New Questions
3/8 Simpson’s Rule
Hello guys. I have homework and I done most of parts. But I have a problem in code. Please help me. The questions like this
Write aMATLAB implementation that applies the Simpson’s 3/8 rule to find an approximation I
for I= integral(from 0 to 1) (e ^2x)*sin(6x)dx
when n=30,60,90 and 120
f=@(x)(exp^(2*x))*sin(6*x);
a=input(‘Enter lower limit a: ‘);
b=input(‘Enter upper limit b: ‘);
n=input(‘Enter the number of sub-intervals n: ‘);
h=(b-a)/n;
if rem(n,3)~=0
fprintf(‘n Enter valid n!!!’);
n=input(‘n Enter n as multiple of 3: ‘);
end
for k=1:1:n
x(k)=a+k*h;
y(k)=f(x(k));
end
so=0;sm3=0;
for k=2:1:n-1
if rem(k,3)==0
sm3=sm3+y(k);
else
so=so+y(k);
end
end
answer=(3*h/8)*(f(a)+f(b)+3*so+2*sm3);
fprintf(‘n The value of integration is %f’,answer);Hello guys. I have homework and I done most of parts. But I have a problem in code. Please help me. The questions like this
Write aMATLAB implementation that applies the Simpson’s 3/8 rule to find an approximation I
for I= integral(from 0 to 1) (e ^2x)*sin(6x)dx
when n=30,60,90 and 120
f=@(x)(exp^(2*x))*sin(6*x);
a=input(‘Enter lower limit a: ‘);
b=input(‘Enter upper limit b: ‘);
n=input(‘Enter the number of sub-intervals n: ‘);
h=(b-a)/n;
if rem(n,3)~=0
fprintf(‘n Enter valid n!!!’);
n=input(‘n Enter n as multiple of 3: ‘);
end
for k=1:1:n
x(k)=a+k*h;
y(k)=f(x(k));
end
so=0;sm3=0;
for k=2:1:n-1
if rem(k,3)==0
sm3=sm3+y(k);
else
so=so+y(k);
end
end
answer=(3*h/8)*(f(a)+f(b)+3*so+2*sm3);
fprintf(‘n The value of integration is %f’,answer); Hello guys. I have homework and I done most of parts. But I have a problem in code. Please help me. The questions like this
Write aMATLAB implementation that applies the Simpson’s 3/8 rule to find an approximation I
for I= integral(from 0 to 1) (e ^2x)*sin(6x)dx
when n=30,60,90 and 120
f=@(x)(exp^(2*x))*sin(6*x);
a=input(‘Enter lower limit a: ‘);
b=input(‘Enter upper limit b: ‘);
n=input(‘Enter the number of sub-intervals n: ‘);
h=(b-a)/n;
if rem(n,3)~=0
fprintf(‘n Enter valid n!!!’);
n=input(‘n Enter n as multiple of 3: ‘);
end
for k=1:1:n
x(k)=a+k*h;
y(k)=f(x(k));
end
so=0;sm3=0;
for k=2:1:n-1
if rem(k,3)==0
sm3=sm3+y(k);
else
so=so+y(k);
end
end
answer=(3*h/8)*(f(a)+f(b)+3*so+2*sm3);
fprintf(‘n The value of integration is %f’,answer); 3/8 simpson’s rule MATLAB Answers — New Questions
analyticity of a function
is there any function can be used to check if a function is analytic or not?is there any function can be used to check if a function is analytic or not? is there any function can be used to check if a function is analytic or not? MATLAB Answers — New Questions
• Given a three-phase power system with a medium-length transmission line, calculate the sending-end voltage and current by hand and by using Matlab code.
Trial>> %M-file to calculate the sending end voltage and current for a medium-length transmission line.
Trial>> %Initialize received voltage, impedance, and admittance
Trial>> vr = 12700 ;
Trial>> z = 0.1 + j*0.82;
Trial>> y = j*4.00e-3;
Trial>> %Calculate ABCD constants
Trial>> A=z*y/2 + 1;
Trial>> B=z;
Trial>> C=y * (z*y/4 + 1);
Trial>> D=z*y/2 + 1;
Trial>> %Calculate the sending end voltage
Trial>> ir = pol2cart(393.65,5.28);
Trial>> vs = A * vr + B * ir;
Trial>> [mag,phase] = cart2pol(vs);
Not enough input arguments.
Error in cart2pol (line 21)
th = atan2(y,x);Trial>> %M-file to calculate the sending end voltage and current for a medium-length transmission line.
Trial>> %Initialize received voltage, impedance, and admittance
Trial>> vr = 12700 ;
Trial>> z = 0.1 + j*0.82;
Trial>> y = j*4.00e-3;
Trial>> %Calculate ABCD constants
Trial>> A=z*y/2 + 1;
Trial>> B=z;
Trial>> C=y * (z*y/4 + 1);
Trial>> D=z*y/2 + 1;
Trial>> %Calculate the sending end voltage
Trial>> ir = pol2cart(393.65,5.28);
Trial>> vs = A * vr + B * ir;
Trial>> [mag,phase] = cart2pol(vs);
Not enough input arguments.
Error in cart2pol (line 21)
th = atan2(y,x); Trial>> %M-file to calculate the sending end voltage and current for a medium-length transmission line.
Trial>> %Initialize received voltage, impedance, and admittance
Trial>> vr = 12700 ;
Trial>> z = 0.1 + j*0.82;
Trial>> y = j*4.00e-3;
Trial>> %Calculate ABCD constants
Trial>> A=z*y/2 + 1;
Trial>> B=z;
Trial>> C=y * (z*y/4 + 1);
Trial>> D=z*y/2 + 1;
Trial>> %Calculate the sending end voltage
Trial>> ir = pol2cart(393.65,5.28);
Trial>> vs = A * vr + B * ir;
Trial>> [mag,phase] = cart2pol(vs);
Not enough input arguments.
Error in cart2pol (line 21)
th = atan2(y,x); how do i write the cart2 pol and pol2 cart formula for this? MATLAB Answers — New Questions
liscence manager error 8
i want to fix this error instantlyi want to fix this error instantly i want to fix this error instantly how to fix this MATLAB Answers — New Questions
optimization of nested loop with two variables
I have an optimization problem of minimizing a two-stage sampling variance subject to the expected variable cost as constraint, and here are my functions:
the objective function is:
function dblSum=dblSumFun(n_h,m_hi)
h=length(N_h);
dblSum=0;
for h=1:length(N_h)
iSum=0;
for i=1:N_h(h)
iTerm=(1/m_hi(i)-1/M_hi(i))*M_hi(i).^2*swh2(h);
iSum=iSum+iTerm;
end
hTerm = (1/n_h(h)-1/N_h(h))*N_h(h)^2*sbh2(h)+N_h(h)/n_h(h)*iSum;
dblSum=dblSum+hterm;
end
end
and the constraint is:
function [c,ceq]=nonlcon(n_h,m_hi)
h=length(N_h)
function dblSumc=dblSumFun(n_h,m_hi)
dblSumc=0;
for h=1:length(N_h)
iSum=0;
for i=1:N_h(h)
iTerm=(0.5*m_hi(i))
iSum=iSum+iTerm;
end
hTerm = 3.5-n_h(h)*0.7-n_h(h)/N_h(h)*iSum;
dblSumc=dblSumc+hterm;
end
end
ceq=dblSumc;% this will be satisfied if it eval to zero
c=[];
and the main coding for optimization is as follows
n_h0=zeros(length(N_h),1);%initial guess
m_hi0=zeros(26*n_h(h),1);
X0=[n_h0;m_hi0];
A=[];
B=[];
Aeq=[];
Beq=[];
options=optimoptions(‘fmincon’,’Algorithm’,’sqp’,’Display’,’iter-detailed’,…
‘MaxFunctionEvaluations’,100000,’MaxIterations’,2000,…
‘FunctionTolerance’,1e-10);
[n_h,m_hi,const]=fmincon(@(n_h,m_hi) obj_function(n_h,m_hi),X0,A,B,Aeq,Beq,LB,UB,@(n_h,m_hi) nonlcon(n_h,m_hi),options)
I wanted to obtain a vector of n_h for h=1,…,26; and a vector of m_hi for h=1,…,26 and i=1,…,n_h(h). Any help?I have an optimization problem of minimizing a two-stage sampling variance subject to the expected variable cost as constraint, and here are my functions:
the objective function is:
function dblSum=dblSumFun(n_h,m_hi)
h=length(N_h);
dblSum=0;
for h=1:length(N_h)
iSum=0;
for i=1:N_h(h)
iTerm=(1/m_hi(i)-1/M_hi(i))*M_hi(i).^2*swh2(h);
iSum=iSum+iTerm;
end
hTerm = (1/n_h(h)-1/N_h(h))*N_h(h)^2*sbh2(h)+N_h(h)/n_h(h)*iSum;
dblSum=dblSum+hterm;
end
end
and the constraint is:
function [c,ceq]=nonlcon(n_h,m_hi)
h=length(N_h)
function dblSumc=dblSumFun(n_h,m_hi)
dblSumc=0;
for h=1:length(N_h)
iSum=0;
for i=1:N_h(h)
iTerm=(0.5*m_hi(i))
iSum=iSum+iTerm;
end
hTerm = 3.5-n_h(h)*0.7-n_h(h)/N_h(h)*iSum;
dblSumc=dblSumc+hterm;
end
end
ceq=dblSumc;% this will be satisfied if it eval to zero
c=[];
and the main coding for optimization is as follows
n_h0=zeros(length(N_h),1);%initial guess
m_hi0=zeros(26*n_h(h),1);
X0=[n_h0;m_hi0];
A=[];
B=[];
Aeq=[];
Beq=[];
options=optimoptions(‘fmincon’,’Algorithm’,’sqp’,’Display’,’iter-detailed’,…
‘MaxFunctionEvaluations’,100000,’MaxIterations’,2000,…
‘FunctionTolerance’,1e-10);
[n_h,m_hi,const]=fmincon(@(n_h,m_hi) obj_function(n_h,m_hi),X0,A,B,Aeq,Beq,LB,UB,@(n_h,m_hi) nonlcon(n_h,m_hi),options)
I wanted to obtain a vector of n_h for h=1,…,26; and a vector of m_hi for h=1,…,26 and i=1,…,n_h(h). Any help? I have an optimization problem of minimizing a two-stage sampling variance subject to the expected variable cost as constraint, and here are my functions:
the objective function is:
function dblSum=dblSumFun(n_h,m_hi)
h=length(N_h);
dblSum=0;
for h=1:length(N_h)
iSum=0;
for i=1:N_h(h)
iTerm=(1/m_hi(i)-1/M_hi(i))*M_hi(i).^2*swh2(h);
iSum=iSum+iTerm;
end
hTerm = (1/n_h(h)-1/N_h(h))*N_h(h)^2*sbh2(h)+N_h(h)/n_h(h)*iSum;
dblSum=dblSum+hterm;
end
end
and the constraint is:
function [c,ceq]=nonlcon(n_h,m_hi)
h=length(N_h)
function dblSumc=dblSumFun(n_h,m_hi)
dblSumc=0;
for h=1:length(N_h)
iSum=0;
for i=1:N_h(h)
iTerm=(0.5*m_hi(i))
iSum=iSum+iTerm;
end
hTerm = 3.5-n_h(h)*0.7-n_h(h)/N_h(h)*iSum;
dblSumc=dblSumc+hterm;
end
end
ceq=dblSumc;% this will be satisfied if it eval to zero
c=[];
and the main coding for optimization is as follows
n_h0=zeros(length(N_h),1);%initial guess
m_hi0=zeros(26*n_h(h),1);
X0=[n_h0;m_hi0];
A=[];
B=[];
Aeq=[];
Beq=[];
options=optimoptions(‘fmincon’,’Algorithm’,’sqp’,’Display’,’iter-detailed’,…
‘MaxFunctionEvaluations’,100000,’MaxIterations’,2000,…
‘FunctionTolerance’,1e-10);
[n_h,m_hi,const]=fmincon(@(n_h,m_hi) obj_function(n_h,m_hi),X0,A,B,Aeq,Beq,LB,UB,@(n_h,m_hi) nonlcon(n_h,m_hi),options)
I wanted to obtain a vector of n_h for h=1,…,26; and a vector of m_hi for h=1,…,26 and i=1,…,n_h(h). Any help? nonlinear optimization nested sum vector MATLAB Answers — New Questions
How to Increase plotting speed
Hi everyone,I have a big trouble on plotting my results,it took a long time to complete the figure.Is there any method to increase plotting speed?
Thanks for your help!!!
clear
L=0.1;
a=L/2;
v=3e8;
f1=1.2e9;
f2=4.8e9;
f3=10e9;
w1=(2*pi*f1);
w2=(2*pi*f2);
w3=(2*pi*f3);
Z01=50;
Z02=50;
a0=(log(Z02/Z01))./(2.*L);
T=2*a;
k=1;
syms x y w
Am=-5;
%%% Eight section SFG
% Calculate gamma
s=L/8;
for n=1:1:k
V=Am(n);
P_am=((V*cos(n*pi*x/T)))*(exp(-2*1i*(w/v)*x));
P_am_int1(n)=int(P_am,x,[0 s]);
P_am_int2(n)=int(P_am,x,[s 2*s]);
P_am_int3(n)=int(P_am,x,[2*s 3*s]);
P_am_int4(n)=int(P_am,x,[3*s 4*s]);
P_am_int5(n)=int(P_am,x,[4*s 5*s]);
P_am_int6(n)=int(P_am,x,[5*s 6*s]);
P_am_int7(n)=int(P_am,x,[6*s 7*s]);
P_am_int8(n)=int(P_am,x,[7*s 8*s]);
end
Ga1=sum(P_am_int1);
Ga2=sum(P_am_int2);
Ga3=sum(P_am_int3);
Ga4=sum(P_am_int4);
Ga5=sum(P_am_int5);
Ga6=sum(P_am_int6);
Ga7=sum(P_am_int7);
Ga8=sum(P_am_int8);
Ga=[Ga1 Ga2 Ga3 Ga4 Ga5 Ga6 Ga7 Ga8];
Ta=1-((Ga(7:-1:1)).^2);
%%% SFG
section_num=8;
gamma_app8=Ga(section_num);
for m=1:1:section_num-1
gamma_app8=gamma_app8*((Ta(section_num-m)))/(1+abs((gamma_app8*Ga(section_num-m))));
gamma_app8=gamma_app8+Ga(section_num-m);
end
fplot(w,abs(gamma_app8),[0 w3],’-‘,’LineWidth’,3)Hi everyone,I have a big trouble on plotting my results,it took a long time to complete the figure.Is there any method to increase plotting speed?
Thanks for your help!!!
clear
L=0.1;
a=L/2;
v=3e8;
f1=1.2e9;
f2=4.8e9;
f3=10e9;
w1=(2*pi*f1);
w2=(2*pi*f2);
w3=(2*pi*f3);
Z01=50;
Z02=50;
a0=(log(Z02/Z01))./(2.*L);
T=2*a;
k=1;
syms x y w
Am=-5;
%%% Eight section SFG
% Calculate gamma
s=L/8;
for n=1:1:k
V=Am(n);
P_am=((V*cos(n*pi*x/T)))*(exp(-2*1i*(w/v)*x));
P_am_int1(n)=int(P_am,x,[0 s]);
P_am_int2(n)=int(P_am,x,[s 2*s]);
P_am_int3(n)=int(P_am,x,[2*s 3*s]);
P_am_int4(n)=int(P_am,x,[3*s 4*s]);
P_am_int5(n)=int(P_am,x,[4*s 5*s]);
P_am_int6(n)=int(P_am,x,[5*s 6*s]);
P_am_int7(n)=int(P_am,x,[6*s 7*s]);
P_am_int8(n)=int(P_am,x,[7*s 8*s]);
end
Ga1=sum(P_am_int1);
Ga2=sum(P_am_int2);
Ga3=sum(P_am_int3);
Ga4=sum(P_am_int4);
Ga5=sum(P_am_int5);
Ga6=sum(P_am_int6);
Ga7=sum(P_am_int7);
Ga8=sum(P_am_int8);
Ga=[Ga1 Ga2 Ga3 Ga4 Ga5 Ga6 Ga7 Ga8];
Ta=1-((Ga(7:-1:1)).^2);
%%% SFG
section_num=8;
gamma_app8=Ga(section_num);
for m=1:1:section_num-1
gamma_app8=gamma_app8*((Ta(section_num-m)))/(1+abs((gamma_app8*Ga(section_num-m))));
gamma_app8=gamma_app8+Ga(section_num-m);
end
fplot(w,abs(gamma_app8),[0 w3],’-‘,’LineWidth’,3) Hi everyone,I have a big trouble on plotting my results,it took a long time to complete the figure.Is there any method to increase plotting speed?
Thanks for your help!!!
clear
L=0.1;
a=L/2;
v=3e8;
f1=1.2e9;
f2=4.8e9;
f3=10e9;
w1=(2*pi*f1);
w2=(2*pi*f2);
w3=(2*pi*f3);
Z01=50;
Z02=50;
a0=(log(Z02/Z01))./(2.*L);
T=2*a;
k=1;
syms x y w
Am=-5;
%%% Eight section SFG
% Calculate gamma
s=L/8;
for n=1:1:k
V=Am(n);
P_am=((V*cos(n*pi*x/T)))*(exp(-2*1i*(w/v)*x));
P_am_int1(n)=int(P_am,x,[0 s]);
P_am_int2(n)=int(P_am,x,[s 2*s]);
P_am_int3(n)=int(P_am,x,[2*s 3*s]);
P_am_int4(n)=int(P_am,x,[3*s 4*s]);
P_am_int5(n)=int(P_am,x,[4*s 5*s]);
P_am_int6(n)=int(P_am,x,[5*s 6*s]);
P_am_int7(n)=int(P_am,x,[6*s 7*s]);
P_am_int8(n)=int(P_am,x,[7*s 8*s]);
end
Ga1=sum(P_am_int1);
Ga2=sum(P_am_int2);
Ga3=sum(P_am_int3);
Ga4=sum(P_am_int4);
Ga5=sum(P_am_int5);
Ga6=sum(P_am_int6);
Ga7=sum(P_am_int7);
Ga8=sum(P_am_int8);
Ga=[Ga1 Ga2 Ga3 Ga4 Ga5 Ga6 Ga7 Ga8];
Ta=1-((Ga(7:-1:1)).^2);
%%% SFG
section_num=8;
gamma_app8=Ga(section_num);
for m=1:1:section_num-1
gamma_app8=gamma_app8*((Ta(section_num-m)))/(1+abs((gamma_app8*Ga(section_num-m))));
gamma_app8=gamma_app8+Ga(section_num-m);
end
fplot(w,abs(gamma_app8),[0 w3],’-‘,’LineWidth’,3) plotting MATLAB Answers — New Questions
FFT is suddenly slow down for repeated operations.
Hello. I am conducting a simulation with a 3-dimensional matrix using Matlab. While performing FFT about one dimension of the 3-dimensional matrix using GPU for repeated operations, I noticed that the computation speed suddenly slows down. Below is a brief summary of the problematic code.
matlab
clear all; close all; clc;
k = 501;
A = zeros(k,k,k,’gpuArray’);
B = zeros(k,k,k,’gpuArray’);
for n = 1:k
tic
B(:,:,:) = fftshift(fft(ifftshift(A,1),[],1),1);
disp(num2str([n, toc]))
end
The result of running the code is as follows:
Result
….
236 7.52e-05
237 7.03e-05
238 7.11e-05
239 7.34e-05
240 7.29e-05
241 7.02e-05
242 0.0235287
243 0.0472623
244 0.0312132
245 0.0444045
246 0.0305904
247 0.0463637
248 0.0309244
….
As the result, from the 242nd iteration, the FFT operation significantly slows down.
I am curious about the cause of this issue.
The GPU used is 4090.
I would appreciate it if you could let me know what the problem might be.Hello. I am conducting a simulation with a 3-dimensional matrix using Matlab. While performing FFT about one dimension of the 3-dimensional matrix using GPU for repeated operations, I noticed that the computation speed suddenly slows down. Below is a brief summary of the problematic code.
matlab
clear all; close all; clc;
k = 501;
A = zeros(k,k,k,’gpuArray’);
B = zeros(k,k,k,’gpuArray’);
for n = 1:k
tic
B(:,:,:) = fftshift(fft(ifftshift(A,1),[],1),1);
disp(num2str([n, toc]))
end
The result of running the code is as follows:
Result
….
236 7.52e-05
237 7.03e-05
238 7.11e-05
239 7.34e-05
240 7.29e-05
241 7.02e-05
242 0.0235287
243 0.0472623
244 0.0312132
245 0.0444045
246 0.0305904
247 0.0463637
248 0.0309244
….
As the result, from the 242nd iteration, the FFT operation significantly slows down.
I am curious about the cause of this issue.
The GPU used is 4090.
I would appreciate it if you could let me know what the problem might be. Hello. I am conducting a simulation with a 3-dimensional matrix using Matlab. While performing FFT about one dimension of the 3-dimensional matrix using GPU for repeated operations, I noticed that the computation speed suddenly slows down. Below is a brief summary of the problematic code.
matlab
clear all; close all; clc;
k = 501;
A = zeros(k,k,k,’gpuArray’);
B = zeros(k,k,k,’gpuArray’);
for n = 1:k
tic
B(:,:,:) = fftshift(fft(ifftshift(A,1),[],1),1);
disp(num2str([n, toc]))
end
The result of running the code is as follows:
Result
….
236 7.52e-05
237 7.03e-05
238 7.11e-05
239 7.34e-05
240 7.29e-05
241 7.02e-05
242 0.0235287
243 0.0472623
244 0.0312132
245 0.0444045
246 0.0305904
247 0.0463637
248 0.0309244
….
As the result, from the 242nd iteration, the FFT operation significantly slows down.
I am curious about the cause of this issue.
The GPU used is 4090.
I would appreciate it if you could let me know what the problem might be. fft, for loop, gpu MATLAB Answers — New Questions
Why do I get the Xilinx Vivado error message “Specified part could not be found” during IP Core Generation with HDL Workflow Advisor or SoC Builder?
I am trying to generate an IP Core using HDL Coder. However, in step 3.2 of HDL Workflow Advisor, I see:
Failed Task "Vivado IP Packager" unsuccessful. See log for details. Generated logfile:
hdl_prjhdlsrcDUTnameworkflow_task_VivadoIPPackager.log
Error in hdlturnkey.ip.IPEmitterVivado/packageVivadoIP
Error in hdlturnkey.ip.IPDriver/generateIPCore
And the content in the "workflow_task_VivadoIPPackager.log" file is:
Task "Vivado IP Packager" unsuccessful. See log for details.
Generated logfile:
****** Vivado v2020.1 (64-bit)
**** SW Build 2902540 on Wed May 27 19:54:49 MDT 2020
**** IP Build 2902112 on Wed May 27 22:43:36 MDT 2020
** Copyright 1986-2020 Xilinx, Inc. All Rights Reserved.
source vivado_ip_package.tcl -notrace
WARNING: [Device 21-436] No parts matched ‘xc7k325tffg900-2’
ERROR: [Coretcl 2-106] Specified part could not be found.
INFO: [Common 17-206] Exiting Vivado at Mon May 30 15:13:18 2022…
Elapsed time is 5.1019 seconds.
A log file with the same name containing the same error message may be created when using SoC Blockset and SoC Builder.I am trying to generate an IP Core using HDL Coder. However, in step 3.2 of HDL Workflow Advisor, I see:
Failed Task "Vivado IP Packager" unsuccessful. See log for details. Generated logfile:
hdl_prjhdlsrcDUTnameworkflow_task_VivadoIPPackager.log
Error in hdlturnkey.ip.IPEmitterVivado/packageVivadoIP
Error in hdlturnkey.ip.IPDriver/generateIPCore
And the content in the "workflow_task_VivadoIPPackager.log" file is:
Task "Vivado IP Packager" unsuccessful. See log for details.
Generated logfile:
****** Vivado v2020.1 (64-bit)
**** SW Build 2902540 on Wed May 27 19:54:49 MDT 2020
**** IP Build 2902112 on Wed May 27 22:43:36 MDT 2020
** Copyright 1986-2020 Xilinx, Inc. All Rights Reserved.
source vivado_ip_package.tcl -notrace
WARNING: [Device 21-436] No parts matched ‘xc7k325tffg900-2’
ERROR: [Coretcl 2-106] Specified part could not be found.
INFO: [Common 17-206] Exiting Vivado at Mon May 30 15:13:18 2022…
Elapsed time is 5.1019 seconds.
A log file with the same name containing the same error message may be created when using SoC Blockset and SoC Builder. I am trying to generate an IP Core using HDL Coder. However, in step 3.2 of HDL Workflow Advisor, I see:
Failed Task "Vivado IP Packager" unsuccessful. See log for details. Generated logfile:
hdl_prjhdlsrcDUTnameworkflow_task_VivadoIPPackager.log
Error in hdlturnkey.ip.IPEmitterVivado/packageVivadoIP
Error in hdlturnkey.ip.IPDriver/generateIPCore
And the content in the "workflow_task_VivadoIPPackager.log" file is:
Task "Vivado IP Packager" unsuccessful. See log for details.
Generated logfile:
****** Vivado v2020.1 (64-bit)
**** SW Build 2902540 on Wed May 27 19:54:49 MDT 2020
**** IP Build 2902112 on Wed May 27 22:43:36 MDT 2020
** Copyright 1986-2020 Xilinx, Inc. All Rights Reserved.
source vivado_ip_package.tcl -notrace
WARNING: [Device 21-436] No parts matched ‘xc7k325tffg900-2’
ERROR: [Coretcl 2-106] Specified part could not be found.
INFO: [Common 17-206] Exiting Vivado at Mon May 30 15:13:18 2022…
Elapsed time is 5.1019 seconds.
A log file with the same name containing the same error message may be created when using SoC Blockset and SoC Builder. MATLAB Answers — New Questions
Why do I get the error message “Run ‘impl_1’ has not been launched. Unable to open” when using HDL Coder, HDL Verifier or SoC Blockset?
When I try to run "HDL Workflow Advisor", "SoC Builder", or the "Verify Setup" test during the "HDL Verifier Support Package for Xilinx FPGA boards" hardware setup, the programming file generation fails for my Xilinx board. The following error is shown in MATLAB, or in the Vivado build log (vivado_build_prj.log):
ERROR: [Common 17-69] Command failed: Run ‘impl_1’ has not been launched. Unable to openWhen I try to run "HDL Workflow Advisor", "SoC Builder", or the "Verify Setup" test during the "HDL Verifier Support Package for Xilinx FPGA boards" hardware setup, the programming file generation fails for my Xilinx board. The following error is shown in MATLAB, or in the Vivado build log (vivado_build_prj.log):
ERROR: [Common 17-69] Command failed: Run ‘impl_1’ has not been launched. Unable to open When I try to run "HDL Workflow Advisor", "SoC Builder", or the "Verify Setup" test during the "HDL Verifier Support Package for Xilinx FPGA boards" hardware setup, the programming file generation fails for my Xilinx board. The following error is shown in MATLAB, or in the Vivado build log (vivado_build_prj.log):
ERROR: [Common 17-69] Command failed: Run ‘impl_1’ has not been launched. Unable to open vivado, webpack, programming, files, generation, failed , ml MATLAB Answers — New Questions
Do the “ADC/DAC Interface” reference designs support Vivado 2022.1 or later?
I am trying to follow the HDL Coder demo "DAC and ADC Loopback Data Capture" for my ZCU111 board using MATLAB R2023a (or later) and Xilinx Vivado 2022.1 (or later):
https://www.mathworks.com/help/hdlcoder/ug/hdl-dac-adc-loopback-data-capture.html
The demo uses the "Real ADC/DAC Interface" reference design, as specified in step 1.2 in the HDL Workflow Advisor.
However, I encounter errors similar to the following at step 4.1 in the HDL Workflow Advisor:
The following IPs are not found in the IP Catalog:
xilinx.com:ip:usp_rf_data_converter:2.4
ERROR: [BD 5-216] VLNV <xilinx.com:ip:usp_rf_data_converter:2.4> is not supported for the current part.
The latest supported version for this part is: <2.5>
Based on the following MATLAB Answers post:
https://www.mathworks.com/matlabcentral/answers/518421-which-versions-of-xilinx-vivado-are-supported-with-which-release-of-hdl-coder
MATLAB R2023a (or later) should support Vivado 2022.1 (or later). Why does the example not work?I am trying to follow the HDL Coder demo "DAC and ADC Loopback Data Capture" for my ZCU111 board using MATLAB R2023a (or later) and Xilinx Vivado 2022.1 (or later):
https://www.mathworks.com/help/hdlcoder/ug/hdl-dac-adc-loopback-data-capture.html
The demo uses the "Real ADC/DAC Interface" reference design, as specified in step 1.2 in the HDL Workflow Advisor.
However, I encounter errors similar to the following at step 4.1 in the HDL Workflow Advisor:
The following IPs are not found in the IP Catalog:
xilinx.com:ip:usp_rf_data_converter:2.4
ERROR: [BD 5-216] VLNV <xilinx.com:ip:usp_rf_data_converter:2.4> is not supported for the current part.
The latest supported version for this part is: <2.5>
Based on the following MATLAB Answers post:
https://www.mathworks.com/matlabcentral/answers/518421-which-versions-of-xilinx-vivado-are-supported-with-which-release-of-hdl-coder
MATLAB R2023a (or later) should support Vivado 2022.1 (or later). Why does the example not work? I am trying to follow the HDL Coder demo "DAC and ADC Loopback Data Capture" for my ZCU111 board using MATLAB R2023a (or later) and Xilinx Vivado 2022.1 (or later):
https://www.mathworks.com/help/hdlcoder/ug/hdl-dac-adc-loopback-data-capture.html
The demo uses the "Real ADC/DAC Interface" reference design, as specified in step 1.2 in the HDL Workflow Advisor.
However, I encounter errors similar to the following at step 4.1 in the HDL Workflow Advisor:
The following IPs are not found in the IP Catalog:
xilinx.com:ip:usp_rf_data_converter:2.4
ERROR: [BD 5-216] VLNV <xilinx.com:ip:usp_rf_data_converter:2.4> is not supported for the current part.
The latest supported version for this part is: <2.5>
Based on the following MATLAB Answers post:
https://www.mathworks.com/matlabcentral/answers/518421-which-versions-of-xilinx-vivado-are-supported-with-which-release-of-hdl-coder
MATLAB R2023a (or later) should support Vivado 2022.1 (or later). Why does the example not work? vivado, dac, adc, ip, core MATLAB Answers — New Questions