Category: Matlab
Category Archives: Matlab
Why do I receive Error 5201 – Unable to access services required to run MATLAB?
When I try launch to MATLAB, I get the following error:
Unable to access services required to run MATLAB (error 5201). How do I resolve this?When I try launch to MATLAB, I get the following error:
Unable to access services required to run MATLAB (error 5201). How do I resolve this? When I try launch to MATLAB, I get the following error:
Unable to access services required to run MATLAB (error 5201). How do I resolve this? MATLAB Answers — New Questions
How to access files on Matlab Drive from Thingspeak Analysis App
Is it possible to access files on my Matlab Drive from matlab code in ThingSpeak Analysis App?
I know we can do this on Matlab Online but it seems the same code does not work on ThingSpeak analysis App.
ThanksIs it possible to access files on my Matlab Drive from matlab code in ThingSpeak Analysis App?
I know we can do this on Matlab Online but it seems the same code does not work on ThingSpeak analysis App.
Thanks Is it possible to access files on my Matlab Drive from matlab code in ThingSpeak Analysis App?
I know we can do this on Matlab Online but it seems the same code does not work on ThingSpeak analysis App.
Thanks thingspeak, matlab drive, analysis app MATLAB Answers — New Questions
undo a command in matlab plotting in 2d
I have a plot in 2d with 3 waves in it now i want to remove one the wave from the plot , how can i do it without restarting from the startI have a plot in 2d with 3 waves in it now i want to remove one the wave from the plot , how can i do it without restarting from the start I have a plot in 2d with 3 waves in it now i want to remove one the wave from the plot , how can i do it without restarting from the start #plot, #2d_plotting MATLAB Answers — New Questions
Is there a way to remove the vertical line from Matlab editor window?
I want to remove the vertical line in the Matlab editor window. Please help me someone.I want to remove the vertical line in the Matlab editor window. Please help me someone. I want to remove the vertical line in the Matlab editor window. Please help me someone. matlab, editor MATLAB Answers — New Questions
How to install fuzzy logic toolbox into matlab
How to install fuzzy logic toolbox into matlab 2017How to install fuzzy logic toolbox into matlab 2017 How to install fuzzy logic toolbox into matlab 2017 matlab, toolbox, fuzzy logic MATLAB Answers — New Questions
how can i have step input signal in signal editor?
I have 3 signals for a SCARA robot. I want to input a step input for these 3 signals in the Signal Editor. How should I enter the time and data inputs in the Signal Editor?
x=[1.412,0.8696,1.412,1.412,1.821,1.545,1.8312.382,1.412]
y=[-3.142,-2.088,-3.142.-3.142,-3.142,-2.31,-3.142,-3.142,-3.142]
z=[-0.086,-0.086,-0.086,-0.186,-0.186,-0.186,-0.186,-0.386,-0.086]
t=[0,1,1.5,2,3,4,4.5,5,6]I have 3 signals for a SCARA robot. I want to input a step input for these 3 signals in the Signal Editor. How should I enter the time and data inputs in the Signal Editor?
x=[1.412,0.8696,1.412,1.412,1.821,1.545,1.8312.382,1.412]
y=[-3.142,-2.088,-3.142.-3.142,-3.142,-2.31,-3.142,-3.142,-3.142]
z=[-0.086,-0.086,-0.086,-0.186,-0.186,-0.186,-0.186,-0.386,-0.086]
t=[0,1,1.5,2,3,4,4.5,5,6] I have 3 signals for a SCARA robot. I want to input a step input for these 3 signals in the Signal Editor. How should I enter the time and data inputs in the Signal Editor?
x=[1.412,0.8696,1.412,1.412,1.821,1.545,1.8312.382,1.412]
y=[-3.142,-2.088,-3.142.-3.142,-3.142,-2.31,-3.142,-3.142,-3.142]
z=[-0.086,-0.086,-0.086,-0.186,-0.186,-0.186,-0.186,-0.386,-0.086]
t=[0,1,1.5,2,3,4,4.5,5,6] step input signal MATLAB Answers — New Questions
Unable to create a exponential graph
I am trying to make a basic tyre degredation model and I am not able to get an increasing exponential graph. I have four input block representing vital variables reagrding tyre degredation. The current model is down below. The code inside the MATLAB function block is
function y = exp_temp(u)
2 % Exponential function for temperature degradation
3 a = 0.1; % adjust this value to fit the data
4 b = 0.02; % adjust this value to fit the data
5 y = a * exp(b * u);
6 end
The graph should look like something In the second picture. What am I doing wrong.I am trying to make a basic tyre degredation model and I am not able to get an increasing exponential graph. I have four input block representing vital variables reagrding tyre degredation. The current model is down below. The code inside the MATLAB function block is
function y = exp_temp(u)
2 % Exponential function for temperature degradation
3 a = 0.1; % adjust this value to fit the data
4 b = 0.02; % adjust this value to fit the data
5 y = a * exp(b * u);
6 end
The graph should look like something In the second picture. What am I doing wrong. I am trying to make a basic tyre degredation model and I am not able to get an increasing exponential graph. I have four input block representing vital variables reagrding tyre degredation. The current model is down below. The code inside the MATLAB function block is
function y = exp_temp(u)
2 % Exponential function for temperature degradation
3 a = 0.1; % adjust this value to fit the data
4 b = 0.02; % adjust this value to fit the data
5 y = a * exp(b * u);
6 end
The graph should look like something In the second picture. What am I doing wrong. matlab, simulink MATLAB Answers — New Questions
Portfolio Optimisation using a mean/ mean absolute deviation model (linear program)
Hey everybody,
I am new to Matlab. I have recently used quadprog for the standard mean-variance model to optimise a portfolio.
I want to try several models and am currently trying to model the linear program -> mean / mean absolute deviation.
Mathematically speaking :
[URL=http://www.pic-upload.de/view-20298258/Screen-Shot-2013-08-05-at-01.05.47.png.html][IMG]http://www10.pic-upload.de/thumb/05.08.13/3hz1okoiiv24.png[/IMG][/URL]
in case that didn’t work :
http://www.pic-upload.de/view-20298258/Screen-Shot-2013-08-05-at-01.05.47.png.html
S = 872 observations I have for 9 stocks.
delta is the target return.
% This script will calculate and plot the efficient frontier for a
% mean – mean absolute deviation model in the Konno context.
% Take sample ‘Sample’ and calculate the mad -> transpose PeriodMAD
% and store variable in the workspace
PeriodMAD = mad(Sample);
PeriodMAD = PeriodMAD’;
assignin(‘base’,’PeriodMAD’,PeriodMAD);
% get number of Assets ( i am using 9 stocks)
nAssets = numel(PeriodMAD);
% Set the first targetreturn
targetreturn = 0.000001;
% Not sure if that is right -> allow none of the MAD values to lower than
% 0
nonnegativityMAD = zeros(nAssets, 1);
% Conformity with the linproq notation
f = PeriodMAD;
% Set some restrictions -> as shown in the graphic I have provided. NOt
% sure if I set them up correctly to be honest.
% PeriodDeviations includes nothing more than Observation at time(i) –
% mean of the asset (PeriodDeviations -> (9,1) vector)
% PeriodReturns -> ln returns for the observations 782 -> vector (9,1)
Aeq = [ PeriodDeviations
-PeriodDeviations
-PeriodMAD
-PeriodReturns ];
Beq = [ PeriodMAD
-PeriodMAD
nonnegativityMAD
-targetreturn];
% Set lower and upper boundaries for the weights -> 0<= x <= 1
lb = zeros(nAssets,1);
ub = ones(nAssets, 1);
% Copied that line from the quadprog example given on the internet
% changed interior-point-convex to interior-point
options = optimset(‘Algorithm’,’interior-point’);
options = optimset(options,’Display’,’iter’,’TolFun’,1e-10);
for i=1:100000;
x = linprog ( f,[],[],Aeq,Beq,lb,ub,[], options );
% Not sure if that is correct. Store respective mean in Output(1,i)
% do the same for the portfolio MAD -> is that correct?
% This is a modified "Sharpe- Ratio" or Konno Ratio. the quotient of
% the former two variables
% Finally store the weights x in Output as well -> 9 variables
% therefore Output(5,i) to Output(13,i)
Output(1,i) = x’ * PeriodReturns;
Output(2,i) = x’ * PeriodMAD;
Output(3,i) = (Output(1,i)/Output(2,i));
Output(5,i) = x(1,1);
Output(6,i) = x(2,1);
Output(7,i) = x(3,1);
Output(8,i) = x(4,1);
Output(9,i) = x(5,1);
Output(10,i) = x(6,1);
Output(11,i) = x(7,1);
Output(12,i) = x(8,1);
Output(13,i) = x(9,1);
% now increment targetreturn -> repeat the entire process as long as
% linprog finds a solutions (converges to a solution) otherwise
% stop/break
targetreturn = targetreturn + 0.000001;
if(exitflag == 1)
continue
else
break
end
end
% Find highest KonnoRatio – Quotient of Returns/Risk stored as
% maxKonnoRatio then find position in Output
maxKonnoRatio = max(Output(3,:));
[row col] = find(maxKonnoRatio == Output(3,:));
% finally create and display an array that contains all the information
% for the optimal allocation.
OptimalAll = [ Output(1,col)
Output(2,col)
Output(3,col)
0
Output(5,col)
Output(6,col)
Output(7,col)
Output(8,col)
Output(9,col) ]
% and hopefully draw the efficient frontier
plot(Output(2,i),Output(1,i))
I am stuck. I have modified so much stuff already and I keep getting error messages. currently this is the most recent one :
EDU>> MAD
Error using linprog (line 231)
The number of rows in Aeq must be the same as the number of elements of beq.
Error in MAD (line 37)
x = linprog ( f,[],[],Aeq,Beq,lb,ub,[], options );
EDU>> MAD
Error: File: MAD.m Line: 108 Column: 32
Unbalanced or unexpected parenthesis or bracket.
EDU>>
if you could please help me.
Am I at least close to a proper solution ?
Btw. : I will annualise those daily data observations – as soon as I can solve the basic problem.
I would be very grateful for some advice and/or help.
Thank you so much!
DanielHey everybody,
I am new to Matlab. I have recently used quadprog for the standard mean-variance model to optimise a portfolio.
I want to try several models and am currently trying to model the linear program -> mean / mean absolute deviation.
Mathematically speaking :
[URL=http://www.pic-upload.de/view-20298258/Screen-Shot-2013-08-05-at-01.05.47.png.html][IMG]http://www10.pic-upload.de/thumb/05.08.13/3hz1okoiiv24.png[/IMG][/URL]
in case that didn’t work :
http://www.pic-upload.de/view-20298258/Screen-Shot-2013-08-05-at-01.05.47.png.html
S = 872 observations I have for 9 stocks.
delta is the target return.
% This script will calculate and plot the efficient frontier for a
% mean – mean absolute deviation model in the Konno context.
% Take sample ‘Sample’ and calculate the mad -> transpose PeriodMAD
% and store variable in the workspace
PeriodMAD = mad(Sample);
PeriodMAD = PeriodMAD’;
assignin(‘base’,’PeriodMAD’,PeriodMAD);
% get number of Assets ( i am using 9 stocks)
nAssets = numel(PeriodMAD);
% Set the first targetreturn
targetreturn = 0.000001;
% Not sure if that is right -> allow none of the MAD values to lower than
% 0
nonnegativityMAD = zeros(nAssets, 1);
% Conformity with the linproq notation
f = PeriodMAD;
% Set some restrictions -> as shown in the graphic I have provided. NOt
% sure if I set them up correctly to be honest.
% PeriodDeviations includes nothing more than Observation at time(i) –
% mean of the asset (PeriodDeviations -> (9,1) vector)
% PeriodReturns -> ln returns for the observations 782 -> vector (9,1)
Aeq = [ PeriodDeviations
-PeriodDeviations
-PeriodMAD
-PeriodReturns ];
Beq = [ PeriodMAD
-PeriodMAD
nonnegativityMAD
-targetreturn];
% Set lower and upper boundaries for the weights -> 0<= x <= 1
lb = zeros(nAssets,1);
ub = ones(nAssets, 1);
% Copied that line from the quadprog example given on the internet
% changed interior-point-convex to interior-point
options = optimset(‘Algorithm’,’interior-point’);
options = optimset(options,’Display’,’iter’,’TolFun’,1e-10);
for i=1:100000;
x = linprog ( f,[],[],Aeq,Beq,lb,ub,[], options );
% Not sure if that is correct. Store respective mean in Output(1,i)
% do the same for the portfolio MAD -> is that correct?
% This is a modified "Sharpe- Ratio" or Konno Ratio. the quotient of
% the former two variables
% Finally store the weights x in Output as well -> 9 variables
% therefore Output(5,i) to Output(13,i)
Output(1,i) = x’ * PeriodReturns;
Output(2,i) = x’ * PeriodMAD;
Output(3,i) = (Output(1,i)/Output(2,i));
Output(5,i) = x(1,1);
Output(6,i) = x(2,1);
Output(7,i) = x(3,1);
Output(8,i) = x(4,1);
Output(9,i) = x(5,1);
Output(10,i) = x(6,1);
Output(11,i) = x(7,1);
Output(12,i) = x(8,1);
Output(13,i) = x(9,1);
% now increment targetreturn -> repeat the entire process as long as
% linprog finds a solutions (converges to a solution) otherwise
% stop/break
targetreturn = targetreturn + 0.000001;
if(exitflag == 1)
continue
else
break
end
end
% Find highest KonnoRatio – Quotient of Returns/Risk stored as
% maxKonnoRatio then find position in Output
maxKonnoRatio = max(Output(3,:));
[row col] = find(maxKonnoRatio == Output(3,:));
% finally create and display an array that contains all the information
% for the optimal allocation.
OptimalAll = [ Output(1,col)
Output(2,col)
Output(3,col)
0
Output(5,col)
Output(6,col)
Output(7,col)
Output(8,col)
Output(9,col) ]
% and hopefully draw the efficient frontier
plot(Output(2,i),Output(1,i))
I am stuck. I have modified so much stuff already and I keep getting error messages. currently this is the most recent one :
EDU>> MAD
Error using linprog (line 231)
The number of rows in Aeq must be the same as the number of elements of beq.
Error in MAD (line 37)
x = linprog ( f,[],[],Aeq,Beq,lb,ub,[], options );
EDU>> MAD
Error: File: MAD.m Line: 108 Column: 32
Unbalanced or unexpected parenthesis or bracket.
EDU>>
if you could please help me.
Am I at least close to a proper solution ?
Btw. : I will annualise those daily data observations – as soon as I can solve the basic problem.
I would be very grateful for some advice and/or help.
Thank you so much!
Daniel Hey everybody,
I am new to Matlab. I have recently used quadprog for the standard mean-variance model to optimise a portfolio.
I want to try several models and am currently trying to model the linear program -> mean / mean absolute deviation.
Mathematically speaking :
[URL=http://www.pic-upload.de/view-20298258/Screen-Shot-2013-08-05-at-01.05.47.png.html][IMG]http://www10.pic-upload.de/thumb/05.08.13/3hz1okoiiv24.png[/IMG][/URL]
in case that didn’t work :
http://www.pic-upload.de/view-20298258/Screen-Shot-2013-08-05-at-01.05.47.png.html
S = 872 observations I have for 9 stocks.
delta is the target return.
% This script will calculate and plot the efficient frontier for a
% mean – mean absolute deviation model in the Konno context.
% Take sample ‘Sample’ and calculate the mad -> transpose PeriodMAD
% and store variable in the workspace
PeriodMAD = mad(Sample);
PeriodMAD = PeriodMAD’;
assignin(‘base’,’PeriodMAD’,PeriodMAD);
% get number of Assets ( i am using 9 stocks)
nAssets = numel(PeriodMAD);
% Set the first targetreturn
targetreturn = 0.000001;
% Not sure if that is right -> allow none of the MAD values to lower than
% 0
nonnegativityMAD = zeros(nAssets, 1);
% Conformity with the linproq notation
f = PeriodMAD;
% Set some restrictions -> as shown in the graphic I have provided. NOt
% sure if I set them up correctly to be honest.
% PeriodDeviations includes nothing more than Observation at time(i) –
% mean of the asset (PeriodDeviations -> (9,1) vector)
% PeriodReturns -> ln returns for the observations 782 -> vector (9,1)
Aeq = [ PeriodDeviations
-PeriodDeviations
-PeriodMAD
-PeriodReturns ];
Beq = [ PeriodMAD
-PeriodMAD
nonnegativityMAD
-targetreturn];
% Set lower and upper boundaries for the weights -> 0<= x <= 1
lb = zeros(nAssets,1);
ub = ones(nAssets, 1);
% Copied that line from the quadprog example given on the internet
% changed interior-point-convex to interior-point
options = optimset(‘Algorithm’,’interior-point’);
options = optimset(options,’Display’,’iter’,’TolFun’,1e-10);
for i=1:100000;
x = linprog ( f,[],[],Aeq,Beq,lb,ub,[], options );
% Not sure if that is correct. Store respective mean in Output(1,i)
% do the same for the portfolio MAD -> is that correct?
% This is a modified "Sharpe- Ratio" or Konno Ratio. the quotient of
% the former two variables
% Finally store the weights x in Output as well -> 9 variables
% therefore Output(5,i) to Output(13,i)
Output(1,i) = x’ * PeriodReturns;
Output(2,i) = x’ * PeriodMAD;
Output(3,i) = (Output(1,i)/Output(2,i));
Output(5,i) = x(1,1);
Output(6,i) = x(2,1);
Output(7,i) = x(3,1);
Output(8,i) = x(4,1);
Output(9,i) = x(5,1);
Output(10,i) = x(6,1);
Output(11,i) = x(7,1);
Output(12,i) = x(8,1);
Output(13,i) = x(9,1);
% now increment targetreturn -> repeat the entire process as long as
% linprog finds a solutions (converges to a solution) otherwise
% stop/break
targetreturn = targetreturn + 0.000001;
if(exitflag == 1)
continue
else
break
end
end
% Find highest KonnoRatio – Quotient of Returns/Risk stored as
% maxKonnoRatio then find position in Output
maxKonnoRatio = max(Output(3,:));
[row col] = find(maxKonnoRatio == Output(3,:));
% finally create and display an array that contains all the information
% for the optimal allocation.
OptimalAll = [ Output(1,col)
Output(2,col)
Output(3,col)
0
Output(5,col)
Output(6,col)
Output(7,col)
Output(8,col)
Output(9,col) ]
% and hopefully draw the efficient frontier
plot(Output(2,i),Output(1,i))
I am stuck. I have modified so much stuff already and I keep getting error messages. currently this is the most recent one :
EDU>> MAD
Error using linprog (line 231)
The number of rows in Aeq must be the same as the number of elements of beq.
Error in MAD (line 37)
x = linprog ( f,[],[],Aeq,Beq,lb,ub,[], options );
EDU>> MAD
Error: File: MAD.m Line: 108 Column: 32
Unbalanced or unexpected parenthesis or bracket.
EDU>>
if you could please help me.
Am I at least close to a proper solution ?
Btw. : I will annualise those daily data observations – as soon as I can solve the basic problem.
I would be very grateful for some advice and/or help.
Thank you so much!
Daniel optimisation, portfolio, mad, linear, finance MATLAB Answers — New Questions
Why do i get a “Pin d10 reserved by servo” error when I run “writeDigitalPin” with my Arduino Uno?
I have an Arduino Uno connected to a servo motor and DC motors. If I create objects for the servo and for the DC motors, and then call "writeDigitalPin" to pin d10 where the DC motor is connected, the states of all of the pins are set to 0 and I get the following error:
"Uno pin d10 is reserved by servo. To release the resource, clear all variables holding onto this resource"
How can I fix this error?I have an Arduino Uno connected to a servo motor and DC motors. If I create objects for the servo and for the DC motors, and then call "writeDigitalPin" to pin d10 where the DC motor is connected, the states of all of the pins are set to 0 and I get the following error:
"Uno pin d10 is reserved by servo. To release the resource, clear all variables holding onto this resource"
How can I fix this error? I have an Arduino Uno connected to a servo motor and DC motors. If I create objects for the servo and for the DC motors, and then call "writeDigitalPin" to pin d10 where the DC motor is connected, the states of all of the pins are set to 0 and I get the following error:
"Uno pin d10 is reserved by servo. To release the resource, clear all variables holding onto this resource"
How can I fix this error? arduino, servo, writedigitalpin MATLAB Answers — New Questions
Simulation of nonlinear simulation oscillating to infinity
I am simulating a wind turbine with a flexible drivetrain in simulink. I am using a two mass model to model the oscillations on the drivetrain.
Whenever I run a simulation with a smooth change in the power output of the turbine it ends up oscillating and the simulation quits with the error message:
"Solver encountered an error while simulating model ‘WecsNoConverter’ at time 47.9683593447728 and cannot continue. Please check the model for errors.
Nonlinear iteration is not converging with step size reduced to hmin (1.70418E-13) at time 47.9684. Try reducing the minimum step size and/or relax the relative error tolerance."
I am using ode15s as the solver. I have tried relaxing the relative error tolerance but it appears to make no difference. Enabling shape preservation makes no difference. Decreasing the max order increases the lenght of time before the system oscillates to infinity. The results above are with a max order of 1. Any max order of 2-4 makes results in the above behaviour happening sooner. I have tried other solvers but ode15s gives me the best results
One thing which fixes the simulation is to increase the damping term on the two mass model. Which results in the smooth output as shown below. However, this means the model is not accurate to the original turbine, so this is not an option.
Are there any other options I can try to get the simulation to run the full length of time?I am simulating a wind turbine with a flexible drivetrain in simulink. I am using a two mass model to model the oscillations on the drivetrain.
Whenever I run a simulation with a smooth change in the power output of the turbine it ends up oscillating and the simulation quits with the error message:
"Solver encountered an error while simulating model ‘WecsNoConverter’ at time 47.9683593447728 and cannot continue. Please check the model for errors.
Nonlinear iteration is not converging with step size reduced to hmin (1.70418E-13) at time 47.9684. Try reducing the minimum step size and/or relax the relative error tolerance."
I am using ode15s as the solver. I have tried relaxing the relative error tolerance but it appears to make no difference. Enabling shape preservation makes no difference. Decreasing the max order increases the lenght of time before the system oscillates to infinity. The results above are with a max order of 1. Any max order of 2-4 makes results in the above behaviour happening sooner. I have tried other solvers but ode15s gives me the best results
One thing which fixes the simulation is to increase the damping term on the two mass model. Which results in the smooth output as shown below. However, this means the model is not accurate to the original turbine, so this is not an option.
Are there any other options I can try to get the simulation to run the full length of time? I am simulating a wind turbine with a flexible drivetrain in simulink. I am using a two mass model to model the oscillations on the drivetrain.
Whenever I run a simulation with a smooth change in the power output of the turbine it ends up oscillating and the simulation quits with the error message:
"Solver encountered an error while simulating model ‘WecsNoConverter’ at time 47.9683593447728 and cannot continue. Please check the model for errors.
Nonlinear iteration is not converging with step size reduced to hmin (1.70418E-13) at time 47.9684. Try reducing the minimum step size and/or relax the relative error tolerance."
I am using ode15s as the solver. I have tried relaxing the relative error tolerance but it appears to make no difference. Enabling shape preservation makes no difference. Decreasing the max order increases the lenght of time before the system oscillates to infinity. The results above are with a max order of 1. Any max order of 2-4 makes results in the above behaviour happening sooner. I have tried other solvers but ode15s gives me the best results
One thing which fixes the simulation is to increase the damping term on the two mass model. Which results in the smooth output as shown below. However, this means the model is not accurate to the original turbine, so this is not an option.
Are there any other options I can try to get the simulation to run the full length of time? nonlinear, simulink, simulation, unstable, oscillation, ode, ode15s, instability MATLAB Answers — New Questions
I’m trying to solve a 2nd order ode with ode45, but have no idea where to start.
This the ode with conditions I’m trying to solve and the code below is as far as I got. It would be appreciated if I could get a detailed step by step to help solve this.
%initial conditions
y0 = [0 1];
tspan = [1 4];This the ode with conditions I’m trying to solve and the code below is as far as I got. It would be appreciated if I could get a detailed step by step to help solve this.
%initial conditions
y0 = [0 1];
tspan = [1 4]; This the ode with conditions I’m trying to solve and the code below is as far as I got. It would be appreciated if I could get a detailed step by step to help solve this.
%initial conditions
y0 = [0 1];
tspan = [1 4]; ode45, ode MATLAB Answers — New Questions
Hodrick-Prescott filter with smoothing factor as parameter
Hi i’m trying to parametrize Hodrick-Prescott filter (HP) as a function of smoothing parameter. Simple xy plot with the smoothing factor as parameter. I post my code below
excel=readmatrix("COMEX_SIZ2024, 1D_1f4e1.csv");
price=excel(:,6);
lambda=500:500:5500;
>> for pp=1:length(lambda)
[Trend(length(price),pp),Cyclical(length(price),pp)]=hpfilter(price,Smoothing=lambda(pp));
end
ERROR: Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
I’m using a for loop to impile the lambda on columns and calculation (x=price) on rows. However it doesnt seem to work.
Where is my error? ThanksHi i’m trying to parametrize Hodrick-Prescott filter (HP) as a function of smoothing parameter. Simple xy plot with the smoothing factor as parameter. I post my code below
excel=readmatrix("COMEX_SIZ2024, 1D_1f4e1.csv");
price=excel(:,6);
lambda=500:500:5500;
>> for pp=1:length(lambda)
[Trend(length(price),pp),Cyclical(length(price),pp)]=hpfilter(price,Smoothing=lambda(pp));
end
ERROR: Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
I’m using a for loop to impile the lambda on columns and calculation (x=price) on rows. However it doesnt seem to work.
Where is my error? Thanks Hi i’m trying to parametrize Hodrick-Prescott filter (HP) as a function of smoothing parameter. Simple xy plot with the smoothing factor as parameter. I post my code below
excel=readmatrix("COMEX_SIZ2024, 1D_1f4e1.csv");
price=excel(:,6);
lambda=500:500:5500;
>> for pp=1:length(lambda)
[Trend(length(price),pp),Cyclical(length(price),pp)]=hpfilter(price,Smoothing=lambda(pp));
end
ERROR: Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
I’m using a for loop to impile the lambda on columns and calculation (x=price) on rows. However it doesnt seem to work.
Where is my error? Thanks hp filter, parameter, for loop, cycle MATLAB Answers — New Questions
Function file does not work
If I save a function in a file it is not work even I save the function file in the same folder of the code
the error is
‘Undefined function ‘Crouts1A’ for input arguments of type ‘double’.’
but if I write the function in the last code it is work.. how can I fix it.
My version Matlab is R2024aIf I save a function in a file it is not work even I save the function file in the same folder of the code
the error is
‘Undefined function ‘Crouts1A’ for input arguments of type ‘double’.’
but if I write the function in the last code it is work.. how can I fix it.
My version Matlab is R2024a If I save a function in a file it is not work even I save the function file in the same folder of the code
the error is
‘Undefined function ‘Crouts1A’ for input arguments of type ‘double’.’
but if I write the function in the last code it is work.. how can I fix it.
My version Matlab is R2024a function file MATLAB Answers — New Questions
Licensing error: -8,523.
I have just installed matlab. But i get an error. I researched cause of the error. I opened and checked the license file. I haven’t got HostID in license file.
My license file:
# BEGIN————–BEGIN————–BEGIN
# DO NOT EDIT THIS FILE. Any changes will be overwritten.
# MathWorks license passcode file.
#LicenseNo: my license numberI have just installed matlab. But i get an error. I researched cause of the error. I opened and checked the license file. I haven’t got HostID in license file.
My license file:
# BEGIN————–BEGIN————–BEGIN
# DO NOT EDIT THIS FILE. Any changes will be overwritten.
# MathWorks license passcode file.
#LicenseNo: my license number I have just installed matlab. But i get an error. I researched cause of the error. I opened and checked the license file. I haven’t got HostID in license file.
My license file:
# BEGIN————–BEGIN————–BEGIN
# DO NOT EDIT THIS FILE. Any changes will be overwritten.
# MathWorks license passcode file.
#LicenseNo: my license number error MATLAB Answers — New Questions
Accessing network drives from within Matlab
I have two Windows 10 computers running Matlab 2023b on the same network. On one computer, I am able to reach a remote network drive easily enough from the Matlab prompt,
>> cd ‘\drivepathname’
However, on the other computer, while I can access the network drive through Windows File Explorer, I cannot do so from within Matlab,
>> cd ‘\drivepathname’
Error using cd
Unable to change current folder to ‘\drivepathname’ (Folder access failure).
I am trying to guess what might be different about the 2 installations. Ay suggestions are welcome.I have two Windows 10 computers running Matlab 2023b on the same network. On one computer, I am able to reach a remote network drive easily enough from the Matlab prompt,
>> cd ‘\drivepathname’
However, on the other computer, while I can access the network drive through Windows File Explorer, I cannot do so from within Matlab,
>> cd ‘\drivepathname’
Error using cd
Unable to change current folder to ‘\drivepathname’ (Folder access failure).
I am trying to guess what might be different about the 2 installations. Ay suggestions are welcome. I have two Windows 10 computers running Matlab 2023b on the same network. On one computer, I am able to reach a remote network drive easily enough from the Matlab prompt,
>> cd ‘\drivepathname’
However, on the other computer, while I can access the network drive through Windows File Explorer, I cannot do so from within Matlab,
>> cd ‘\drivepathname’
Error using cd
Unable to change current folder to ‘\drivepathname’ (Folder access failure).
I am trying to guess what might be different about the 2 installations. Ay suggestions are welcome. cd, network drive, priviliges MATLAB Answers — New Questions
How to quantify shape similarity between two vectors.
I need to quanitfy how similarity between two spectral profile. I have looked at procrustes distance but it dosent work when spectrum is shifted on x axis. Is there a way to quanitfy this, ideally between 0 (no similairty) and 1 (perfect similarity) ?
x1 = 0:0.1:10;
Y1 = gaussmf(x1,[0.8 5 ]);
Y2 = gaussmf(x1,[0.8 3 ]);
Y3 = gaussmf(x1,[0.4 2 ]);
figure(1)
plot(x1,Y1, ‘k’,’Linewidth’,2)
hold on
plot(x1,Y2, ‘b’,’Linewidth’,2)
hold on
plot(x1,Y3, ‘r’,’Linewidth’,2)
legend(["A","B","C"])
figure(1)
In the toy example, A and B are very similar so that should have a high similairty index but A-C and B-C should have lower similarity.I need to quanitfy how similarity between two spectral profile. I have looked at procrustes distance but it dosent work when spectrum is shifted on x axis. Is there a way to quanitfy this, ideally between 0 (no similairty) and 1 (perfect similarity) ?
x1 = 0:0.1:10;
Y1 = gaussmf(x1,[0.8 5 ]);
Y2 = gaussmf(x1,[0.8 3 ]);
Y3 = gaussmf(x1,[0.4 2 ]);
figure(1)
plot(x1,Y1, ‘k’,’Linewidth’,2)
hold on
plot(x1,Y2, ‘b’,’Linewidth’,2)
hold on
plot(x1,Y3, ‘r’,’Linewidth’,2)
legend(["A","B","C"])
figure(1)
In the toy example, A and B are very similar so that should have a high similairty index but A-C and B-C should have lower similarity. I need to quanitfy how similarity between two spectral profile. I have looked at procrustes distance but it dosent work when spectrum is shifted on x axis. Is there a way to quanitfy this, ideally between 0 (no similairty) and 1 (perfect similarity) ?
x1 = 0:0.1:10;
Y1 = gaussmf(x1,[0.8 5 ]);
Y2 = gaussmf(x1,[0.8 3 ]);
Y3 = gaussmf(x1,[0.4 2 ]);
figure(1)
plot(x1,Y1, ‘k’,’Linewidth’,2)
hold on
plot(x1,Y2, ‘b’,’Linewidth’,2)
hold on
plot(x1,Y3, ‘r’,’Linewidth’,2)
legend(["A","B","C"])
figure(1)
In the toy example, A and B are very similar so that should have a high similairty index but A-C and B-C should have lower similarity. similarity index, procrustes, spectral matching MATLAB Answers — New Questions
Generating codim-1 bifurcation diagram of sliding friction oscillator
I am performing continuation analysis in MATCONT and I am finding it difficult to generate co-dim bifurcation diagram.
Here is my linearized system of equations which represents a 3-dof clutch dynamics with sliding type friction:
x1′ = x2
x2′ = -(de+Fn*mukin)*x2/je + (Fn*mukin*x4)/je – ((x2-x4)*mukin + mus)/je
x3′ = x4
x4′ = (Fn*mukin*x2)/jd – (ds+Fn*mukin)*x4/jd +ds*x6/jd + ks*x7/jd
x5′ = x6
x6′ = ds*x4/jv -ds*x6/jv – ks*x7/jv
x7′ = x6 – x4
This system dynamics represents clutch dynamics with the sliding friction between inertias je and jd. jv is the load inertia. ks is stiffness between jd and jv. de,ds is damping coefficient. Fn is normal force acting on jd and je during engagement of clutch. mukin is slope of friction curve usually between [-0.01 to 0.01] and mus is static coefficient of friction 0.136 for this analysis.
je = 1.57
jd = 0.0066
jv = 4
ks = 56665.5
ds,de = 0.1
Fn = 8000
Please guide me how to perform the continuation of this system in MATCONT.I am performing continuation analysis in MATCONT and I am finding it difficult to generate co-dim bifurcation diagram.
Here is my linearized system of equations which represents a 3-dof clutch dynamics with sliding type friction:
x1′ = x2
x2′ = -(de+Fn*mukin)*x2/je + (Fn*mukin*x4)/je – ((x2-x4)*mukin + mus)/je
x3′ = x4
x4′ = (Fn*mukin*x2)/jd – (ds+Fn*mukin)*x4/jd +ds*x6/jd + ks*x7/jd
x5′ = x6
x6′ = ds*x4/jv -ds*x6/jv – ks*x7/jv
x7′ = x6 – x4
This system dynamics represents clutch dynamics with the sliding friction between inertias je and jd. jv is the load inertia. ks is stiffness between jd and jv. de,ds is damping coefficient. Fn is normal force acting on jd and je during engagement of clutch. mukin is slope of friction curve usually between [-0.01 to 0.01] and mus is static coefficient of friction 0.136 for this analysis.
je = 1.57
jd = 0.0066
jv = 4
ks = 56665.5
ds,de = 0.1
Fn = 8000
Please guide me how to perform the continuation of this system in MATCONT. I am performing continuation analysis in MATCONT and I am finding it difficult to generate co-dim bifurcation diagram.
Here is my linearized system of equations which represents a 3-dof clutch dynamics with sliding type friction:
x1′ = x2
x2′ = -(de+Fn*mukin)*x2/je + (Fn*mukin*x4)/je – ((x2-x4)*mukin + mus)/je
x3′ = x4
x4′ = (Fn*mukin*x2)/jd – (ds+Fn*mukin)*x4/jd +ds*x6/jd + ks*x7/jd
x5′ = x6
x6′ = ds*x4/jv -ds*x6/jv – ks*x7/jv
x7′ = x6 – x4
This system dynamics represents clutch dynamics with the sliding friction between inertias je and jd. jv is the load inertia. ks is stiffness between jd and jv. de,ds is damping coefficient. Fn is normal force acting on jd and je during engagement of clutch. mukin is slope of friction curve usually between [-0.01 to 0.01] and mus is static coefficient of friction 0.136 for this analysis.
je = 1.57
jd = 0.0066
jv = 4
ks = 56665.5
ds,de = 0.1
Fn = 8000
Please guide me how to perform the continuation of this system in MATCONT. matcont MATLAB Answers — New Questions
How to launch scripts into Simulink using key shortcut
I have some scripts to automate some procese designing in Simulink, but I would like to run/launch them with a key shortcuts.
I tried to use ‘accelerator’ but is shows in the menu accelerator keys but without work.
How to activate accelerators or run/launch a custom scripts with a key shortcuts ?I have some scripts to automate some procese designing in Simulink, but I would like to run/launch them with a key shortcuts.
I tried to use ‘accelerator’ but is shows in the menu accelerator keys but without work.
How to activate accelerators or run/launch a custom scripts with a key shortcuts ? I have some scripts to automate some procese designing in Simulink, but I would like to run/launch them with a key shortcuts.
I tried to use ‘accelerator’ but is shows in the menu accelerator keys but without work.
How to activate accelerators or run/launch a custom scripts with a key shortcuts ? accelerators, key shortcuts MATLAB Answers — New Questions
Using array input and output for simulink S-function C code block
I’m having a tough time attempting to use a C code block that needs uint8 array input and output . I’ve tried starting from a number of legacy code examples but encounter crashes every time my C code actually tries to access the incoming memory. If someone can point me to a working example (I’ve already tried everything that looked relevant here) I’d appreciate it. In my latest attempt I gave up on using the legacy code functions and took code from this example Create a Basic C MEX S-Function – MATLAB & Simulink (mathworks.com) which at least runs without crashing, and started to change it to take uint8 in/out as below. However I’ve no idea where to find the equivalent of InputRealPtrsType for unit8_T . If I use InputPtrsType instead of InputRealPtrsType I get the error error C2100: you cannot dereference an operand of type const void`
static void mdlOutputs(SimStruct *S, int_T tid)
{
int_T i;
// replced ssGetInputPortRealSignalPtrs(S,0) with ssGetInputPortSignalPtrs
InputRealPtrsType uPtrs = ssGetInputPortSignalPtrs(S,0);
// replaced ssGetOutputPortRealSignal(S,0) with ssGetOutputPortSignal
real_T *y = ssGetOutputPortSignal(S,0);
int_T width = ssGetOutputPortWidth(S,0);
for (i=0; i<width; i++) {
*y++ = 2.0 *(*uPtrs[i]);
}
}I’m having a tough time attempting to use a C code block that needs uint8 array input and output . I’ve tried starting from a number of legacy code examples but encounter crashes every time my C code actually tries to access the incoming memory. If someone can point me to a working example (I’ve already tried everything that looked relevant here) I’d appreciate it. In my latest attempt I gave up on using the legacy code functions and took code from this example Create a Basic C MEX S-Function – MATLAB & Simulink (mathworks.com) which at least runs without crashing, and started to change it to take uint8 in/out as below. However I’ve no idea where to find the equivalent of InputRealPtrsType for unit8_T . If I use InputPtrsType instead of InputRealPtrsType I get the error error C2100: you cannot dereference an operand of type const void`
static void mdlOutputs(SimStruct *S, int_T tid)
{
int_T i;
// replced ssGetInputPortRealSignalPtrs(S,0) with ssGetInputPortSignalPtrs
InputRealPtrsType uPtrs = ssGetInputPortSignalPtrs(S,0);
// replaced ssGetOutputPortRealSignal(S,0) with ssGetOutputPortSignal
real_T *y = ssGetOutputPortSignal(S,0);
int_T width = ssGetOutputPortWidth(S,0);
for (i=0; i<width; i++) {
*y++ = 2.0 *(*uPtrs[i]);
}
} I’m having a tough time attempting to use a C code block that needs uint8 array input and output . I’ve tried starting from a number of legacy code examples but encounter crashes every time my C code actually tries to access the incoming memory. If someone can point me to a working example (I’ve already tried everything that looked relevant here) I’d appreciate it. In my latest attempt I gave up on using the legacy code functions and took code from this example Create a Basic C MEX S-Function – MATLAB & Simulink (mathworks.com) which at least runs without crashing, and started to change it to take uint8 in/out as below. However I’ve no idea where to find the equivalent of InputRealPtrsType for unit8_T . If I use InputPtrsType instead of InputRealPtrsType I get the error error C2100: you cannot dereference an operand of type const void`
static void mdlOutputs(SimStruct *S, int_T tid)
{
int_T i;
// replced ssGetInputPortRealSignalPtrs(S,0) with ssGetInputPortSignalPtrs
InputRealPtrsType uPtrs = ssGetInputPortSignalPtrs(S,0);
// replaced ssGetOutputPortRealSignal(S,0) with ssGetOutputPortSignal
real_T *y = ssGetOutputPortSignal(S,0);
int_T width = ssGetOutputPortWidth(S,0);
for (i=0; i<width; i++) {
*y++ = 2.0 *(*uPtrs[i]);
}
} sfunction, c-code, legacy code MATLAB Answers — New Questions
Initializing data store memory for Simulink global variables
For all functions called by Simulink function block, Simulink requires the declaration of all global variables. Also these variables need to be initialized in Data store memory. Now if any of such global variables is an array, whose initial value is an empty matrix [ ] (as its size changes during the program execution), then the Simulink is not accepting the bare initial value of [ ] for any variable’s data store memory. How to handle this situation, as there are too many such variables.For all functions called by Simulink function block, Simulink requires the declaration of all global variables. Also these variables need to be initialized in Data store memory. Now if any of such global variables is an array, whose initial value is an empty matrix [ ] (as its size changes during the program execution), then the Simulink is not accepting the bare initial value of [ ] for any variable’s data store memory. How to handle this situation, as there are too many such variables. For all functions called by Simulink function block, Simulink requires the declaration of all global variables. Also these variables need to be initialized in Data store memory. Now if any of such global variables is an array, whose initial value is an empty matrix [ ] (as its size changes during the program execution), then the Simulink is not accepting the bare initial value of [ ] for any variable’s data store memory. How to handle this situation, as there are too many such variables. simulink, data store memory, initialization MATLAB Answers — New Questions