Category: Matlab
Category Archives: Matlab
Baseband IQ to RF Signal Generation
Body:
I’m working on the IQmod example in MATLAB and attempting to generate a 4FSK signal for transmission at 150 MHz. However, I’m unclear about how to control the center frequency of the transmitted signal.
Current Approach:
I’ve tried using the center frequency option in the inport block, but it doesn’t seem to affect the transmission frequency.
The iqmodulator block offers a local Oscillator option, but its purpose in setting the center frequency isn’t entirely clear.
My Question:
How can I properly set the center frequency to 150 MHz for transmitting the 4FSK signal using the IQmod example? Should I be modulating the baseband signal with a carrier at 150 MHz before feeding it to iqmodulator? Or is there another approach within the existing structure?
Additional Information:
I’m using a sampling rate of 1 MHz for the IQ data.Body:
I’m working on the IQmod example in MATLAB and attempting to generate a 4FSK signal for transmission at 150 MHz. However, I’m unclear about how to control the center frequency of the transmitted signal.
Current Approach:
I’ve tried using the center frequency option in the inport block, but it doesn’t seem to affect the transmission frequency.
The iqmodulator block offers a local Oscillator option, but its purpose in setting the center frequency isn’t entirely clear.
My Question:
How can I properly set the center frequency to 150 MHz for transmitting the 4FSK signal using the IQmod example? Should I be modulating the baseband signal with a carrier at 150 MHz before feeding it to iqmodulator? Or is there another approach within the existing structure?
Additional Information:
I’m using a sampling rate of 1 MHz for the IQ data. Body:
I’m working on the IQmod example in MATLAB and attempting to generate a 4FSK signal for transmission at 150 MHz. However, I’m unclear about how to control the center frequency of the transmitted signal.
Current Approach:
I’ve tried using the center frequency option in the inport block, but it doesn’t seem to affect the transmission frequency.
The iqmodulator block offers a local Oscillator option, but its purpose in setting the center frequency isn’t entirely clear.
My Question:
How can I properly set the center frequency to 150 MHz for transmitting the 4FSK signal using the IQmod example? Should I be modulating the baseband signal with a carrier at 150 MHz before feeding it to iqmodulator? Or is there another approach within the existing structure?
Additional Information:
I’m using a sampling rate of 1 MHz for the IQ data. simulink, communication, mfsk, iqmodulator MATLAB Answers — New Questions
counter that will count the input 1. If the input signal goes to 0 then the counter should reset.
I have to count every "True" signal and increment the counter by 1, when the signal is "True" and reset the counter to 0 when the signal is "False"I have to count every "True" signal and increment the counter by 1, when the signal is "True" and reset the counter to 0 when the signal is "False" I have to count every "True" signal and increment the counter by 1, when the signal is "True" and reset the counter to 0 when the signal is "False" counter MATLAB Answers — New Questions
127.0.0.1:31516 – Message service fatally disconnected
Hi,
I have a problem with Matlab (both R2023b and R2024a) not being able to resume after PC wakes from sleep mode. If Matlab is open when trying to put my PC to sleep, it stalls for several minutes preventing it from sleeping (until some process times out I guess and it finally enters sleep mode). Then, after it wakes, Matlab throws this error that Message service was disconnected at a specific localhost port (see title, the port number can vary). I followed advice from other posts (https://www.mathworks.com/matlabcentral/answers/514453-message-service-fatally-disconnected, https://www.mathworks.com/matlabcentral/answers/1637690-session-locks-when-connected-to-internet-after-disconnect-it-eventually-unlocks-with-matlab-error, and links within) that suggested to reset the preferences folder in AppData and download help documentation to local storage, but neither helped. This issue started in R2023b, recently I’ve upgraded to R2024a, but the issue still persists (this means I have a fresh install of R2024a that does this).
This disconnect issue causes the session to "freeze" – I can still write code into scripts and the GUI still responds, but I cannot execute any lines, and any edits in scripts cannot be saved (meaning that anything I write/edit will be lost). Restarting Matlab "fixes" this (until the next sleep mode), but that is not a solution for me. I use Windows 11 Home 23H2 with a Ryzen 3600, the Matlab is an Academic Total Headcount licence if any of that matters.Hi,
I have a problem with Matlab (both R2023b and R2024a) not being able to resume after PC wakes from sleep mode. If Matlab is open when trying to put my PC to sleep, it stalls for several minutes preventing it from sleeping (until some process times out I guess and it finally enters sleep mode). Then, after it wakes, Matlab throws this error that Message service was disconnected at a specific localhost port (see title, the port number can vary). I followed advice from other posts (https://www.mathworks.com/matlabcentral/answers/514453-message-service-fatally-disconnected, https://www.mathworks.com/matlabcentral/answers/1637690-session-locks-when-connected-to-internet-after-disconnect-it-eventually-unlocks-with-matlab-error, and links within) that suggested to reset the preferences folder in AppData and download help documentation to local storage, but neither helped. This issue started in R2023b, recently I’ve upgraded to R2024a, but the issue still persists (this means I have a fresh install of R2024a that does this).
This disconnect issue causes the session to "freeze" – I can still write code into scripts and the GUI still responds, but I cannot execute any lines, and any edits in scripts cannot be saved (meaning that anything I write/edit will be lost). Restarting Matlab "fixes" this (until the next sleep mode), but that is not a solution for me. I use Windows 11 Home 23H2 with a Ryzen 3600, the Matlab is an Academic Total Headcount licence if any of that matters. Hi,
I have a problem with Matlab (both R2023b and R2024a) not being able to resume after PC wakes from sleep mode. If Matlab is open when trying to put my PC to sleep, it stalls for several minutes preventing it from sleeping (until some process times out I guess and it finally enters sleep mode). Then, after it wakes, Matlab throws this error that Message service was disconnected at a specific localhost port (see title, the port number can vary). I followed advice from other posts (https://www.mathworks.com/matlabcentral/answers/514453-message-service-fatally-disconnected, https://www.mathworks.com/matlabcentral/answers/1637690-session-locks-when-connected-to-internet-after-disconnect-it-eventually-unlocks-with-matlab-error, and links within) that suggested to reset the preferences folder in AppData and download help documentation to local storage, but neither helped. This issue started in R2023b, recently I’ve upgraded to R2024a, but the issue still persists (this means I have a fresh install of R2024a that does this).
This disconnect issue causes the session to "freeze" – I can still write code into scripts and the GUI still responds, but I cannot execute any lines, and any edits in scripts cannot be saved (meaning that anything I write/edit will be lost). Restarting Matlab "fixes" this (until the next sleep mode), but that is not a solution for me. I use Windows 11 Home 23H2 with a Ryzen 3600, the Matlab is an Academic Total Headcount licence if any of that matters. matlab startup, message service MATLAB Answers — New Questions
How can I solve this problem?
%数据集中1-59样本为第一类,60-130第二类,131-178第三类
load wine.mat;%载入数据
train_wine = [wine(1:30,:);wine(60:95,:);wine(131:153,:)];%第一类的1-30,第二类60-95,第三类131-153作为训练集
train_wine_labels = [wine_labels(1:30);wine_labels(60:95);wine_labels(131:153)];%提取标签
test_wine = [wine(31:59,:);wine(96:130,:);wine(154:178,:)];%剩下样本作为测试集
test_wine_labels = [wine_labels(31:59);wine_labels(96:130);wine_labels(154:178)];%提取相应标签
[mtrain,ntrain] = size(train_wine);
[mtest,ntest] = size(test_wine);%数据预处理,归一化
datatest = [train_wine;test_wine];
[dataset_scale,ps] = mapminmax(dataset’,0,1);
dataset_scale = dataset_scale’;
train_wine = dataset_scale(1:mtrain,:);
test_wine = dataset_scale((mtrain+1):(mtrain+mtest),:);
%预测模型
model = svmtrain(train_wine_labels,train_wine,’-c 2 -g 1′);
[predict_label,accuracy] = svmpredict(test_wine_labels,test_wine,model);
函数或变量 ‘wine_labels’ 无法识别。
Function or variable ‘wine_labels’ is not recognised.%数据集中1-59样本为第一类,60-130第二类,131-178第三类
load wine.mat;%载入数据
train_wine = [wine(1:30,:);wine(60:95,:);wine(131:153,:)];%第一类的1-30,第二类60-95,第三类131-153作为训练集
train_wine_labels = [wine_labels(1:30);wine_labels(60:95);wine_labels(131:153)];%提取标签
test_wine = [wine(31:59,:);wine(96:130,:);wine(154:178,:)];%剩下样本作为测试集
test_wine_labels = [wine_labels(31:59);wine_labels(96:130);wine_labels(154:178)];%提取相应标签
[mtrain,ntrain] = size(train_wine);
[mtest,ntest] = size(test_wine);%数据预处理,归一化
datatest = [train_wine;test_wine];
[dataset_scale,ps] = mapminmax(dataset’,0,1);
dataset_scale = dataset_scale’;
train_wine = dataset_scale(1:mtrain,:);
test_wine = dataset_scale((mtrain+1):(mtrain+mtest),:);
%预测模型
model = svmtrain(train_wine_labels,train_wine,’-c 2 -g 1′);
[predict_label,accuracy] = svmpredict(test_wine_labels,test_wine,model);
函数或变量 ‘wine_labels’ 无法识别。
Function or variable ‘wine_labels’ is not recognised. %数据集中1-59样本为第一类,60-130第二类,131-178第三类
load wine.mat;%载入数据
train_wine = [wine(1:30,:);wine(60:95,:);wine(131:153,:)];%第一类的1-30,第二类60-95,第三类131-153作为训练集
train_wine_labels = [wine_labels(1:30);wine_labels(60:95);wine_labels(131:153)];%提取标签
test_wine = [wine(31:59,:);wine(96:130,:);wine(154:178,:)];%剩下样本作为测试集
test_wine_labels = [wine_labels(31:59);wine_labels(96:130);wine_labels(154:178)];%提取相应标签
[mtrain,ntrain] = size(train_wine);
[mtest,ntest] = size(test_wine);%数据预处理,归一化
datatest = [train_wine;test_wine];
[dataset_scale,ps] = mapminmax(dataset’,0,1);
dataset_scale = dataset_scale’;
train_wine = dataset_scale(1:mtrain,:);
test_wine = dataset_scale((mtrain+1):(mtrain+mtest),:);
%预测模型
model = svmtrain(train_wine_labels,train_wine,’-c 2 -g 1′);
[predict_label,accuracy] = svmpredict(test_wine_labels,test_wine,model);
函数或变量 ‘wine_labels’ 无法识别。
Function or variable ‘wine_labels’ is not recognised. 无法识别 MATLAB Answers — New Questions
How to make reusable a c2000 Embedded Coder block?
Hello,
I’m using Simulink blocks from "Embedded Coder Support Package for Texas Instruments C2000 Processors/F2837xD" library, however, when trying to control a GPIO from two different subsystems (which occurs not simultaneously) I get an error message when trying to compile since the block is not reusable. How can I do it reusable?
I’ve read something about "SS_OPTION_WORKS_WITH_CODE_REUSE" but I don’t know how to make specific blocks reusable, like the next one.
Thank you very much.
Best regards.Hello,
I’m using Simulink blocks from "Embedded Coder Support Package for Texas Instruments C2000 Processors/F2837xD" library, however, when trying to control a GPIO from two different subsystems (which occurs not simultaneously) I get an error message when trying to compile since the block is not reusable. How can I do it reusable?
I’ve read something about "SS_OPTION_WORKS_WITH_CODE_REUSE" but I don’t know how to make specific blocks reusable, like the next one.
Thank you very much.
Best regards. Hello,
I’m using Simulink blocks from "Embedded Coder Support Package for Texas Instruments C2000 Processors/F2837xD" library, however, when trying to control a GPIO from two different subsystems (which occurs not simultaneously) I get an error message when trying to compile since the block is not reusable. How can I do it reusable?
I’ve read something about "SS_OPTION_WORKS_WITH_CODE_REUSE" but I don’t know how to make specific blocks reusable, like the next one.
Thank you very much.
Best regards. embedded coder, c2000 embedded coder MATLAB Answers — New Questions
Make an image darker with overlay of another image
Hello,
I have two images I read into matrices that are displayed with imagesc. I was wondering if there’s a way to darken one image using the other image (like I could in Photoshop by using the darken overlay feature). I’ve looked into a few options, like imfuse, but haven’t had much luck. Any suggestions?Hello,
I have two images I read into matrices that are displayed with imagesc. I was wondering if there’s a way to darken one image using the other image (like I could in Photoshop by using the darken overlay feature). I’ve looked into a few options, like imfuse, but haven’t had much luck. Any suggestions? Hello,
I have two images I read into matrices that are displayed with imagesc. I was wondering if there’s a way to darken one image using the other image (like I could in Photoshop by using the darken overlay feature). I’ve looked into a few options, like imfuse, but haven’t had much luck. Any suggestions? image processing MATLAB Answers — New Questions
What is the problem in my code? Lambert-W function
I’m trying to solve a non-linear system of equations using Newton-Raphson method. The problem is in section 2.1 from this paper:
https://www.sciencedirect.com/science/article/pii/S0038092X14006094#t0010
It goes only up to the second iteration, and I got incorrect answer.
I used these values for iN and VN (N=1,2,3,4,5). V1 = 1.00400400e+00; V2 = 1.02598500e+00; V3 = 1.05325500e+00; V4 = 1.08812300e+00; V5 = 1.13388700e+00; i1 = -2.40036700e-02; i2 = -3.59849700e-02; i3 = -5.32552100e-02; i4 = -7.81225600e-02 ; i5 = -1.13887200e-01;
I used a = Iph, b = I0, f = n, c = Rs, d = Rsh, Vth = 0.0258
Here’s my code:
clear all; clc;
N = 20;
tErr = 1e-6;
syms a b c d f
V1 = 1.00400400e+00; V2 = 1.02598500e+00; V3 = 1.05325500e+00; V4 = 1.08812300e+00; V5 = 1.13388700e+00; i1 = -2.40036700e-02; i2 = -3.59849700e-02; i3 = -5.32552100e-02; i4 = -7.81225600e-02 ; i5 = -1.13887200e-01;
m1 = d*(-i1 + a + b)/(0.0258*f); m2 = d*(-i2 + a + b)/(0.0258*f); m3 = d*(-i3 + a + b)/(0.0258*f); m4 = d*(-i4 + a + b)/(0.0258*f);
m5 = d*(-i5 + a + b)/(0.0258*f); n = .0258*f; k = b*d/n;
f1 = -i1*c-i1*d+a*d-n*lambertw(b*d*exp(m1)/n)-V1;
f2 = -i2*c-i2*d+a*d-n*lambertw(b*d*exp(m2)/n)-V2;
f3 = -i3*c-i3*d+a*d-n*lambertw(b*d*exp(m3)/n)-V3;
f4 = -i4*c-i4*d+a*d-n*lambertw(b*d*exp(m4)/n)-V4;
f5 = -i5*c-i5*d+a*d-n*lambertw(b*d*exp(m5)/n)-V5;
fs = [f1; f2; f3; f4; f5];
xs = [a; b; f; c; d];
jac = [d/lambertw(b*d*exp(m1)/n), -(n*lambertw(b*d*exp(m1)/n)-b*d)/(b*(1+lambertw(b*d*exp(m1)/n))), lambertw(b*d*exp(m1)/n)*(-n*lambertw(b*d*exp(m1)/n)-i1*d+a*d+b*d)/(f*(1+lambertw(b*d*exp(m1)/n))), -i1, -(n*lambertw(b*d*exp(m1)/n)+i1*d-a*d-b*d)/((1+lambertw(b*d*exp(m1)/n))*d);
d/lambertw(b*d*exp(m2)/n), -(n*lambertw(b*d*exp(m2)/n)-b*d)/(b*(1+lambertw(b*d*exp(m2)/n))), lambertw(b*d*exp(m2)/n)*(-n*lambertw(b*d*exp(m2)/n)-i2*d+a*d+b*d)/(f*(1+lambertw(b*d*exp(m2)/n))), -i2, -(n*lambertw(b*d*exp(m2)/n)+i2*d-a*d-b*d)/((1+lambertw(b*d*exp(m2)/n))*d);
d/lambertw(b*d*exp(m3)/n), -(n*lambertw(b*d*exp(m3)/n)-b*d)/(b*(1+lambertw(b*d*exp(m3)/n))), lambertw(b*d*exp(m3)/n)*(-n*lambertw(b*d*exp(m3)/n)-i3*d+a*d+b*d)/(f*(1+lambertw(b*d*exp(m3)/n))), -i3, -(n*lambertw(b*d*exp(m3)/n)+i3*d-a*d-b*d)/((1+lambertw(b*d*exp(m3)/n))*d);
d/lambertw(b*d*exp(m4)/n), -(n*lambertw(b*d*exp(m4)/n)-b*d)/(b*(1+lambertw(b*d*exp(m4)/n))), lambertw(b*d*exp(m4)/n)*(-n*lambertw(b*d*exp(m4)/n)-i4*d+a*d+b*d)/(f*(1+lambertw(b*d*exp(m4)/n))), -i4, -(n*lambertw(b*d*exp(m4)/n)+i4*d-a*d-b*d)/((1+lambertw(b*d*exp(m4)/n))*d);
d/lambertw(b*d*exp(m5)/n), -(n*lambertw(b*d*exp(m5)/n)-b*d)/(b*(1+lambertw(b*d*exp(m5)/n))), lambertw(b*d*exp(m5)/n)*(-n*lambertw(b*d*exp(m5)/n)-i5*d+a*d+b*d)/(f*(1+lambertw(b*d*exp(m5)/n))), -i5, -(n*lambertw(b*d*exp(m5)/n)+i5*d-a*d-b*d)/((1+lambertw(b*d*exp(m5)/n))*d)];
x = [1.2; 0.001; 1.5; 1; 15];
for i=1:N
f = double(subs(fs, xs, x));
j = double(subs(jac, xs, x));
x = x – inv(j)*f;
err = abs(inv(j)*f);
if(err<tErr)
break;
end
end
display(x);I’m trying to solve a non-linear system of equations using Newton-Raphson method. The problem is in section 2.1 from this paper:
https://www.sciencedirect.com/science/article/pii/S0038092X14006094#t0010
It goes only up to the second iteration, and I got incorrect answer.
I used these values for iN and VN (N=1,2,3,4,5). V1 = 1.00400400e+00; V2 = 1.02598500e+00; V3 = 1.05325500e+00; V4 = 1.08812300e+00; V5 = 1.13388700e+00; i1 = -2.40036700e-02; i2 = -3.59849700e-02; i3 = -5.32552100e-02; i4 = -7.81225600e-02 ; i5 = -1.13887200e-01;
I used a = Iph, b = I0, f = n, c = Rs, d = Rsh, Vth = 0.0258
Here’s my code:
clear all; clc;
N = 20;
tErr = 1e-6;
syms a b c d f
V1 = 1.00400400e+00; V2 = 1.02598500e+00; V3 = 1.05325500e+00; V4 = 1.08812300e+00; V5 = 1.13388700e+00; i1 = -2.40036700e-02; i2 = -3.59849700e-02; i3 = -5.32552100e-02; i4 = -7.81225600e-02 ; i5 = -1.13887200e-01;
m1 = d*(-i1 + a + b)/(0.0258*f); m2 = d*(-i2 + a + b)/(0.0258*f); m3 = d*(-i3 + a + b)/(0.0258*f); m4 = d*(-i4 + a + b)/(0.0258*f);
m5 = d*(-i5 + a + b)/(0.0258*f); n = .0258*f; k = b*d/n;
f1 = -i1*c-i1*d+a*d-n*lambertw(b*d*exp(m1)/n)-V1;
f2 = -i2*c-i2*d+a*d-n*lambertw(b*d*exp(m2)/n)-V2;
f3 = -i3*c-i3*d+a*d-n*lambertw(b*d*exp(m3)/n)-V3;
f4 = -i4*c-i4*d+a*d-n*lambertw(b*d*exp(m4)/n)-V4;
f5 = -i5*c-i5*d+a*d-n*lambertw(b*d*exp(m5)/n)-V5;
fs = [f1; f2; f3; f4; f5];
xs = [a; b; f; c; d];
jac = [d/lambertw(b*d*exp(m1)/n), -(n*lambertw(b*d*exp(m1)/n)-b*d)/(b*(1+lambertw(b*d*exp(m1)/n))), lambertw(b*d*exp(m1)/n)*(-n*lambertw(b*d*exp(m1)/n)-i1*d+a*d+b*d)/(f*(1+lambertw(b*d*exp(m1)/n))), -i1, -(n*lambertw(b*d*exp(m1)/n)+i1*d-a*d-b*d)/((1+lambertw(b*d*exp(m1)/n))*d);
d/lambertw(b*d*exp(m2)/n), -(n*lambertw(b*d*exp(m2)/n)-b*d)/(b*(1+lambertw(b*d*exp(m2)/n))), lambertw(b*d*exp(m2)/n)*(-n*lambertw(b*d*exp(m2)/n)-i2*d+a*d+b*d)/(f*(1+lambertw(b*d*exp(m2)/n))), -i2, -(n*lambertw(b*d*exp(m2)/n)+i2*d-a*d-b*d)/((1+lambertw(b*d*exp(m2)/n))*d);
d/lambertw(b*d*exp(m3)/n), -(n*lambertw(b*d*exp(m3)/n)-b*d)/(b*(1+lambertw(b*d*exp(m3)/n))), lambertw(b*d*exp(m3)/n)*(-n*lambertw(b*d*exp(m3)/n)-i3*d+a*d+b*d)/(f*(1+lambertw(b*d*exp(m3)/n))), -i3, -(n*lambertw(b*d*exp(m3)/n)+i3*d-a*d-b*d)/((1+lambertw(b*d*exp(m3)/n))*d);
d/lambertw(b*d*exp(m4)/n), -(n*lambertw(b*d*exp(m4)/n)-b*d)/(b*(1+lambertw(b*d*exp(m4)/n))), lambertw(b*d*exp(m4)/n)*(-n*lambertw(b*d*exp(m4)/n)-i4*d+a*d+b*d)/(f*(1+lambertw(b*d*exp(m4)/n))), -i4, -(n*lambertw(b*d*exp(m4)/n)+i4*d-a*d-b*d)/((1+lambertw(b*d*exp(m4)/n))*d);
d/lambertw(b*d*exp(m5)/n), -(n*lambertw(b*d*exp(m5)/n)-b*d)/(b*(1+lambertw(b*d*exp(m5)/n))), lambertw(b*d*exp(m5)/n)*(-n*lambertw(b*d*exp(m5)/n)-i5*d+a*d+b*d)/(f*(1+lambertw(b*d*exp(m5)/n))), -i5, -(n*lambertw(b*d*exp(m5)/n)+i5*d-a*d-b*d)/((1+lambertw(b*d*exp(m5)/n))*d)];
x = [1.2; 0.001; 1.5; 1; 15];
for i=1:N
f = double(subs(fs, xs, x));
j = double(subs(jac, xs, x));
x = x – inv(j)*f;
err = abs(inv(j)*f);
if(err<tErr)
break;
end
end
display(x); I’m trying to solve a non-linear system of equations using Newton-Raphson method. The problem is in section 2.1 from this paper:
https://www.sciencedirect.com/science/article/pii/S0038092X14006094#t0010
It goes only up to the second iteration, and I got incorrect answer.
I used these values for iN and VN (N=1,2,3,4,5). V1 = 1.00400400e+00; V2 = 1.02598500e+00; V3 = 1.05325500e+00; V4 = 1.08812300e+00; V5 = 1.13388700e+00; i1 = -2.40036700e-02; i2 = -3.59849700e-02; i3 = -5.32552100e-02; i4 = -7.81225600e-02 ; i5 = -1.13887200e-01;
I used a = Iph, b = I0, f = n, c = Rs, d = Rsh, Vth = 0.0258
Here’s my code:
clear all; clc;
N = 20;
tErr = 1e-6;
syms a b c d f
V1 = 1.00400400e+00; V2 = 1.02598500e+00; V3 = 1.05325500e+00; V4 = 1.08812300e+00; V5 = 1.13388700e+00; i1 = -2.40036700e-02; i2 = -3.59849700e-02; i3 = -5.32552100e-02; i4 = -7.81225600e-02 ; i5 = -1.13887200e-01;
m1 = d*(-i1 + a + b)/(0.0258*f); m2 = d*(-i2 + a + b)/(0.0258*f); m3 = d*(-i3 + a + b)/(0.0258*f); m4 = d*(-i4 + a + b)/(0.0258*f);
m5 = d*(-i5 + a + b)/(0.0258*f); n = .0258*f; k = b*d/n;
f1 = -i1*c-i1*d+a*d-n*lambertw(b*d*exp(m1)/n)-V1;
f2 = -i2*c-i2*d+a*d-n*lambertw(b*d*exp(m2)/n)-V2;
f3 = -i3*c-i3*d+a*d-n*lambertw(b*d*exp(m3)/n)-V3;
f4 = -i4*c-i4*d+a*d-n*lambertw(b*d*exp(m4)/n)-V4;
f5 = -i5*c-i5*d+a*d-n*lambertw(b*d*exp(m5)/n)-V5;
fs = [f1; f2; f3; f4; f5];
xs = [a; b; f; c; d];
jac = [d/lambertw(b*d*exp(m1)/n), -(n*lambertw(b*d*exp(m1)/n)-b*d)/(b*(1+lambertw(b*d*exp(m1)/n))), lambertw(b*d*exp(m1)/n)*(-n*lambertw(b*d*exp(m1)/n)-i1*d+a*d+b*d)/(f*(1+lambertw(b*d*exp(m1)/n))), -i1, -(n*lambertw(b*d*exp(m1)/n)+i1*d-a*d-b*d)/((1+lambertw(b*d*exp(m1)/n))*d);
d/lambertw(b*d*exp(m2)/n), -(n*lambertw(b*d*exp(m2)/n)-b*d)/(b*(1+lambertw(b*d*exp(m2)/n))), lambertw(b*d*exp(m2)/n)*(-n*lambertw(b*d*exp(m2)/n)-i2*d+a*d+b*d)/(f*(1+lambertw(b*d*exp(m2)/n))), -i2, -(n*lambertw(b*d*exp(m2)/n)+i2*d-a*d-b*d)/((1+lambertw(b*d*exp(m2)/n))*d);
d/lambertw(b*d*exp(m3)/n), -(n*lambertw(b*d*exp(m3)/n)-b*d)/(b*(1+lambertw(b*d*exp(m3)/n))), lambertw(b*d*exp(m3)/n)*(-n*lambertw(b*d*exp(m3)/n)-i3*d+a*d+b*d)/(f*(1+lambertw(b*d*exp(m3)/n))), -i3, -(n*lambertw(b*d*exp(m3)/n)+i3*d-a*d-b*d)/((1+lambertw(b*d*exp(m3)/n))*d);
d/lambertw(b*d*exp(m4)/n), -(n*lambertw(b*d*exp(m4)/n)-b*d)/(b*(1+lambertw(b*d*exp(m4)/n))), lambertw(b*d*exp(m4)/n)*(-n*lambertw(b*d*exp(m4)/n)-i4*d+a*d+b*d)/(f*(1+lambertw(b*d*exp(m4)/n))), -i4, -(n*lambertw(b*d*exp(m4)/n)+i4*d-a*d-b*d)/((1+lambertw(b*d*exp(m4)/n))*d);
d/lambertw(b*d*exp(m5)/n), -(n*lambertw(b*d*exp(m5)/n)-b*d)/(b*(1+lambertw(b*d*exp(m5)/n))), lambertw(b*d*exp(m5)/n)*(-n*lambertw(b*d*exp(m5)/n)-i5*d+a*d+b*d)/(f*(1+lambertw(b*d*exp(m5)/n))), -i5, -(n*lambertw(b*d*exp(m5)/n)+i5*d-a*d-b*d)/((1+lambertw(b*d*exp(m5)/n))*d)];
x = [1.2; 0.001; 1.5; 1; 15];
for i=1:N
f = double(subs(fs, xs, x));
j = double(subs(jac, xs, x));
x = x – inv(j)*f;
err = abs(inv(j)*f);
if(err<tErr)
break;
end
end
display(x); #newtonmethod, #solve, #nonlinear MATLAB Answers — New Questions
Export Data + Another graphic
Hey,
I have a circuit in LTSPICE and I alredy exported the data to matlab. I created a plot.
But now, I have to add another plot to it so I can compare both of them. This second plot is a bode dyagram with a transfer function and I can make it work.
Can you guys help please?Hey,
I have a circuit in LTSPICE and I alredy exported the data to matlab. I created a plot.
But now, I have to add another plot to it so I can compare both of them. This second plot is a bode dyagram with a transfer function and I can make it work.
Can you guys help please? Hey,
I have a circuit in LTSPICE and I alredy exported the data to matlab. I created a plot.
But now, I have to add another plot to it so I can compare both of them. This second plot is a bode dyagram with a transfer function and I can make it work.
Can you guys help please? matlab, circuit MATLAB Answers — New Questions
Thingspeakwrite error when using string array
This string of code is taken from the thingSpeak documentation for matlab. I just copy and paste but still got this error. I would very much appreciate it if anyone can tell me where i did wrong
<</matlabcentral/answers/uploaded_files/94486/error.JPG>>This string of code is taken from the thingSpeak documentation for matlab. I just copy and paste but still got this error. I would very much appreciate it if anyone can tell me where i did wrong
<</matlabcentral/answers/uploaded_files/94486/error.JPG>> This string of code is taken from the thingSpeak documentation for matlab. I just copy and paste but still got this error. I would very much appreciate it if anyone can tell me where i did wrong
<</matlabcentral/answers/uploaded_files/94486/error.JPG>> thingspeak, matlab, string, iot MATLAB Answers — New Questions
Book recommendations for improving optimization, control and modeling different processes in MATLAB
Hi, I want to enhance my coding skills in optimization, simulation, and control of various processes using MATLAB. Could you suggest some books that would help me achieve this?Hi, I want to enhance my coding skills in optimization, simulation, and control of various processes using MATLAB. Could you suggest some books that would help me achieve this? Hi, I want to enhance my coding skills in optimization, simulation, and control of various processes using MATLAB. Could you suggest some books that would help me achieve this? book, control, optimization, model MATLAB Answers — New Questions
Is it possible to use of Matlab functions that do not support code generation in matlab.System objects?
I am working on developing a matlab.System and would like to leverage the speed advantage of running the model in complied mode.
The matlab engine interaction with the matlab.System object is described in – https://www.mathworks.com/help/simulink/ug/simulink-engine-interaction-with-system-objects.html
In order to maintain generality of code (i.e. I have a parent model superclass which specifies methods used by several subclasses – models that share a common framework), I need to use functions like metaclass that do not support code generation.
Is it possible to use functions such as metaclass in some of the implementation methods?I am working on developing a matlab.System and would like to leverage the speed advantage of running the model in complied mode.
The matlab engine interaction with the matlab.System object is described in – https://www.mathworks.com/help/simulink/ug/simulink-engine-interaction-with-system-objects.html
In order to maintain generality of code (i.e. I have a parent model superclass which specifies methods used by several subclasses – models that share a common framework), I need to use functions like metaclass that do not support code generation.
Is it possible to use functions such as metaclass in some of the implementation methods? I am working on developing a matlab.System and would like to leverage the speed advantage of running the model in complied mode.
The matlab engine interaction with the matlab.System object is described in – https://www.mathworks.com/help/simulink/ug/simulink-engine-interaction-with-system-objects.html
In order to maintain generality of code (i.e. I have a parent model superclass which specifies methods used by several subclasses – models that share a common framework), I need to use functions like metaclass that do not support code generation.
Is it possible to use functions such as metaclass in some of the implementation methods? matlab, simulink, matlab.system MATLAB Answers — New Questions
Is there any implementation of XGBoost algorithm for decision trees in Matlab?
I’ve found other boosting algos available in fitensemble and fitcensemble options but not XGBoost. Any chance to find it somewhere else?
Thanks
RobertoI’ve found other boosting algos available in fitensemble and fitcensemble options but not XGBoost. Any chance to find it somewhere else?
Thanks
Roberto I’ve found other boosting algos available in fitensemble and fitcensemble options but not XGBoost. Any chance to find it somewhere else?
Thanks
Roberto xgboost, machine learning, optimization, decision trees, boosting MATLAB Answers — New Questions
Index error running Psychtoolbox experiment
Dear Community,
I am running my experiment using Psychtoolbox. Unfortunately, I cannot share the whole script here, but generally it’s a centre-out reaching task where my participants use a joystick to reach targets. The joystick trajectory is being tracked with high temporal resolution and saved.
The tasks is presented using Psychtoolbox-3 (3.0.19) running on the MATLAB platform (2021b) in ubuntu (22.04).
The script works somewhat unstable. In 50 percent of cases it runs smoothly without any issues. In the other 50 percent it crushes with the following error message:
Identifier: MATLAB:badsubscript (line 643)
Error: Index in position 1 exceeds array bounds. Index must not exceed 552.
Error in function TextSize: Invalid Window (or Texture) Index provided: It doesn’t correspond to an open window or texture.
Did you close it accidentally via Screen(‘Close’) or Screen(‘CloseAll’) ?
Error using Screen
Usage:
oldTextSize=Screen(‘TextSize’, windowPtr [,textSize]);
Error in C_cued_cursor_rotation_joystick_noCentre (line 727)
Screen(‘TextSize’,wPtr, 40);
Here’s a few lines of my script with line 643 highlighted:
motion(:,9) = [NaN; ((velo/pix_per_mm)/1000)]; %convert velocity units to m/s
%store raw data
trialDat{trial} = motion;
%extract reach data
reachDat{trial} = motion(move_loc:endLoc,:); % LINE 643
%get velocity trend
reachDat{trial}(:,10) = trenddecomp(reachDat{trial}(:,9));
%identify max velocity from trend data
[maxVelo, maxLoc] = max(reachDat{trial}(:, 10));
I’m not a great expert in Matlab unfortunetely. What bugs me is that the script crushes at random time points. Sometimes after 50 trials, sometimes after 450+. And there seems to be nothing different im terms of participant’s performance compared to other trials.
Do you have any ideas what can cause this issue?
And why it doesn’t crush from the very first trial?Dear Community,
I am running my experiment using Psychtoolbox. Unfortunately, I cannot share the whole script here, but generally it’s a centre-out reaching task where my participants use a joystick to reach targets. The joystick trajectory is being tracked with high temporal resolution and saved.
The tasks is presented using Psychtoolbox-3 (3.0.19) running on the MATLAB platform (2021b) in ubuntu (22.04).
The script works somewhat unstable. In 50 percent of cases it runs smoothly without any issues. In the other 50 percent it crushes with the following error message:
Identifier: MATLAB:badsubscript (line 643)
Error: Index in position 1 exceeds array bounds. Index must not exceed 552.
Error in function TextSize: Invalid Window (or Texture) Index provided: It doesn’t correspond to an open window or texture.
Did you close it accidentally via Screen(‘Close’) or Screen(‘CloseAll’) ?
Error using Screen
Usage:
oldTextSize=Screen(‘TextSize’, windowPtr [,textSize]);
Error in C_cued_cursor_rotation_joystick_noCentre (line 727)
Screen(‘TextSize’,wPtr, 40);
Here’s a few lines of my script with line 643 highlighted:
motion(:,9) = [NaN; ((velo/pix_per_mm)/1000)]; %convert velocity units to m/s
%store raw data
trialDat{trial} = motion;
%extract reach data
reachDat{trial} = motion(move_loc:endLoc,:); % LINE 643
%get velocity trend
reachDat{trial}(:,10) = trenddecomp(reachDat{trial}(:,9));
%identify max velocity from trend data
[maxVelo, maxLoc] = max(reachDat{trial}(:, 10));
I’m not a great expert in Matlab unfortunetely. What bugs me is that the script crushes at random time points. Sometimes after 50 trials, sometimes after 450+. And there seems to be nothing different im terms of participant’s performance compared to other trials.
Do you have any ideas what can cause this issue?
And why it doesn’t crush from the very first trial? Dear Community,
I am running my experiment using Psychtoolbox. Unfortunately, I cannot share the whole script here, but generally it’s a centre-out reaching task where my participants use a joystick to reach targets. The joystick trajectory is being tracked with high temporal resolution and saved.
The tasks is presented using Psychtoolbox-3 (3.0.19) running on the MATLAB platform (2021b) in ubuntu (22.04).
The script works somewhat unstable. In 50 percent of cases it runs smoothly without any issues. In the other 50 percent it crushes with the following error message:
Identifier: MATLAB:badsubscript (line 643)
Error: Index in position 1 exceeds array bounds. Index must not exceed 552.
Error in function TextSize: Invalid Window (or Texture) Index provided: It doesn’t correspond to an open window or texture.
Did you close it accidentally via Screen(‘Close’) or Screen(‘CloseAll’) ?
Error using Screen
Usage:
oldTextSize=Screen(‘TextSize’, windowPtr [,textSize]);
Error in C_cued_cursor_rotation_joystick_noCentre (line 727)
Screen(‘TextSize’,wPtr, 40);
Here’s a few lines of my script with line 643 highlighted:
motion(:,9) = [NaN; ((velo/pix_per_mm)/1000)]; %convert velocity units to m/s
%store raw data
trialDat{trial} = motion;
%extract reach data
reachDat{trial} = motion(move_loc:endLoc,:); % LINE 643
%get velocity trend
reachDat{trial}(:,10) = trenddecomp(reachDat{trial}(:,9));
%identify max velocity from trend data
[maxVelo, maxLoc] = max(reachDat{trial}(:, 10));
I’m not a great expert in Matlab unfortunetely. What bugs me is that the script crushes at random time points. Sometimes after 50 trials, sometimes after 450+. And there seems to be nothing different im terms of participant’s performance compared to other trials.
Do you have any ideas what can cause this issue?
And why it doesn’t crush from the very first trial? psychtoolbox MATLAB Answers — New Questions
Simulink start page stuck on infinite loading screen
I am using Matlab 2022b. This is the behavior I get when opening Matlab.
Selecting the Matlab application once will open two seperate Matlab windows.
Matlab itself runs fine (I can run
Opening Simulink loads the Simulink start page and once I select a project it gets stuck in an infinite loading loop. I have tried reinstalling and I get the same behavior.I am using Matlab 2022b. This is the behavior I get when opening Matlab.
Selecting the Matlab application once will open two seperate Matlab windows.
Matlab itself runs fine (I can run
Opening Simulink loads the Simulink start page and once I select a project it gets stuck in an infinite loading loop. I have tried reinstalling and I get the same behavior. I am using Matlab 2022b. This is the behavior I get when opening Matlab.
Selecting the Matlab application once will open two seperate Matlab windows.
Matlab itself runs fine (I can run
Opening Simulink loads the Simulink start page and once I select a project it gets stuck in an infinite loading loop. I have tried reinstalling and I get the same behavior. simulink MATLAB Answers — New Questions
Solve ill-conditioned linear systems
Consider the following linear system of equations :
When solving this system using MATLAB, I found that the condition number of matrix is extremely large, indicating that the system is ill-conditioned. Some characteristics of the system are as follows:
Condition number of : 2.715e+06
Determinant of : 0.5196
I have attempted several methods, including least squares, normalization, and regularization, but none have produced satisfactory results in terms of accuracy. The matrix and is currently stored as double type, and I have also tried using ‘vpa’ to control the number of significant digits, but it was in vain. Are there any effective methods to solve this system, or is it possible to identify and eliminate highly correlated row vectors to ensure the accuracy of the remaining solutions?
Matlab data ‘.mat’:
https://1drv.ms/u/s!AlQCuPoSp7emgaNizYy43ea4fhgecg?e=vd3ubh
%% Load data
load("cal_linear_equations.mat");
%% Evaluate and calculate
DET_A=det(A_coeff);
Cond_A=cond(A_coeff);
Sol_real=A_coeffb_coeff;
Error=A_coeff*Sol_real-b_coeff;
max(abs(Error));Consider the following linear system of equations :
When solving this system using MATLAB, I found that the condition number of matrix is extremely large, indicating that the system is ill-conditioned. Some characteristics of the system are as follows:
Condition number of : 2.715e+06
Determinant of : 0.5196
I have attempted several methods, including least squares, normalization, and regularization, but none have produced satisfactory results in terms of accuracy. The matrix and is currently stored as double type, and I have also tried using ‘vpa’ to control the number of significant digits, but it was in vain. Are there any effective methods to solve this system, or is it possible to identify and eliminate highly correlated row vectors to ensure the accuracy of the remaining solutions?
Matlab data ‘.mat’:
https://1drv.ms/u/s!AlQCuPoSp7emgaNizYy43ea4fhgecg?e=vd3ubh
%% Load data
load("cal_linear_equations.mat");
%% Evaluate and calculate
DET_A=det(A_coeff);
Cond_A=cond(A_coeff);
Sol_real=A_coeffb_coeff;
Error=A_coeff*Sol_real-b_coeff;
max(abs(Error)); Consider the following linear system of equations :
When solving this system using MATLAB, I found that the condition number of matrix is extremely large, indicating that the system is ill-conditioned. Some characteristics of the system are as follows:
Condition number of : 2.715e+06
Determinant of : 0.5196
I have attempted several methods, including least squares, normalization, and regularization, but none have produced satisfactory results in terms of accuracy. The matrix and is currently stored as double type, and I have also tried using ‘vpa’ to control the number of significant digits, but it was in vain. Are there any effective methods to solve this system, or is it possible to identify and eliminate highly correlated row vectors to ensure the accuracy of the remaining solutions?
Matlab data ‘.mat’:
https://1drv.ms/u/s!AlQCuPoSp7emgaNizYy43ea4fhgecg?e=vd3ubh
%% Load data
load("cal_linear_equations.mat");
%% Evaluate and calculate
DET_A=det(A_coeff);
Cond_A=cond(A_coeff);
Sol_real=A_coeffb_coeff;
Error=A_coeff*Sol_real-b_coeff;
max(abs(Error)); linear equations, equation, system MATLAB Answers — New Questions
What is the Proper Notation for Multi-level Mixed Effects Models
I am a little confused on the proper syntax/notation for multi-level mxied effects models and was wondering what the proper way to write the formula is for these in Matlab? The results for either syntax appear identical except the BLUP names from calling "randomEffects" are different.
From the Multilevel Mixed-Effects Modeling Using MATLAB where state is nested within region they use the syntax (1|REGION) + (1|STATE:REGION).
However, from the fitlme description where to "j th tomato type nested in the k th soil type" the notation used is (1|Soil) + (1|Soil:Tomato).
Thanks,
SethI am a little confused on the proper syntax/notation for multi-level mxied effects models and was wondering what the proper way to write the formula is for these in Matlab? The results for either syntax appear identical except the BLUP names from calling "randomEffects" are different.
From the Multilevel Mixed-Effects Modeling Using MATLAB where state is nested within region they use the syntax (1|REGION) + (1|STATE:REGION).
However, from the fitlme description where to "j th tomato type nested in the k th soil type" the notation used is (1|Soil) + (1|Soil:Tomato).
Thanks,
Seth I am a little confused on the proper syntax/notation for multi-level mxied effects models and was wondering what the proper way to write the formula is for these in Matlab? The results for either syntax appear identical except the BLUP names from calling "randomEffects" are different.
From the Multilevel Mixed-Effects Modeling Using MATLAB where state is nested within region they use the syntax (1|REGION) + (1|STATE:REGION).
However, from the fitlme description where to "j th tomato type nested in the k th soil type" the notation used is (1|Soil) + (1|Soil:Tomato).
Thanks,
Seth fitglme, fitlme MATLAB Answers — New Questions
Cannot find an ADALM-PLUTO radio.
Hi,
at the end of the installation of the Support Package "Communications Toolbox Support Package for Analog Devices ADALM-Pluto Radio" I get an "Hardware Setup Error" that the Adalm-Pluto cannot be found. A view to WIndows System shows the Adalm Pluto.
I tried to unistall an install several times, but it dindn’t help.
MATLAB Version: 9.3.0.713579 (R2017b)
Operating System: Microsoft Windows 10 Home Version 10.0 (Build 17134)Hi,
at the end of the installation of the Support Package "Communications Toolbox Support Package for Analog Devices ADALM-Pluto Radio" I get an "Hardware Setup Error" that the Adalm-Pluto cannot be found. A view to WIndows System shows the Adalm Pluto.
I tried to unistall an install several times, but it dindn’t help.
MATLAB Version: 9.3.0.713579 (R2017b)
Operating System: Microsoft Windows 10 Home Version 10.0 (Build 17134) Hi,
at the end of the installation of the Support Package "Communications Toolbox Support Package for Analog Devices ADALM-Pluto Radio" I get an "Hardware Setup Error" that the Adalm-Pluto cannot be found. A view to WIndows System shows the Adalm Pluto.
I tried to unistall an install several times, but it dindn’t help.
MATLAB Version: 9.3.0.713579 (R2017b)
Operating System: Microsoft Windows 10 Home Version 10.0 (Build 17134) adalm-pluto MATLAB Answers — New Questions
how to change latex default font in figure?
set(STA1,’A_Label’,’String’,’$(i+n)-C_{10}$’,’Interpreter’,’latex’,’FontSize’,18,’FontWeight’,’bold’)
When I use latex interpreter ,it can‘t use Times new roman style。how to solve this problem?
(在使用Latex编译器画图时,发现只能使用默认字体,不能更改为新罗马字体,如何解决?)set(STA1,’A_Label’,’String’,’$(i+n)-C_{10}$’,’Interpreter’,’latex’,’FontSize’,18,’FontWeight’,’bold’)
When I use latex interpreter ,it can‘t use Times new roman style。how to solve this problem?
(在使用Latex编译器画图时,发现只能使用默认字体,不能更改为新罗马字体,如何解决?) set(STA1,’A_Label’,’String’,’$(i+n)-C_{10}$’,’Interpreter’,’latex’,’FontSize’,18,’FontWeight’,’bold’)
When I use latex interpreter ,it can‘t use Times new roman style。how to solve this problem?
(在使用Latex编译器画图时,发现只能使用默认字体,不能更改为新罗马字体,如何解决?) latex, fontname, times new roman MATLAB Answers — New Questions
Non-zero Gaussian noise in image processing
How can i Generate Gaussian Noise with a non zero meadian?
i found this code put i do not understand the division by 256.
where (I) is the cameraman image.
%Generating Gaussian Noise
mean= 40/256; Std= 20; var=(Std/256)^2;
G=imnoise(I,’gaussian’,mean,var);
imshow(G)
title (‘Image with Gaussian Noise’)How can i Generate Gaussian Noise with a non zero meadian?
i found this code put i do not understand the division by 256.
where (I) is the cameraman image.
%Generating Gaussian Noise
mean= 40/256; Std= 20; var=(Std/256)^2;
G=imnoise(I,’gaussian’,mean,var);
imshow(G)
title (‘Image with Gaussian Noise’) How can i Generate Gaussian Noise with a non zero meadian?
i found this code put i do not understand the division by 256.
where (I) is the cameraman image.
%Generating Gaussian Noise
mean= 40/256; Std= 20; var=(Std/256)^2;
G=imnoise(I,’gaussian’,mean,var);
imshow(G)
title (‘Image with Gaussian Noise’) gaussian noise, digital image processing, gaussian noise with non zero median MATLAB Answers — New Questions
how to apply mask on image of a size
I have apply noise to an image, now I would like to add mask on the image of size 3×3.
This is the code I am using to add noise but not able to add mask in it.
I = imread(‘sample2.jpg’);
I = rgb2gray(I);
noise_type = ‘salt & pepper’; % ‘gaussian’ or ‘poisson’ are also valid
noises = imnoise(im, noise_type, 0.09);
nim = im;
nim(noises == 0) = 0;
%# plot
figure; subplot(1,2,1);
imagesc(nim);
colormap(gray);
title(‘the noisy image’);I have apply noise to an image, now I would like to add mask on the image of size 3×3.
This is the code I am using to add noise but not able to add mask in it.
I = imread(‘sample2.jpg’);
I = rgb2gray(I);
noise_type = ‘salt & pepper’; % ‘gaussian’ or ‘poisson’ are also valid
noises = imnoise(im, noise_type, 0.09);
nim = im;
nim(noises == 0) = 0;
%# plot
figure; subplot(1,2,1);
imagesc(nim);
colormap(gray);
title(‘the noisy image’); I have apply noise to an image, now I would like to add mask on the image of size 3×3.
This is the code I am using to add noise but not able to add mask in it.
I = imread(‘sample2.jpg’);
I = rgb2gray(I);
noise_type = ‘salt & pepper’; % ‘gaussian’ or ‘poisson’ are also valid
noises = imnoise(im, noise_type, 0.09);
nim = im;
nim(noises == 0) = 0;
%# plot
figure; subplot(1,2,1);
imagesc(nim);
colormap(gray);
title(‘the noisy image’); mask on image MATLAB Answers — New Questions