Category: Matlab
Category Archives: Matlab
Radiation pattern code needed.
Can someone please help me to plot a radiation pattern of a H-plane horn antenna in matlab. I have tried so many times but it doesn’t work. Please share the code if somebody has it. thanks a bunch.Can someone please help me to plot a radiation pattern of a H-plane horn antenna in matlab. I have tried so many times but it doesn’t work. Please share the code if somebody has it. thanks a bunch. Can someone please help me to plot a radiation pattern of a H-plane horn antenna in matlab. I have tried so many times but it doesn’t work. Please share the code if somebody has it. thanks a bunch. horn antenna, radiation pattern. MATLAB Answers — New Questions
Hotkeys not working in matlab
Hi everyone! For some unknown reason, hotkeys do not work in the editor and command window. When I select the hotkey editor in the settings, for example Ctrl+W… I’m trying to set Ctrl+W, i press Ctrl+W but Matlab displays it as Ctrl+[]. So it’s like it can’t understand the symbol. Plz help. It’s impossible to work without Ctrl+Z, Ctrl+C, etc.
OS: Pop!_OS 22.04 LTS x86_64Hi everyone! For some unknown reason, hotkeys do not work in the editor and command window. When I select the hotkey editor in the settings, for example Ctrl+W… I’m trying to set Ctrl+W, i press Ctrl+W but Matlab displays it as Ctrl+[]. So it’s like it can’t understand the symbol. Plz help. It’s impossible to work without Ctrl+Z, Ctrl+C, etc.
OS: Pop!_OS 22.04 LTS x86_64 Hi everyone! For some unknown reason, hotkeys do not work in the editor and command window. When I select the hotkey editor in the settings, for example Ctrl+W… I’m trying to set Ctrl+W, i press Ctrl+W but Matlab displays it as Ctrl+[]. So it’s like it can’t understand the symbol. Plz help. It’s impossible to work without Ctrl+Z, Ctrl+C, etc.
OS: Pop!_OS 22.04 LTS x86_64 linux, keyboard, hotkeys MATLAB Answers — New Questions
how use categorical in uitable
VNAMES={‘On’,’Trading’,’L_S’,’Stat’,’PROVA’,’Cap’,’Perc’,’Draw_Sys’};
cat=categorical({‘Fil’;’Stat’});
VTYPES=[{‘logical’},{‘string’},{‘string’},{‘double’},{‘double’},{‘cat’},{‘double’},{‘logical’}];
T=table(‘Size’,[nrows,numel(VNAMES)],’VariableTypes’,VTYPES,’VariableNames’,VNAMES);
Error using table (line 310)
Specify variable types as a string array or a cell array of character
vectors, such as ["string", "datetime", "double"].
i try to use in vtypes : {‘cat’}..{cat}…{"cat"} but it give me an errorVNAMES={‘On’,’Trading’,’L_S’,’Stat’,’PROVA’,’Cap’,’Perc’,’Draw_Sys’};
cat=categorical({‘Fil’;’Stat’});
VTYPES=[{‘logical’},{‘string’},{‘string’},{‘double’},{‘double’},{‘cat’},{‘double’},{‘logical’}];
T=table(‘Size’,[nrows,numel(VNAMES)],’VariableTypes’,VTYPES,’VariableNames’,VNAMES);
Error using table (line 310)
Specify variable types as a string array or a cell array of character
vectors, such as ["string", "datetime", "double"].
i try to use in vtypes : {‘cat’}..{cat}…{"cat"} but it give me an error VNAMES={‘On’,’Trading’,’L_S’,’Stat’,’PROVA’,’Cap’,’Perc’,’Draw_Sys’};
cat=categorical({‘Fil’;’Stat’});
VTYPES=[{‘logical’},{‘string’},{‘string’},{‘double’},{‘double’},{‘cat’},{‘double’},{‘logical’}];
T=table(‘Size’,[nrows,numel(VNAMES)],’VariableTypes’,VTYPES,’VariableNames’,VNAMES);
Error using table (line 310)
Specify variable types as a string array or a cell array of character
vectors, such as ["string", "datetime", "double"].
i try to use in vtypes : {‘cat’}..{cat}…{"cat"} but it give me an error how use categorical in uitable MATLAB Answers — New Questions
Change size of input arguments without recompiling mex with codegen
I compiled a simple function with matlab coder. The function takes three input arguments: xvec is [nx,1], yvec is [ny,1] and zmat is [nx,ny]. All is good the first time I run the mex function, but if I subsequently change the size of one of the input arrays (say I change nx from nx=8 to nx=7), the function crashes. Of course I can compile again the code and it runs, but I really want to avoid recompilation every time I change the dimension of the inputs!
MWE here:
clear
clc
close all
nx = 8;
ny = 3;
xvec = linspace(0,1,nx)’;
yvec = linspace(0,1,ny)’;
zmat = xvec.^2+yvec’; % [nx,ny]
%size(zmat)
disp(‘Calling myfun…’)
res = myfun(xvec,yvec,zmat);
% MEX with codegen
disp(‘Compiling MEX…’)
cfg = coder.config(‘mex’);
cfg.GenerateReport = true;
codegen -config cfg myfun -args {xvec,yvec,zmat} -o myfun_mex
disp(‘Calling myfun_mex…’)
res_mex = myfun_mex(xvec,yvec,zmat);
err_mex = abs(res-res_mex)
and here is the function:
function res = myfun(x,y,z)
res = sum(x)+sum(y)+sum(sum(z));
end
First time, I compile and it runs OK. Then, if I set nx=7, it crashes with the following error message:
“`
Incorrect size for expression ‘x’: expected [8×1] but found [7×1].
Error in myfun_mex
Error in main (line 22)
res_mex = myfun_mex(xvec,yvec,zmat);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
“`
Any help is greatly appreciated, thanks!I compiled a simple function with matlab coder. The function takes three input arguments: xvec is [nx,1], yvec is [ny,1] and zmat is [nx,ny]. All is good the first time I run the mex function, but if I subsequently change the size of one of the input arrays (say I change nx from nx=8 to nx=7), the function crashes. Of course I can compile again the code and it runs, but I really want to avoid recompilation every time I change the dimension of the inputs!
MWE here:
clear
clc
close all
nx = 8;
ny = 3;
xvec = linspace(0,1,nx)’;
yvec = linspace(0,1,ny)’;
zmat = xvec.^2+yvec’; % [nx,ny]
%size(zmat)
disp(‘Calling myfun…’)
res = myfun(xvec,yvec,zmat);
% MEX with codegen
disp(‘Compiling MEX…’)
cfg = coder.config(‘mex’);
cfg.GenerateReport = true;
codegen -config cfg myfun -args {xvec,yvec,zmat} -o myfun_mex
disp(‘Calling myfun_mex…’)
res_mex = myfun_mex(xvec,yvec,zmat);
err_mex = abs(res-res_mex)
and here is the function:
function res = myfun(x,y,z)
res = sum(x)+sum(y)+sum(sum(z));
end
First time, I compile and it runs OK. Then, if I set nx=7, it crashes with the following error message:
“`
Incorrect size for expression ‘x’: expected [8×1] but found [7×1].
Error in myfun_mex
Error in main (line 22)
res_mex = myfun_mex(xvec,yvec,zmat);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
“`
Any help is greatly appreciated, thanks! I compiled a simple function with matlab coder. The function takes three input arguments: xvec is [nx,1], yvec is [ny,1] and zmat is [nx,ny]. All is good the first time I run the mex function, but if I subsequently change the size of one of the input arrays (say I change nx from nx=8 to nx=7), the function crashes. Of course I can compile again the code and it runs, but I really want to avoid recompilation every time I change the dimension of the inputs!
MWE here:
clear
clc
close all
nx = 8;
ny = 3;
xvec = linspace(0,1,nx)’;
yvec = linspace(0,1,ny)’;
zmat = xvec.^2+yvec’; % [nx,ny]
%size(zmat)
disp(‘Calling myfun…’)
res = myfun(xvec,yvec,zmat);
% MEX with codegen
disp(‘Compiling MEX…’)
cfg = coder.config(‘mex’);
cfg.GenerateReport = true;
codegen -config cfg myfun -args {xvec,yvec,zmat} -o myfun_mex
disp(‘Calling myfun_mex…’)
res_mex = myfun_mex(xvec,yvec,zmat);
err_mex = abs(res-res_mex)
and here is the function:
function res = myfun(x,y,z)
res = sum(x)+sum(y)+sum(sum(z));
end
First time, I compile and it runs OK. Then, if I set nx=7, it crashes with the following error message:
“`
Incorrect size for expression ‘x’: expected [8×1] but found [7×1].
Error in myfun_mex
Error in main (line 22)
res_mex = myfun_mex(xvec,yvec,zmat);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
“`
Any help is greatly appreciated, thanks! codegen, function, mex MATLAB Answers — New Questions
External mode option not showing on simulink matlab 2020a
I want to interface arduino with simulink in external mode but i didnt find external mode option in simulink.Please help me to find that ‘external mode’option in main menu.I want to interface arduino with simulink in external mode but i didnt find external mode option in simulink.Please help me to find that ‘external mode’option in main menu. I want to interface arduino with simulink in external mode but i didnt find external mode option in simulink.Please help me to find that ‘external mode’option in main menu. simulink, matlab MATLAB Answers — New Questions
Matlab no muestra el gráfico de mi codigo
Estoy usando matlab online y nunca he tenido problemas con las graficas ni codigo, todo me funcionaba perfecto, hace unos dias hice un codigo que me devuelve una grafica, pero hoy ejecute el mismo codigo sin ningun cambio y no me devuelve la grafica, solo me muestra el pnale de grafica pero en blanco
tengo el siguiente codigo:
close all
clear all
clc
% Duración y frecuencia de muestreo
duration = 5;
Fs = 44100;
t = linspace(0, duration, duration * Fs);
% crossfade con maximo de 1
crossfade = exponentialFunction(t, 1, 1);
% Señal generada aleatoriamente adicional para producir el efecto de crossfade
autoGeneratedSignal = cos(2 * pi * 1000 * t); % Ajusta la frecuencia y forma de la señal
% Aplicar crossfade a las dos señales
signal1 = autoGeneratedSignal .* crossfade(2, :);
signal2 = sin(2 * pi * 500 * t) .* crossfade(1, :); % Genera otra señal, puedes ajustar la frecuencia
% Sumar las señales para obtener el resultado del crossfade
result = signal2 + signal1;
% Visualizar el resultado
figure;
subplot(3, 1, 1);
plot(t, signal1, ‘LineWidth’, 2);
title(‘Señal Generada con Crossfade’);
subplot(3, 1, 2);
plot(t, signal2, ‘LineWidth’, 2);
title(‘Otra Señal con Crossfade’);
subplot(3, 1, 3);
plot(t, result, ‘LineWidth’, 2);
title(‘Resultado del Crossfade’);
% Reproducir el resultado
sound(result, Fs);
function y = exponentialFunction(t, decayRate, growthRate)
% Genera una función exponencial decreciente y creciente con un valor máximo de 1.
% Parámetros:
% t: Vector de tiempo
% decayRate: Tasa de decrecimiento exponencial (debe ser un número positivo)
% growthRate: Tasa de crecimiento exponencial (debe ser un número positivo)
% Asegúrate de que los parámetros sean válidos
if decayRate <= 0 || growthRate <= 0
error(‘Las tasas de decrecimiento y crecimiento deben ser números positivos.’);
end
% Genera las funciones exponenciales
decayFunction = exp(-decayRate * t);
growthFunction = 1 – exp(-growthRate * t);
% Normaliza las funciones para tener un valor máximo de 1
decayFunction = decayFunction / max(decayFunction);
growthFunction = growthFunction / max(growthFunction);
% Combina las funciones
y = [decayFunction; growthFunction];
endEstoy usando matlab online y nunca he tenido problemas con las graficas ni codigo, todo me funcionaba perfecto, hace unos dias hice un codigo que me devuelve una grafica, pero hoy ejecute el mismo codigo sin ningun cambio y no me devuelve la grafica, solo me muestra el pnale de grafica pero en blanco
tengo el siguiente codigo:
close all
clear all
clc
% Duración y frecuencia de muestreo
duration = 5;
Fs = 44100;
t = linspace(0, duration, duration * Fs);
% crossfade con maximo de 1
crossfade = exponentialFunction(t, 1, 1);
% Señal generada aleatoriamente adicional para producir el efecto de crossfade
autoGeneratedSignal = cos(2 * pi * 1000 * t); % Ajusta la frecuencia y forma de la señal
% Aplicar crossfade a las dos señales
signal1 = autoGeneratedSignal .* crossfade(2, :);
signal2 = sin(2 * pi * 500 * t) .* crossfade(1, :); % Genera otra señal, puedes ajustar la frecuencia
% Sumar las señales para obtener el resultado del crossfade
result = signal2 + signal1;
% Visualizar el resultado
figure;
subplot(3, 1, 1);
plot(t, signal1, ‘LineWidth’, 2);
title(‘Señal Generada con Crossfade’);
subplot(3, 1, 2);
plot(t, signal2, ‘LineWidth’, 2);
title(‘Otra Señal con Crossfade’);
subplot(3, 1, 3);
plot(t, result, ‘LineWidth’, 2);
title(‘Resultado del Crossfade’);
% Reproducir el resultado
sound(result, Fs);
function y = exponentialFunction(t, decayRate, growthRate)
% Genera una función exponencial decreciente y creciente con un valor máximo de 1.
% Parámetros:
% t: Vector de tiempo
% decayRate: Tasa de decrecimiento exponencial (debe ser un número positivo)
% growthRate: Tasa de crecimiento exponencial (debe ser un número positivo)
% Asegúrate de que los parámetros sean válidos
if decayRate <= 0 || growthRate <= 0
error(‘Las tasas de decrecimiento y crecimiento deben ser números positivos.’);
end
% Genera las funciones exponenciales
decayFunction = exp(-decayRate * t);
growthFunction = 1 – exp(-growthRate * t);
% Normaliza las funciones para tener un valor máximo de 1
decayFunction = decayFunction / max(decayFunction);
growthFunction = growthFunction / max(growthFunction);
% Combina las funciones
y = [decayFunction; growthFunction];
end Estoy usando matlab online y nunca he tenido problemas con las graficas ni codigo, todo me funcionaba perfecto, hace unos dias hice un codigo que me devuelve una grafica, pero hoy ejecute el mismo codigo sin ningun cambio y no me devuelve la grafica, solo me muestra el pnale de grafica pero en blanco
tengo el siguiente codigo:
close all
clear all
clc
% Duración y frecuencia de muestreo
duration = 5;
Fs = 44100;
t = linspace(0, duration, duration * Fs);
% crossfade con maximo de 1
crossfade = exponentialFunction(t, 1, 1);
% Señal generada aleatoriamente adicional para producir el efecto de crossfade
autoGeneratedSignal = cos(2 * pi * 1000 * t); % Ajusta la frecuencia y forma de la señal
% Aplicar crossfade a las dos señales
signal1 = autoGeneratedSignal .* crossfade(2, :);
signal2 = sin(2 * pi * 500 * t) .* crossfade(1, :); % Genera otra señal, puedes ajustar la frecuencia
% Sumar las señales para obtener el resultado del crossfade
result = signal2 + signal1;
% Visualizar el resultado
figure;
subplot(3, 1, 1);
plot(t, signal1, ‘LineWidth’, 2);
title(‘Señal Generada con Crossfade’);
subplot(3, 1, 2);
plot(t, signal2, ‘LineWidth’, 2);
title(‘Otra Señal con Crossfade’);
subplot(3, 1, 3);
plot(t, result, ‘LineWidth’, 2);
title(‘Resultado del Crossfade’);
% Reproducir el resultado
sound(result, Fs);
function y = exponentialFunction(t, decayRate, growthRate)
% Genera una función exponencial decreciente y creciente con un valor máximo de 1.
% Parámetros:
% t: Vector de tiempo
% decayRate: Tasa de decrecimiento exponencial (debe ser un número positivo)
% growthRate: Tasa de crecimiento exponencial (debe ser un número positivo)
% Asegúrate de que los parámetros sean válidos
if decayRate <= 0 || growthRate <= 0
error(‘Las tasas de decrecimiento y crecimiento deben ser números positivos.’);
end
% Genera las funciones exponenciales
decayFunction = exp(-decayRate * t);
growthFunction = 1 – exp(-growthRate * t);
% Normaliza las funciones para tener un valor máximo de 1
decayFunction = decayFunction / max(decayFunction);
growthFunction = growthFunction / max(growthFunction);
% Combina las funciones
y = [decayFunction; growthFunction];
end matlab online MATLAB Answers — New Questions
Vehicle Dynamics 3DOF Single Track Block doesn’t seem to include drag equations.
For the Vehicle Body 3 DOF block in the Vehicle Dynamics Blockset, I’ve configured it to run in single track mode. The documentation includes equations for drag forces under the dual track section, but not the single track section, which led me to believe that the drag forces are only relevant for the dual track block.
This does not seem to be the case, as I’m observing the drag forces in the output of the single track block to be nonzero. It makes sense that drag would be accounted for in both single track and dual track modes, but why then are the drag forces only described in the dual track equations?
Furthermore, the single track documentation does mention drag forces, saying that external forces = drag forces + input forces:
But then when I observe the external body forces as output by the block, they are always 0 despite the drag forces being nonzero. Seems like there might be a term overload with "external forces" referring both to the external input forces as well as the drag + input combined force.
External force input:
What I thought would be the computed external force output (drag + input forces), but is always 0 when input force is 0:For the Vehicle Body 3 DOF block in the Vehicle Dynamics Blockset, I’ve configured it to run in single track mode. The documentation includes equations for drag forces under the dual track section, but not the single track section, which led me to believe that the drag forces are only relevant for the dual track block.
This does not seem to be the case, as I’m observing the drag forces in the output of the single track block to be nonzero. It makes sense that drag would be accounted for in both single track and dual track modes, but why then are the drag forces only described in the dual track equations?
Furthermore, the single track documentation does mention drag forces, saying that external forces = drag forces + input forces:
But then when I observe the external body forces as output by the block, they are always 0 despite the drag forces being nonzero. Seems like there might be a term overload with "external forces" referring both to the external input forces as well as the drag + input combined force.
External force input:
What I thought would be the computed external force output (drag + input forces), but is always 0 when input force is 0: For the Vehicle Body 3 DOF block in the Vehicle Dynamics Blockset, I’ve configured it to run in single track mode. The documentation includes equations for drag forces under the dual track section, but not the single track section, which led me to believe that the drag forces are only relevant for the dual track block.
This does not seem to be the case, as I’m observing the drag forces in the output of the single track block to be nonzero. It makes sense that drag would be accounted for in both single track and dual track modes, but why then are the drag forces only described in the dual track equations?
Furthermore, the single track documentation does mention drag forces, saying that external forces = drag forces + input forces:
But then when I observe the external body forces as output by the block, they are always 0 despite the drag forces being nonzero. Seems like there might be a term overload with "external forces" referring both to the external input forces as well as the drag + input combined force.
External force input:
What I thought would be the computed external force output (drag + input forces), but is always 0 when input force is 0: simulink, vehicle dynamics MATLAB Answers — New Questions
Calculating UACI, NPCR for 2 images
Presently I have a problem in implementing the UACI and PSNR code for 2 images which are respectively Original & Cipher Images. I need the code for calculating it……
What would the Code? I don’t have much idea about it..
Do I need to find UACI between 2 images or only 1 image will be sufficientPresently I have a problem in implementing the UACI and PSNR code for 2 images which are respectively Original & Cipher Images. I need the code for calculating it……
What would the Code? I don’t have much idea about it..
Do I need to find UACI between 2 images or only 1 image will be sufficient Presently I have a problem in implementing the UACI and PSNR code for 2 images which are respectively Original & Cipher Images. I need the code for calculating it……
What would the Code? I don’t have much idea about it..
Do I need to find UACI between 2 images or only 1 image will be sufficient uaci, psnr calculation MATLAB Answers — New Questions
Help with MATLAB symbolic toolbox
Hi there everyone,
I need some help with using the MATLAB symbolic tool box.
I have some symbolic expressions to manipulate and I am getting quite frustrated.
I have the paticular solution to a differential equation and need to find the coefficients C1 and C2.
% Set up symbolic variables
syms t C1 C2
% Set up parameters
K = 2.2167e+06;
M = 45.96;
wn = sqrt(K/M)
c = 0.5
% set up quadratic terms
a = 1
b = 2*c*wn
c = wn^2
% Solve for u
u1 = (-b + sqrt(b^2 – 4*a*c))/2
u2 = (-b – sqrt(b^2 – 4*a*c))/2
% Particalular solution to differential equation
yp = vpa(exp(-43.1357*t)*(C1*cos(74.7132*t) + C2*sin(74.7132*t)) == 0,4)
% The first derivitive of yp
dyp = vpa(diff(yp),4)
% Find the value of C1 interm of C2
C1 = vpa(solve(yp, C1),4)
% Sub C1 into equation dyp to have an expression in terms of C2 alone
eq = vpa(subs(dyp,C2,C1),4)
As you can see I obtain the value of C1 in terms of C2. I then want to plug this into equation "dyp". However, when I run the code for "eq", C1 is still in the expression. The expression should contain just C2’s, and this is really frustrating. If equation "eq" contains just C2 values I can then solve for C2 – I hope this makes sense.
Is there a way around this. I have not very good at plug and chucking with long and messy equatons, so I am hoping MATLAB can help me out.
Thanks in advance,
ScottHi there everyone,
I need some help with using the MATLAB symbolic tool box.
I have some symbolic expressions to manipulate and I am getting quite frustrated.
I have the paticular solution to a differential equation and need to find the coefficients C1 and C2.
% Set up symbolic variables
syms t C1 C2
% Set up parameters
K = 2.2167e+06;
M = 45.96;
wn = sqrt(K/M)
c = 0.5
% set up quadratic terms
a = 1
b = 2*c*wn
c = wn^2
% Solve for u
u1 = (-b + sqrt(b^2 – 4*a*c))/2
u2 = (-b – sqrt(b^2 – 4*a*c))/2
% Particalular solution to differential equation
yp = vpa(exp(-43.1357*t)*(C1*cos(74.7132*t) + C2*sin(74.7132*t)) == 0,4)
% The first derivitive of yp
dyp = vpa(diff(yp),4)
% Find the value of C1 interm of C2
C1 = vpa(solve(yp, C1),4)
% Sub C1 into equation dyp to have an expression in terms of C2 alone
eq = vpa(subs(dyp,C2,C1),4)
As you can see I obtain the value of C1 in terms of C2. I then want to plug this into equation "dyp". However, when I run the code for "eq", C1 is still in the expression. The expression should contain just C2’s, and this is really frustrating. If equation "eq" contains just C2 values I can then solve for C2 – I hope this makes sense.
Is there a way around this. I have not very good at plug and chucking with long and messy equatons, so I am hoping MATLAB can help me out.
Thanks in advance,
Scott Hi there everyone,
I need some help with using the MATLAB symbolic tool box.
I have some symbolic expressions to manipulate and I am getting quite frustrated.
I have the paticular solution to a differential equation and need to find the coefficients C1 and C2.
% Set up symbolic variables
syms t C1 C2
% Set up parameters
K = 2.2167e+06;
M = 45.96;
wn = sqrt(K/M)
c = 0.5
% set up quadratic terms
a = 1
b = 2*c*wn
c = wn^2
% Solve for u
u1 = (-b + sqrt(b^2 – 4*a*c))/2
u2 = (-b – sqrt(b^2 – 4*a*c))/2
% Particalular solution to differential equation
yp = vpa(exp(-43.1357*t)*(C1*cos(74.7132*t) + C2*sin(74.7132*t)) == 0,4)
% The first derivitive of yp
dyp = vpa(diff(yp),4)
% Find the value of C1 interm of C2
C1 = vpa(solve(yp, C1),4)
% Sub C1 into equation dyp to have an expression in terms of C2 alone
eq = vpa(subs(dyp,C2,C1),4)
As you can see I obtain the value of C1 in terms of C2. I then want to plug this into equation "dyp". However, when I run the code for "eq", C1 is still in the expression. The expression should contain just C2’s, and this is really frustrating. If equation "eq" contains just C2 values I can then solve for C2 – I hope this makes sense.
Is there a way around this. I have not very good at plug and chucking with long and messy equatons, so I am hoping MATLAB can help me out.
Thanks in advance,
Scott symbolic MATLAB Answers — New Questions
error: Function definition is misplaced or improperly nested error?
I am defining a nested function (bicomp1) inside a function (biaxialcomp) whose output is to be minimised using the fmincon optimization function, but I get an error that this function is misplaced or improperly nested. What could be the problem with it?
function [Mux, Muy] = biaxialcomp(c,app,gc,gs,bar,n,i)
th = [10 20 30 40 50 60 70 80];
Mux = zeros(1,8);
Muy = zeros(1,8);
for iv = 1:8
% first potential scenario
if app.b*tand(th(iv)) < app.t
tt = app.b*sind(th(iv))+app.t*cosd(th(iv));
c_opt = fmincon(@bicomp1,c,[],[],[],[],0,tt);
function obj = bicomp1(c)
a = 0.8*c;
Xna = a/sind(th(iv));
fcu = 0.67*app.Fcu/gc;
…I am defining a nested function (bicomp1) inside a function (biaxialcomp) whose output is to be minimised using the fmincon optimization function, but I get an error that this function is misplaced or improperly nested. What could be the problem with it?
function [Mux, Muy] = biaxialcomp(c,app,gc,gs,bar,n,i)
th = [10 20 30 40 50 60 70 80];
Mux = zeros(1,8);
Muy = zeros(1,8);
for iv = 1:8
% first potential scenario
if app.b*tand(th(iv)) < app.t
tt = app.b*sind(th(iv))+app.t*cosd(th(iv));
c_opt = fmincon(@bicomp1,c,[],[],[],[],0,tt);
function obj = bicomp1(c)
a = 0.8*c;
Xna = a/sind(th(iv));
fcu = 0.67*app.Fcu/gc;
… I am defining a nested function (bicomp1) inside a function (biaxialcomp) whose output is to be minimised using the fmincon optimization function, but I get an error that this function is misplaced or improperly nested. What could be the problem with it?
function [Mux, Muy] = biaxialcomp(c,app,gc,gs,bar,n,i)
th = [10 20 30 40 50 60 70 80];
Mux = zeros(1,8);
Muy = zeros(1,8);
for iv = 1:8
% first potential scenario
if app.b*tand(th(iv)) < app.t
tt = app.b*sind(th(iv))+app.t*cosd(th(iv));
c_opt = fmincon(@bicomp1,c,[],[],[],[],0,tt);
function obj = bicomp1(c)
a = 0.8*c;
Xna = a/sind(th(iv));
fcu = 0.67*app.Fcu/gc;
… functions MATLAB Answers — New Questions
Viscircles. Example doesn’t work
I try to understand function Viscircles. But i can’t do it. I can’t to launch the example Clear Axes Before Plotting Circles. Where i can wrong?
figure
colors = {‘b’,’r’,’g’,’y’,’k’};
for k = 1:5
% Create 5 random circles to display,
X = rand(5,1);
Y = rand(5,1);
centers = [X Y];
radii = 0.1*rand(5,1);
% Clear the axes.
cla
% Fix the axis limits.
xlim([-0.1 1.1])
ylim([-0.1 1.1])
% Set the axis aspect ratio to 1:1.
axis square
% Set a title.
title([‘k = ‘ num2str(k)])
% Display the circles.
viscircles(centers,radii,’Color’,colors{k});
%% Error using viscircles>parseInputs (line 175) Unknown input string: Color.
%% Error in viscircles (line 67) [ax, centers, radii, options] = parseInputs(varargin{:});
% Pause for 1 second.
pause(1)
endI try to understand function Viscircles. But i can’t do it. I can’t to launch the example Clear Axes Before Plotting Circles. Where i can wrong?
figure
colors = {‘b’,’r’,’g’,’y’,’k’};
for k = 1:5
% Create 5 random circles to display,
X = rand(5,1);
Y = rand(5,1);
centers = [X Y];
radii = 0.1*rand(5,1);
% Clear the axes.
cla
% Fix the axis limits.
xlim([-0.1 1.1])
ylim([-0.1 1.1])
% Set the axis aspect ratio to 1:1.
axis square
% Set a title.
title([‘k = ‘ num2str(k)])
% Display the circles.
viscircles(centers,radii,’Color’,colors{k});
%% Error using viscircles>parseInputs (line 175) Unknown input string: Color.
%% Error in viscircles (line 67) [ax, centers, radii, options] = parseInputs(varargin{:});
% Pause for 1 second.
pause(1)
end I try to understand function Viscircles. But i can’t do it. I can’t to launch the example Clear Axes Before Plotting Circles. Where i can wrong?
figure
colors = {‘b’,’r’,’g’,’y’,’k’};
for k = 1:5
% Create 5 random circles to display,
X = rand(5,1);
Y = rand(5,1);
centers = [X Y];
radii = 0.1*rand(5,1);
% Clear the axes.
cla
% Fix the axis limits.
xlim([-0.1 1.1])
ylim([-0.1 1.1])
% Set the axis aspect ratio to 1:1.
axis square
% Set a title.
title([‘k = ‘ num2str(k)])
% Display the circles.
viscircles(centers,radii,’Color’,colors{k});
%% Error using viscircles>parseInputs (line 175) Unknown input string: Color.
%% Error in viscircles (line 67) [ax, centers, radii, options] = parseInputs(varargin{:});
% Pause for 1 second.
pause(1)
end viscircles MATLAB Answers — New Questions
Simmetrical Constraints in Multivariate Regression
Hi everyone!
This is my problem:
My data are related in this way: F = H*V + B*A where F is a 2xn matrix, V and A are 2xn matrices while H and B are 2×2 matrices.
H and B must be simmetrical.
I’ve already got F, V and A and I want to calculate H and B with a multivariate regression. How can I do it?
Thank you in advance!Hi everyone!
This is my problem:
My data are related in this way: F = H*V + B*A where F is a 2xn matrix, V and A are 2xn matrices while H and B are 2×2 matrices.
H and B must be simmetrical.
I’ve already got F, V and A and I want to calculate H and B with a multivariate regression. How can I do it?
Thank you in advance! Hi everyone!
This is my problem:
My data are related in this way: F = H*V + B*A where F is a 2xn matrix, V and A are 2xn matrices while H and B are 2×2 matrices.
H and B must be simmetrical.
I’ve already got F, V and A and I want to calculate H and B with a multivariate regression. How can I do it?
Thank you in advance! regression, matrices MATLAB Answers — New Questions
Finding the percentile of a time series
Dear all,
I hope this finds you well.
I had a question concerning quantiles/percentiles. I want to know the 90th percentile of my time series, because I want to use that value as a threshold later on.
Is it enough to use the quantile() or the prctile() commands on my data set, or do I have to go with a different approach that involves sorting my data, finding the standard deviation, etc. or Find the distribution of my data then look at the tails?
Also my time series has NaNs in them. Not sure if that affects the commands.
This is a dropbox link to my data:
https://www.dropbox.com/s/k838d1ww0wj5s38/Help-Data.mat?dl=0
Thank You!!Dear all,
I hope this finds you well.
I had a question concerning quantiles/percentiles. I want to know the 90th percentile of my time series, because I want to use that value as a threshold later on.
Is it enough to use the quantile() or the prctile() commands on my data set, or do I have to go with a different approach that involves sorting my data, finding the standard deviation, etc. or Find the distribution of my data then look at the tails?
Also my time series has NaNs in them. Not sure if that affects the commands.
This is a dropbox link to my data:
https://www.dropbox.com/s/k838d1ww0wj5s38/Help-Data.mat?dl=0
Thank You!! Dear all,
I hope this finds you well.
I had a question concerning quantiles/percentiles. I want to know the 90th percentile of my time series, because I want to use that value as a threshold later on.
Is it enough to use the quantile() or the prctile() commands on my data set, or do I have to go with a different approach that involves sorting my data, finding the standard deviation, etc. or Find the distribution of my data then look at the tails?
Also my time series has NaNs in them. Not sure if that affects the commands.
This is a dropbox link to my data:
https://www.dropbox.com/s/k838d1ww0wj5s38/Help-Data.mat?dl=0
Thank You!! percentile, time series, noob, quantile MATLAB Answers — New Questions
How i can get the best option plot for density and also other graph ?
i saw a lot design of graph which color are change and make a plot very better and really i am looking for such option but i can’t manage the option and i don’t know which option is good can any one help me for get the best design of plotting?
% Define the grid
[x, y] = meshgrid(linspace(-10, 10, 400), linspace(-10, 10, 400));
% Define the function
Z = real(0.3e1 ./ 0.2e1 * (0.9375e1 .* exp(0.25e1 * x – 0.4761904763e0 * y) + 0.50625e1 .* exp(0.15e1 * x – 0.2e1 * y)) ./ (0.1e1 + 0.15e1 .* exp(0.25e1 * x – 0.4761904763e0 * y) + 0.225e1 .* exp(0.15e1 * x – 0.2e1 * y)) – 0.3e1 ./ 0.2e1 .* (0.375e1 .* exp(0.25e1 * x – 0.4761904763e0 * y) + 0.3375e1 .* exp(0.15e1 * x – 0.2e1 * y)) .^ 2 ./ (0.1e1 + 0.15e1 .* exp(0.25e1 * x – 0.4761904763e0 * y) + 0.225e1 .* exp(0.15e1 * x – 0.2e1 * y)) .^ 2);
% Create density plot
figure;
contourf(x, y, Z, 50, ‘LineStyle’, ‘none’);
colormap(prism);
xlabel(‘x’);
ylabel(‘y’);
title(‘Density Plot of Given Function’);i saw a lot design of graph which color are change and make a plot very better and really i am looking for such option but i can’t manage the option and i don’t know which option is good can any one help me for get the best design of plotting?
% Define the grid
[x, y] = meshgrid(linspace(-10, 10, 400), linspace(-10, 10, 400));
% Define the function
Z = real(0.3e1 ./ 0.2e1 * (0.9375e1 .* exp(0.25e1 * x – 0.4761904763e0 * y) + 0.50625e1 .* exp(0.15e1 * x – 0.2e1 * y)) ./ (0.1e1 + 0.15e1 .* exp(0.25e1 * x – 0.4761904763e0 * y) + 0.225e1 .* exp(0.15e1 * x – 0.2e1 * y)) – 0.3e1 ./ 0.2e1 .* (0.375e1 .* exp(0.25e1 * x – 0.4761904763e0 * y) + 0.3375e1 .* exp(0.15e1 * x – 0.2e1 * y)) .^ 2 ./ (0.1e1 + 0.15e1 .* exp(0.25e1 * x – 0.4761904763e0 * y) + 0.225e1 .* exp(0.15e1 * x – 0.2e1 * y)) .^ 2);
% Create density plot
figure;
contourf(x, y, Z, 50, ‘LineStyle’, ‘none’);
colormap(prism);
xlabel(‘x’);
ylabel(‘y’);
title(‘Density Plot of Given Function’); i saw a lot design of graph which color are change and make a plot very better and really i am looking for such option but i can’t manage the option and i don’t know which option is good can any one help me for get the best design of plotting?
% Define the grid
[x, y] = meshgrid(linspace(-10, 10, 400), linspace(-10, 10, 400));
% Define the function
Z = real(0.3e1 ./ 0.2e1 * (0.9375e1 .* exp(0.25e1 * x – 0.4761904763e0 * y) + 0.50625e1 .* exp(0.15e1 * x – 0.2e1 * y)) ./ (0.1e1 + 0.15e1 .* exp(0.25e1 * x – 0.4761904763e0 * y) + 0.225e1 .* exp(0.15e1 * x – 0.2e1 * y)) – 0.3e1 ./ 0.2e1 .* (0.375e1 .* exp(0.25e1 * x – 0.4761904763e0 * y) + 0.3375e1 .* exp(0.15e1 * x – 0.2e1 * y)) .^ 2 ./ (0.1e1 + 0.15e1 .* exp(0.25e1 * x – 0.4761904763e0 * y) + 0.225e1 .* exp(0.15e1 * x – 0.2e1 * y)) .^ 2);
% Create density plot
figure;
contourf(x, y, Z, 50, ‘LineStyle’, ‘none’);
colormap(prism);
xlabel(‘x’);
ylabel(‘y’);
title(‘Density Plot of Given Function’); plotting MATLAB Answers — New Questions
Distributed and spmd not running faster
I think I’m missing something fundamental about using distributed arrays with spmd. If I run the following the distributed version takes ~0.04s while the non-distributed version completes in ~0.2s (with a process pool matching the cores on my machine).
x = ones(10000, 10000);
tic
x = x * 2.3;
toc
x
x = distributed(ones(10000, 10000));
tic
spmd
x = x * 2.3;
end
toc
gather(x)
What am I missing?
Edit: I moved the tic and toc to after the array initialization and before displaying x to not include that as I realized calling distributed is taking longer while it distributes the array across the processes and gather is taking time.I think I’m missing something fundamental about using distributed arrays with spmd. If I run the following the distributed version takes ~0.04s while the non-distributed version completes in ~0.2s (with a process pool matching the cores on my machine).
x = ones(10000, 10000);
tic
x = x * 2.3;
toc
x
x = distributed(ones(10000, 10000));
tic
spmd
x = x * 2.3;
end
toc
gather(x)
What am I missing?
Edit: I moved the tic and toc to after the array initialization and before displaying x to not include that as I realized calling distributed is taking longer while it distributes the array across the processes and gather is taking time. I think I’m missing something fundamental about using distributed arrays with spmd. If I run the following the distributed version takes ~0.04s while the non-distributed version completes in ~0.2s (with a process pool matching the cores on my machine).
x = ones(10000, 10000);
tic
x = x * 2.3;
toc
x
x = distributed(ones(10000, 10000));
tic
spmd
x = x * 2.3;
end
toc
gather(x)
What am I missing?
Edit: I moved the tic and toc to after the array initialization and before displaying x to not include that as I realized calling distributed is taking longer while it distributes the array across the processes and gather is taking time. distributed, parallel computing, spmd, parallel computing toolbox MATLAB Answers — New Questions
Matlab for auto logging into websites, populating web fields etc or go with Python
Hello all
I know that Matlab is suited for many engineering uses however i wanted the opinion of the community of using Matlab to run automated reports by extracting data from web sites as well as autologging into websites and populating data fields.
An idea i have is to use a Matlab GUI for a user to enter data, this data then opens a browser and populates various web fields.
I have been told that i should abandon the idea of using Matlab and go with Python.
Just wondering what the thoughts of the commuinty was?
Thank you.Hello all
I know that Matlab is suited for many engineering uses however i wanted the opinion of the community of using Matlab to run automated reports by extracting data from web sites as well as autologging into websites and populating data fields.
An idea i have is to use a Matlab GUI for a user to enter data, this data then opens a browser and populates various web fields.
I have been told that i should abandon the idea of using Matlab and go with Python.
Just wondering what the thoughts of the commuinty was?
Thank you. Hello all
I know that Matlab is suited for many engineering uses however i wanted the opinion of the community of using Matlab to run automated reports by extracting data from web sites as well as autologging into websites and populating data fields.
An idea i have is to use a Matlab GUI for a user to enter data, this data then opens a browser and populates various web fields.
I have been told that i should abandon the idea of using Matlab and go with Python.
Just wondering what the thoughts of the commuinty was?
Thank you. web, auto log in, matlab 2019 MATLAB Answers — New Questions
CPM Modulator Implementation Methods
In the comm.CPMModulator help, in the "More About > CPM Method", it says the output comes from a relation mentioned there.
But, the only way to get to the same output is by using FM Modulator method (using g(t) instead of q(t)).
I wonder if there is a way to get to the same output just by using that relation (using q(t)).
Thanks!In the comm.CPMModulator help, in the "More About > CPM Method", it says the output comes from a relation mentioned there.
But, the only way to get to the same output is by using FM Modulator method (using g(t) instead of q(t)).
I wonder if there is a way to get to the same output just by using that relation (using q(t)).
Thanks! In the comm.CPMModulator help, in the "More About > CPM Method", it says the output comes from a relation mentioned there.
But, the only way to get to the same output is by using FM Modulator method (using g(t) instead of q(t)).
I wonder if there is a way to get to the same output just by using that relation (using q(t)).
Thanks! cpm modulator, digital modulations, communications toolbox, wireless communications MATLAB Answers — New Questions
How do I multiplex 3 phase power system signals onto a single signal or generate a varying frequency voltage source
So I am trying to test a HVDC model’s response to a frequency deviation. I designed a quick model to output a balanced three phase voltage whose frequency profile I could control (see image attached). The trouble is that I get the voltage as three separate signals, but I need them as a single line. I’ve tried both generic muxes and physical signal converters, but they don’t connect (wrong signal type). Essentially what I want to do is the reverse of a phase splitter block but I can’t find a block that will do this.
Please reply if you have a solution to this problem or if you know of a different way to vary the frequency of a three phase voltage source.So I am trying to test a HVDC model’s response to a frequency deviation. I designed a quick model to output a balanced three phase voltage whose frequency profile I could control (see image attached). The trouble is that I get the voltage as three separate signals, but I need them as a single line. I’ve tried both generic muxes and physical signal converters, but they don’t connect (wrong signal type). Essentially what I want to do is the reverse of a phase splitter block but I can’t find a block that will do this.
Please reply if you have a solution to this problem or if you know of a different way to vary the frequency of a three phase voltage source. So I am trying to test a HVDC model’s response to a frequency deviation. I designed a quick model to output a balanced three phase voltage whose frequency profile I could control (see image attached). The trouble is that I get the voltage as three separate signals, but I need them as a single line. I’ve tried both generic muxes and physical signal converters, but they don’t connect (wrong signal type). Essentially what I want to do is the reverse of a phase splitter block but I can’t find a block that will do this.
Please reply if you have a solution to this problem or if you know of a different way to vary the frequency of a three phase voltage source. three phase, frequency, varying, mux, simpowersystems, power system, power_electronics_control, power_conversion_control MATLAB Answers — New Questions
website is not receiving data from ,y node mcu
I’m using a NodeMCU for my AQI project. Initially, everything was working fine, but now when I try to update, my ThingSpeak website isn’t showing any new data. It only shows my last entry from three months ago.
The serial monitor indicates ‘Data sent to ThingSpeak,’ but my channel is not displaying any updated data. Instead, it’s showing ‘Field value unavailable.I’m using a NodeMCU for my AQI project. Initially, everything was working fine, but now when I try to update, my ThingSpeak website isn’t showing any new data. It only shows my last entry from three months ago.
The serial monitor indicates ‘Data sent to ThingSpeak,’ but my channel is not displaying any updated data. Instead, it’s showing ‘Field value unavailable. I’m using a NodeMCU for my AQI project. Initially, everything was working fine, but now when I try to update, my ThingSpeak website isn’t showing any new data. It only shows my last entry from three months ago.
The serial monitor indicates ‘Data sent to ThingSpeak,’ but my channel is not displaying any updated data. Instead, it’s showing ‘Field value unavailable. data not received MATLAB Answers — New Questions
How to connect broken lines, but no enlarge line width?
I need to fill rectangle(run fill holes), but the broken lines in rectangle stop me to do this. due to the high density rectangles in figure, so I want to connect broken lines, but no enlarge line width. Could you help me?
I have tryed to do dilate/erode/open/close mask operations, but they all can’t meet my request.I need to fill rectangle(run fill holes), but the broken lines in rectangle stop me to do this. due to the high density rectangles in figure, so I want to connect broken lines, but no enlarge line width. Could you help me?
I have tryed to do dilate/erode/open/close mask operations, but they all can’t meet my request. I need to fill rectangle(run fill holes), but the broken lines in rectangle stop me to do this. due to the high density rectangles in figure, so I want to connect broken lines, but no enlarge line width. Could you help me?
I have tryed to do dilate/erode/open/close mask operations, but they all can’t meet my request. image processing, image segmentation MATLAB Answers — New Questions