Category: Matlab
Category Archives: Matlab
Is it possible to make this tiny loop faster?
It seems that it might be possible to make this loop faster. Does anyone have any thoughts? I have to call a loop like this millions of times in a larger workflow, and it is getting to be the slowest part of the code. I appreciate any insights!
a = 2; % constant
b = 3; % constant
n = 10; % number of elements of outputs c and s
% n could be up to 100
% preallocate and set the initial conditions
c = zeros(n,1);
s = c;
c(1) = 3; % set the initial condition for c
s(1) = 1; % set the initial condition for s
% run the loop
for i = 2:n
c(i) = a*c(i-1) -b*s(i-1);
s(i) = b*c(i-1) + a*s(i-1);
endIt seems that it might be possible to make this loop faster. Does anyone have any thoughts? I have to call a loop like this millions of times in a larger workflow, and it is getting to be the slowest part of the code. I appreciate any insights!
a = 2; % constant
b = 3; % constant
n = 10; % number of elements of outputs c and s
% n could be up to 100
% preallocate and set the initial conditions
c = zeros(n,1);
s = c;
c(1) = 3; % set the initial condition for c
s(1) = 1; % set the initial condition for s
% run the loop
for i = 2:n
c(i) = a*c(i-1) -b*s(i-1);
s(i) = b*c(i-1) + a*s(i-1);
end It seems that it might be possible to make this loop faster. Does anyone have any thoughts? I have to call a loop like this millions of times in a larger workflow, and it is getting to be the slowest part of the code. I appreciate any insights!
a = 2; % constant
b = 3; % constant
n = 10; % number of elements of outputs c and s
% n could be up to 100
% preallocate and set the initial conditions
c = zeros(n,1);
s = c;
c(1) = 3; % set the initial condition for c
s(1) = 1; % set the initial condition for s
% run the loop
for i = 2:n
c(i) = a*c(i-1) -b*s(i-1);
s(i) = b*c(i-1) + a*s(i-1);
end vectorization, for loop, speed MATLAB Answers — New Questions
Solar Wind Battery Hybrid Integration
I have created solar system by connecting PV array to boost converter working at MPPT by using P&O MPPT technique. Furthermore i have created wind system by connecting Wind turbine with PMSG which is connected with uncontrolled rectifier and boost converter and I have applied P&O on that boost converter. Both are seperatelly working on MPPT . Now I want to integrate both the system to a common bus from which i will suppy it to grid. Now when I am trying to integrate both either solar or wind is not working properly. For low loads the wind system is not working at mppt and for high loads the solar is not working on MPPT.I have created solar system by connecting PV array to boost converter working at MPPT by using P&O MPPT technique. Furthermore i have created wind system by connecting Wind turbine with PMSG which is connected with uncontrolled rectifier and boost converter and I have applied P&O on that boost converter. Both are seperatelly working on MPPT . Now I want to integrate both the system to a common bus from which i will suppy it to grid. Now when I am trying to integrate both either solar or wind is not working properly. For low loads the wind system is not working at mppt and for high loads the solar is not working on MPPT. I have created solar system by connecting PV array to boost converter working at MPPT by using P&O MPPT technique. Furthermore i have created wind system by connecting Wind turbine with PMSG which is connected with uncontrolled rectifier and boost converter and I have applied P&O on that boost converter. Both are seperatelly working on MPPT . Now I want to integrate both the system to a common bus from which i will suppy it to grid. Now when I am trying to integrate both either solar or wind is not working properly. For low loads the wind system is not working at mppt and for high loads the solar is not working on MPPT. solar, wind, mppt, hybrid model, dc bus MATLAB Answers — New Questions
Why does it say “invalid email or password” when i reinstall r2023b Product
I have a problem reinstalling Matlab2023b, as the error states "invalid email or password" when I try to install R2025a or any other product. Note that my email and password are correct, and I can log in to the MathWorks account. Could you advise me on how to resolve this issue?
thanks lot
Your sincerely
Reda dalilaI have a problem reinstalling Matlab2023b, as the error states "invalid email or password" when I try to install R2025a or any other product. Note that my email and password are correct, and I can log in to the MathWorks account. Could you advise me on how to resolve this issue?
thanks lot
Your sincerely
Reda dalila I have a problem reinstalling Matlab2023b, as the error states "invalid email or password" when I try to install R2025a or any other product. Note that my email and password are correct, and I can log in to the MathWorks account. Could you advise me on how to resolve this issue?
thanks lot
Your sincerely
Reda dalila invalid password or email MATLAB Answers — New Questions
TIFF from ImageJ not loading correctly in R2024b (worked in R2022b)
Hi,
I’ve been using MATLAB to analyze 3D confocal images saved as TIFF files. My process is to get the original images from NIS-Elements, then open them in ImageJ to crop just the droplet region, and save that as a TIFF. In MATLAB R2022b, this TIFF input would allow the program to do a full 3D reconstruction of the droplet and calculate the data I need.
But now that I’m using R2024b, the same TIFF files don’t load properly. The 3D reconstruction step stops and doesn’t work, and I get no data even when I test it using the exact same TIFF files and inputs that worked previously.
I’m wondering if MATLAB R2024b handles TIFF files differently than R2022b? Are there specific settings I should use when saving TIFFs from ImageJ to make sure they work with the latest MATLAB? Or would this be entirely a different problem?
Thanks!Hi,
I’ve been using MATLAB to analyze 3D confocal images saved as TIFF files. My process is to get the original images from NIS-Elements, then open them in ImageJ to crop just the droplet region, and save that as a TIFF. In MATLAB R2022b, this TIFF input would allow the program to do a full 3D reconstruction of the droplet and calculate the data I need.
But now that I’m using R2024b, the same TIFF files don’t load properly. The 3D reconstruction step stops and doesn’t work, and I get no data even when I test it using the exact same TIFF files and inputs that worked previously.
I’m wondering if MATLAB R2024b handles TIFF files differently than R2022b? Are there specific settings I should use when saving TIFFs from ImageJ to make sure they work with the latest MATLAB? Or would this be entirely a different problem?
Thanks! Hi,
I’ve been using MATLAB to analyze 3D confocal images saved as TIFF files. My process is to get the original images from NIS-Elements, then open them in ImageJ to crop just the droplet region, and save that as a TIFF. In MATLAB R2022b, this TIFF input would allow the program to do a full 3D reconstruction of the droplet and calculate the data I need.
But now that I’m using R2024b, the same TIFF files don’t load properly. The 3D reconstruction step stops and doesn’t work, and I get no data even when I test it using the exact same TIFF files and inputs that worked previously.
I’m wondering if MATLAB R2024b handles TIFF files differently than R2022b? Are there specific settings I should use when saving TIFFs from ImageJ to make sure they work with the latest MATLAB? Or would this be entirely a different problem?
Thanks! tiff, 3d reconstruction, matlab2024b, image proces MATLAB Answers — New Questions
Regarding using trainnet, testnet in binary image classification(size difference between network output and test data output)
Hello, every MATLAB users,
I’m trying to make simple binary classification network
model is designed to check whether the image has certain object or not
input datastore is combined of image datastore and label datastore as shown:
imdsTrain = imageDatastore(trainingDataTbl.imageFileName);
imdsTrain.Labels = trainingDataTbl.existence;
imdsTrain.Labels = categorical(imdsTrain.Labels)
labelsTrain = categorical(trainingDataTbl.existence);
ldsTrain = arrayDatastore(labelsTrain);
cdsTrain = combine(imdsTrain, ldsTrain);
(i know already imdsTrain has label data but i modified to debug the error even it doesn’t matter)
Each labels is one of 2 categories : True, False
Designed network structure is as follows:
fcn = @(X) X(:,:,1);
bClayers = [
imageInputLayer([800 800 3],"Name","imageinput")
functionLayer(fcn, "Name","gray")
convolution2dLayer([5 5],8,"Name","conv","Padding","same")
reluLayer("Name","relu")
maxPooling2dLayer([8 8],"Name","maxpool","Padding","same","Stride",[8 8])
convolution2dLayer([3 3],16,"Name","conv_1","Padding","same")
reluLayer("Name","relu_1")
maxPooling2dLayer([5 5],"Name","maxpool_1","Padding","same","Stride",[5 5])
fullyConnectedLayer(2,"Name","fc")
softmaxLayer("Name","softmax")];
It’s simple CNN structure
I set the options as below:
options = trainingOptions("adam", …
GradientDecayFactor=0.9, …
SquaredGradientDecayFactor=0.999, …
InitialLearnRate=0.001, …
LearnRateSchedule="none", …
MiniBatchSize=1, …
L2Regularization=0.0005, …
MaxEpochs=4, …
BatchNormalizationStatistics="moving", …
DispatchInBackground=false, …
ResetInputNormalization=false, …
Shuffle="every-epoch", …
VerboseFrequency=20, …
CheckpointPath=tempdir);
I set the MiniBatchSize with 1.
Because, I don’t know why but some reason error came up when i execute the trainnet function.
net = trainnet(cdsTrain, bClayers, "crossentropy", options);
the error message is that size of prediction(maybe output of the network) is not same with size of desired value(maybe ground truth label data).
and the desired value size is affected by MiniBatchSize.
I have no idea why this error is occuring.
How Can I Adjust MiniBatchSize or Modify the Code to Run Succesfully??
다음 사용 중 오류가 발생함: validateTrueValues (54번 라인) 예측값 및 목표값의 크기가 일치해야 합니다. 예측값의 크기: 2(C) × 1(B) 목표값의 크기: 2(C) × 16(B)
(This is the Korean error message)
I trained with minibatch size of 1 Anyway.
Another problem happens.
metricValues = testnet(net, cdsTest, "accuracy");
While test the network, Even I make Traindata and Testdata with Same size and same formality,
Code couldn’t run with error message the size between network output and desired value(maybe Test data) should same.
This is korean error message for anyone who can understand:
다음 사용 중 오류가 발생함: testnet (40번 라인)
메트릭 "Accuracy"의 경우 네트워크 출력값과 목표값의 크기가 동일해야 합니다.
How can I fix this code??
I hope anyone could respond my question.
Thank you for reading.Hello, every MATLAB users,
I’m trying to make simple binary classification network
model is designed to check whether the image has certain object or not
input datastore is combined of image datastore and label datastore as shown:
imdsTrain = imageDatastore(trainingDataTbl.imageFileName);
imdsTrain.Labels = trainingDataTbl.existence;
imdsTrain.Labels = categorical(imdsTrain.Labels)
labelsTrain = categorical(trainingDataTbl.existence);
ldsTrain = arrayDatastore(labelsTrain);
cdsTrain = combine(imdsTrain, ldsTrain);
(i know already imdsTrain has label data but i modified to debug the error even it doesn’t matter)
Each labels is one of 2 categories : True, False
Designed network structure is as follows:
fcn = @(X) X(:,:,1);
bClayers = [
imageInputLayer([800 800 3],"Name","imageinput")
functionLayer(fcn, "Name","gray")
convolution2dLayer([5 5],8,"Name","conv","Padding","same")
reluLayer("Name","relu")
maxPooling2dLayer([8 8],"Name","maxpool","Padding","same","Stride",[8 8])
convolution2dLayer([3 3],16,"Name","conv_1","Padding","same")
reluLayer("Name","relu_1")
maxPooling2dLayer([5 5],"Name","maxpool_1","Padding","same","Stride",[5 5])
fullyConnectedLayer(2,"Name","fc")
softmaxLayer("Name","softmax")];
It’s simple CNN structure
I set the options as below:
options = trainingOptions("adam", …
GradientDecayFactor=0.9, …
SquaredGradientDecayFactor=0.999, …
InitialLearnRate=0.001, …
LearnRateSchedule="none", …
MiniBatchSize=1, …
L2Regularization=0.0005, …
MaxEpochs=4, …
BatchNormalizationStatistics="moving", …
DispatchInBackground=false, …
ResetInputNormalization=false, …
Shuffle="every-epoch", …
VerboseFrequency=20, …
CheckpointPath=tempdir);
I set the MiniBatchSize with 1.
Because, I don’t know why but some reason error came up when i execute the trainnet function.
net = trainnet(cdsTrain, bClayers, "crossentropy", options);
the error message is that size of prediction(maybe output of the network) is not same with size of desired value(maybe ground truth label data).
and the desired value size is affected by MiniBatchSize.
I have no idea why this error is occuring.
How Can I Adjust MiniBatchSize or Modify the Code to Run Succesfully??
다음 사용 중 오류가 발생함: validateTrueValues (54번 라인) 예측값 및 목표값의 크기가 일치해야 합니다. 예측값의 크기: 2(C) × 1(B) 목표값의 크기: 2(C) × 16(B)
(This is the Korean error message)
I trained with minibatch size of 1 Anyway.
Another problem happens.
metricValues = testnet(net, cdsTest, "accuracy");
While test the network, Even I make Traindata and Testdata with Same size and same formality,
Code couldn’t run with error message the size between network output and desired value(maybe Test data) should same.
This is korean error message for anyone who can understand:
다음 사용 중 오류가 발생함: testnet (40번 라인)
메트릭 "Accuracy"의 경우 네트워크 출력값과 목표값의 크기가 동일해야 합니다.
How can I fix this code??
I hope anyone could respond my question.
Thank you for reading. Hello, every MATLAB users,
I’m trying to make simple binary classification network
model is designed to check whether the image has certain object or not
input datastore is combined of image datastore and label datastore as shown:
imdsTrain = imageDatastore(trainingDataTbl.imageFileName);
imdsTrain.Labels = trainingDataTbl.existence;
imdsTrain.Labels = categorical(imdsTrain.Labels)
labelsTrain = categorical(trainingDataTbl.existence);
ldsTrain = arrayDatastore(labelsTrain);
cdsTrain = combine(imdsTrain, ldsTrain);
(i know already imdsTrain has label data but i modified to debug the error even it doesn’t matter)
Each labels is one of 2 categories : True, False
Designed network structure is as follows:
fcn = @(X) X(:,:,1);
bClayers = [
imageInputLayer([800 800 3],"Name","imageinput")
functionLayer(fcn, "Name","gray")
convolution2dLayer([5 5],8,"Name","conv","Padding","same")
reluLayer("Name","relu")
maxPooling2dLayer([8 8],"Name","maxpool","Padding","same","Stride",[8 8])
convolution2dLayer([3 3],16,"Name","conv_1","Padding","same")
reluLayer("Name","relu_1")
maxPooling2dLayer([5 5],"Name","maxpool_1","Padding","same","Stride",[5 5])
fullyConnectedLayer(2,"Name","fc")
softmaxLayer("Name","softmax")];
It’s simple CNN structure
I set the options as below:
options = trainingOptions("adam", …
GradientDecayFactor=0.9, …
SquaredGradientDecayFactor=0.999, …
InitialLearnRate=0.001, …
LearnRateSchedule="none", …
MiniBatchSize=1, …
L2Regularization=0.0005, …
MaxEpochs=4, …
BatchNormalizationStatistics="moving", …
DispatchInBackground=false, …
ResetInputNormalization=false, …
Shuffle="every-epoch", …
VerboseFrequency=20, …
CheckpointPath=tempdir);
I set the MiniBatchSize with 1.
Because, I don’t know why but some reason error came up when i execute the trainnet function.
net = trainnet(cdsTrain, bClayers, "crossentropy", options);
the error message is that size of prediction(maybe output of the network) is not same with size of desired value(maybe ground truth label data).
and the desired value size is affected by MiniBatchSize.
I have no idea why this error is occuring.
How Can I Adjust MiniBatchSize or Modify the Code to Run Succesfully??
다음 사용 중 오류가 발생함: validateTrueValues (54번 라인) 예측값 및 목표값의 크기가 일치해야 합니다. 예측값의 크기: 2(C) × 1(B) 목표값의 크기: 2(C) × 16(B)
(This is the Korean error message)
I trained with minibatch size of 1 Anyway.
Another problem happens.
metricValues = testnet(net, cdsTest, "accuracy");
While test the network, Even I make Traindata and Testdata with Same size and same formality,
Code couldn’t run with error message the size between network output and desired value(maybe Test data) should same.
This is korean error message for anyone who can understand:
다음 사용 중 오류가 발생함: testnet (40번 라인)
메트릭 "Accuracy"의 경우 네트워크 출력값과 목표값의 크기가 동일해야 합니다.
How can I fix this code??
I hope anyone could respond my question.
Thank you for reading. binaryclassification, cnn, trainnet, deeplearning, testnet MATLAB Answers — New Questions
Optimal decimation to Log Simulation Data
Hello everyone,
I have a Inverter model and I want to calculate its switching losses, although I can use MATLAB function ee_getPowerLossSummary, but I want to implement my own power loss analysis in post-processing. If I modulate the inverter at 5kHz, the switching event happens every 200mcicrosecond, and if I want to log simulation data in workspace, what should be the decimation keeping in mind these things.
I am using a variable step solver, because I couldn’t use fixed step with N-channel MOSFTET, where PWM is provided by the Three-phase Two-Level PWM generator with sample time (1/10*Fsw).
If I run the simulation for 7 seconds only, the total step sizes could be up to 7M, keeping in mind the step size of 1microsecond.
Is there any way to run that model with fixed-step solver, or what should be the decimation so that my simulation speed is optimal as well as I can capture the swiching events.
Looking forward to hearign from the experts.
Thank You!Hello everyone,
I have a Inverter model and I want to calculate its switching losses, although I can use MATLAB function ee_getPowerLossSummary, but I want to implement my own power loss analysis in post-processing. If I modulate the inverter at 5kHz, the switching event happens every 200mcicrosecond, and if I want to log simulation data in workspace, what should be the decimation keeping in mind these things.
I am using a variable step solver, because I couldn’t use fixed step with N-channel MOSFTET, where PWM is provided by the Three-phase Two-Level PWM generator with sample time (1/10*Fsw).
If I run the simulation for 7 seconds only, the total step sizes could be up to 7M, keeping in mind the step size of 1microsecond.
Is there any way to run that model with fixed-step solver, or what should be the decimation so that my simulation speed is optimal as well as I can capture the swiching events.
Looking forward to hearign from the experts.
Thank You! Hello everyone,
I have a Inverter model and I want to calculate its switching losses, although I can use MATLAB function ee_getPowerLossSummary, but I want to implement my own power loss analysis in post-processing. If I modulate the inverter at 5kHz, the switching event happens every 200mcicrosecond, and if I want to log simulation data in workspace, what should be the decimation keeping in mind these things.
I am using a variable step solver, because I couldn’t use fixed step with N-channel MOSFTET, where PWM is provided by the Three-phase Two-Level PWM generator with sample time (1/10*Fsw).
If I run the simulation for 7 seconds only, the total step sizes could be up to 7M, keeping in mind the step size of 1microsecond.
Is there any way to run that model with fixed-step solver, or what should be the decimation so that my simulation speed is optimal as well as I can capture the swiching events.
Looking forward to hearign from the experts.
Thank You! power_electronics_control MATLAB Answers — New Questions
I need to use a scope to display the current i and the power P as functions of the voltage V, with the curves obtained for various irradiance levels and temperatures
1. Context
As part of my energy modeling project, I developed a simulation model in Simulink:
A photovoltaic (PV) panel model based on the single-diode approach, accounting for irradiance and temperature effects.
the model generate time-domain outputs under standard test conditions.
2. Objectives
I need to extract the I–V and P–V curves of the PV panel for different environmental conditions:
Irradiance (G): 200, 400, 600, 800, 1000 W/m²
Temperature (T): 0°C, 25°C, 50°C
3. Current model status
The Simulink PV model includes:
Computation of Iph, Irs, I0
Equivalent PV cell circuit
Buck-Boost converter with MPPT and PWM control
Time-based curves: Pin(t), Pout(t)Inputs: Irradiance (G), Temperature (T)However, it does not currently output I–V or P–V curves directly.
4. Issues encountered
No direct I–V and P–V output
No voltage sweep mechanism to generate these curves
No variation tracking across different G and T conditions
5. Request for help
I’d appreciate guidance on how to:
Add a voltage sweep mechanism (controlled voltage source) to the PV model
Automatically extract I–V and P–V curves for different G and T values
Create a simulation script that loops over multiple irradiance and temperature settings
Export the results (ideally to .mat or .csv)
Thank you in advance for any suggestions or shared examples!1. Context
As part of my energy modeling project, I developed a simulation model in Simulink:
A photovoltaic (PV) panel model based on the single-diode approach, accounting for irradiance and temperature effects.
the model generate time-domain outputs under standard test conditions.
2. Objectives
I need to extract the I–V and P–V curves of the PV panel for different environmental conditions:
Irradiance (G): 200, 400, 600, 800, 1000 W/m²
Temperature (T): 0°C, 25°C, 50°C
3. Current model status
The Simulink PV model includes:
Computation of Iph, Irs, I0
Equivalent PV cell circuit
Buck-Boost converter with MPPT and PWM control
Time-based curves: Pin(t), Pout(t)Inputs: Irradiance (G), Temperature (T)However, it does not currently output I–V or P–V curves directly.
4. Issues encountered
No direct I–V and P–V output
No voltage sweep mechanism to generate these curves
No variation tracking across different G and T conditions
5. Request for help
I’d appreciate guidance on how to:
Add a voltage sweep mechanism (controlled voltage source) to the PV model
Automatically extract I–V and P–V curves for different G and T values
Create a simulation script that loops over multiple irradiance and temperature settings
Export the results (ideally to .mat or .csv)
Thank you in advance for any suggestions or shared examples! 1. Context
As part of my energy modeling project, I developed a simulation model in Simulink:
A photovoltaic (PV) panel model based on the single-diode approach, accounting for irradiance and temperature effects.
the model generate time-domain outputs under standard test conditions.
2. Objectives
I need to extract the I–V and P–V curves of the PV panel for different environmental conditions:
Irradiance (G): 200, 400, 600, 800, 1000 W/m²
Temperature (T): 0°C, 25°C, 50°C
3. Current model status
The Simulink PV model includes:
Computation of Iph, Irs, I0
Equivalent PV cell circuit
Buck-Boost converter with MPPT and PWM control
Time-based curves: Pin(t), Pout(t)Inputs: Irradiance (G), Temperature (T)However, it does not currently output I–V or P–V curves directly.
4. Issues encountered
No direct I–V and P–V output
No voltage sweep mechanism to generate these curves
No variation tracking across different G and T conditions
5. Request for help
I’d appreciate guidance on how to:
Add a voltage sweep mechanism (controlled voltage source) to the PV model
Automatically extract I–V and P–V curves for different G and T values
Create a simulation script that loops over multiple irradiance and temperature settings
Export the results (ideally to .mat or .csv)
Thank you in advance for any suggestions or shared examples! photovoltaic panel, current, voltage, power, scope MATLAB Answers — New Questions
Break in and break away points on Root Locus
Hi,
I’m busy developing a controller, but for some reason my plot does not cut through the real axis and I’m not able to find the locations where the damping ratio is 0.59.
Herewith the code, block diagram and RLocus plot:
G=tf([0.151 0.1774], [1 0.739 0.921 0.25])
rlocus(G)
Any assistance will be appreciated.
Thanks
NielHi,
I’m busy developing a controller, but for some reason my plot does not cut through the real axis and I’m not able to find the locations where the damping ratio is 0.59.
Herewith the code, block diagram and RLocus plot:
G=tf([0.151 0.1774], [1 0.739 0.921 0.25])
rlocus(G)
Any assistance will be appreciated.
Thanks
Niel Hi,
I’m busy developing a controller, but for some reason my plot does not cut through the real axis and I’m not able to find the locations where the damping ratio is 0.59.
Herewith the code, block diagram and RLocus plot:
G=tf([0.151 0.1774], [1 0.739 0.921 0.25])
rlocus(G)
Any assistance will be appreciated.
Thanks
Niel matlab, root locus MATLAB Answers — New Questions
External Mode Connection Issue with C2000 LaunchPad and Speedgoat System
Dear MathWorks Support Team,
I am reaching out to request your assistance with an issue we are facing during the implementation of a controller model using the C2000 Blockset. As advised by Speedgoat support, this problem appears to be related to the C2000 Blockset, and they have recommended that we consult you directly.
Project Setup Overview:
We are working with two models:
Plant model – implemented on the Speedgoat FPGA
Controller model – implemented on a LaunchPad development kit (https://www.speedgoat.com/products/launchpad-development-kit) (TI LaunchXL-F28379D)
The two systems communicate via analog signals using the IO334 interface.
We have successfully confirmed the following:
The plant model is transmitting correct signals to the LaunchPad, verified using an oscilloscope via SMA connectors on the LaunchPad.
The LaunchPad receives the input signals correctly.
The plant model is also responding correctly when tested with a signal generator.
Issue Description:
The controller model builds, deploys, and starts successfully on the LaunchPad. However, when we attempt to use Monitor & Tune (external mode), we encounter the following error:
"External Mode Open Protocol Connect command failed: Could not connect to target application. XCP internal error: timeout expired."
We have attached relevant screenshots and the build report for your review.
Setup Details:
The LaunchPad is connected to the PC via USB.
It is also connected to the Speedgoat system via the SAMTEC connector.
We have used the blocks recommended in the documentation for the LaunchPad.
We would greatly appreciate your help in identifying the cause of this issue and guiding us through any additional steps or configurations needed to enable external mode communication.
Thank you very much for your support.
Best regards,
Varun ShahiDear MathWorks Support Team,
I am reaching out to request your assistance with an issue we are facing during the implementation of a controller model using the C2000 Blockset. As advised by Speedgoat support, this problem appears to be related to the C2000 Blockset, and they have recommended that we consult you directly.
Project Setup Overview:
We are working with two models:
Plant model – implemented on the Speedgoat FPGA
Controller model – implemented on a LaunchPad development kit (https://www.speedgoat.com/products/launchpad-development-kit) (TI LaunchXL-F28379D)
The two systems communicate via analog signals using the IO334 interface.
We have successfully confirmed the following:
The plant model is transmitting correct signals to the LaunchPad, verified using an oscilloscope via SMA connectors on the LaunchPad.
The LaunchPad receives the input signals correctly.
The plant model is also responding correctly when tested with a signal generator.
Issue Description:
The controller model builds, deploys, and starts successfully on the LaunchPad. However, when we attempt to use Monitor & Tune (external mode), we encounter the following error:
"External Mode Open Protocol Connect command failed: Could not connect to target application. XCP internal error: timeout expired."
We have attached relevant screenshots and the build report for your review.
Setup Details:
The LaunchPad is connected to the PC via USB.
It is also connected to the Speedgoat system via the SAMTEC connector.
We have used the blocks recommended in the documentation for the LaunchPad.
We would greatly appreciate your help in identifying the cause of this issue and guiding us through any additional steps or configurations needed to enable external mode communication.
Thank you very much for your support.
Best regards,
Varun Shahi Dear MathWorks Support Team,
I am reaching out to request your assistance with an issue we are facing during the implementation of a controller model using the C2000 Blockset. As advised by Speedgoat support, this problem appears to be related to the C2000 Blockset, and they have recommended that we consult you directly.
Project Setup Overview:
We are working with two models:
Plant model – implemented on the Speedgoat FPGA
Controller model – implemented on a LaunchPad development kit (https://www.speedgoat.com/products/launchpad-development-kit) (TI LaunchXL-F28379D)
The two systems communicate via analog signals using the IO334 interface.
We have successfully confirmed the following:
The plant model is transmitting correct signals to the LaunchPad, verified using an oscilloscope via SMA connectors on the LaunchPad.
The LaunchPad receives the input signals correctly.
The plant model is also responding correctly when tested with a signal generator.
Issue Description:
The controller model builds, deploys, and starts successfully on the LaunchPad. However, when we attempt to use Monitor & Tune (external mode), we encounter the following error:
"External Mode Open Protocol Connect command failed: Could not connect to target application. XCP internal error: timeout expired."
We have attached relevant screenshots and the build report for your review.
Setup Details:
The LaunchPad is connected to the PC via USB.
It is also connected to the Speedgoat system via the SAMTEC connector.
We have used the blocks recommended in the documentation for the LaunchPad.
We would greatly appreciate your help in identifying the cause of this issue and guiding us through any additional steps or configurations needed to enable external mode communication.
Thank you very much for your support.
Best regards,
Varun Shahi c2000 blockset issue MATLAB Answers — New Questions
how to validate mscohere?
I would like to validate the use of mscohere for impact test data, using an instrumented hammer that measures force and an accelerometer to measure response. I ran some artificial cases – see attached pdf. Single input, single output. I tried to force mscohere to use only 3 windows of data, one for each impact test. The first half of results are for sinusoidal input and output, and the second half are for a simulated impact input. There are 2 time domain plots in there. The inputs are the 3 input vectors stacked vertically, and the 3 output vectors stacked vertically. Sample rate is 1000 Hz, with a 4 second window and 0.25 Hz resolution. I am using a rectangular window:
[coherence, frequencies2] = mscohere(coherenceInput, coherenceOutput, rectwin(windowLength), 0, windowLength, sampleRateHz);
The results look about right to me, but I would like to validate it against some known or anlytical results. Are there any suitable examples available?
Also, how do I check that it is getting the absolute basics right – for example, is it using the 3 windows of data that I want it to use?I would like to validate the use of mscohere for impact test data, using an instrumented hammer that measures force and an accelerometer to measure response. I ran some artificial cases – see attached pdf. Single input, single output. I tried to force mscohere to use only 3 windows of data, one for each impact test. The first half of results are for sinusoidal input and output, and the second half are for a simulated impact input. There are 2 time domain plots in there. The inputs are the 3 input vectors stacked vertically, and the 3 output vectors stacked vertically. Sample rate is 1000 Hz, with a 4 second window and 0.25 Hz resolution. I am using a rectangular window:
[coherence, frequencies2] = mscohere(coherenceInput, coherenceOutput, rectwin(windowLength), 0, windowLength, sampleRateHz);
The results look about right to me, but I would like to validate it against some known or anlytical results. Are there any suitable examples available?
Also, how do I check that it is getting the absolute basics right – for example, is it using the 3 windows of data that I want it to use? I would like to validate the use of mscohere for impact test data, using an instrumented hammer that measures force and an accelerometer to measure response. I ran some artificial cases – see attached pdf. Single input, single output. I tried to force mscohere to use only 3 windows of data, one for each impact test. The first half of results are for sinusoidal input and output, and the second half are for a simulated impact input. There are 2 time domain plots in there. The inputs are the 3 input vectors stacked vertically, and the 3 output vectors stacked vertically. Sample rate is 1000 Hz, with a 4 second window and 0.25 Hz resolution. I am using a rectangular window:
[coherence, frequencies2] = mscohere(coherenceInput, coherenceOutput, rectwin(windowLength), 0, windowLength, sampleRateHz);
The results look about right to me, but I would like to validate it against some known or anlytical results. Are there any suitable examples available?
Also, how do I check that it is getting the absolute basics right – for example, is it using the 3 windows of data that I want it to use? mscohere MATLAB Answers — New Questions
Transfer history to MATLAB 2025a
Hi everybody.
I bought a new computer and I want to transfer the MATLAB history I had on the old one. The new computer has MATLAB 2025a installed, while the old one has MATLAB 2024b.
I already transfer histories in the past and it was as simple as copy and paste the History.xml from a computer to another. However, with MATLAB 2025a, history is no longer saved in the History.xml. How can I transfer the command history from the old computer (and MATLAB 2024b) to the new one with MATLAB 2025a?Hi everybody.
I bought a new computer and I want to transfer the MATLAB history I had on the old one. The new computer has MATLAB 2025a installed, while the old one has MATLAB 2024b.
I already transfer histories in the past and it was as simple as copy and paste the History.xml from a computer to another. However, with MATLAB 2025a, history is no longer saved in the History.xml. How can I transfer the command history from the old computer (and MATLAB 2024b) to the new one with MATLAB 2025a? Hi everybody.
I bought a new computer and I want to transfer the MATLAB history I had on the old one. The new computer has MATLAB 2025a installed, while the old one has MATLAB 2024b.
I already transfer histories in the past and it was as simple as copy and paste the History.xml from a computer to another. However, with MATLAB 2025a, history is no longer saved in the History.xml. How can I transfer the command history from the old computer (and MATLAB 2024b) to the new one with MATLAB 2025a? matlab MATLAB Answers — New Questions
Constraints to a Second Order Curve Fit
Given this set of data, is it possible to perform a 2nd order curve fit with the set constraint that the leading coefficient must be positive? Using an unconstrained curve fit (both "polyfit" and "fit" were used), the data produces a curve with a rather small negative leading coefficient. For reference, the data is as follows:
x = 150, 190, 400, 330, 115, 494
y = 1537, 1784, 3438, 2943, 1175, 4203
The given outputs using both methods largely agreed, as shown below:
fit_eq =
-0.0007 8.3119 255.8074
eq =
Linear model Poly2:
eq(x) = p1*x^2 + p2*x + p3
Coefficients (with 95% confidence bounds):
p1 = -0.0007088 (-0.003588, 0.00217)
p2 = 8.312 (6.51, 10.11)
p3 = 255.8 (25.01, 486.6)Given this set of data, is it possible to perform a 2nd order curve fit with the set constraint that the leading coefficient must be positive? Using an unconstrained curve fit (both "polyfit" and "fit" were used), the data produces a curve with a rather small negative leading coefficient. For reference, the data is as follows:
x = 150, 190, 400, 330, 115, 494
y = 1537, 1784, 3438, 2943, 1175, 4203
The given outputs using both methods largely agreed, as shown below:
fit_eq =
-0.0007 8.3119 255.8074
eq =
Linear model Poly2:
eq(x) = p1*x^2 + p2*x + p3
Coefficients (with 95% confidence bounds):
p1 = -0.0007088 (-0.003588, 0.00217)
p2 = 8.312 (6.51, 10.11)
p3 = 255.8 (25.01, 486.6) Given this set of data, is it possible to perform a 2nd order curve fit with the set constraint that the leading coefficient must be positive? Using an unconstrained curve fit (both "polyfit" and "fit" were used), the data produces a curve with a rather small negative leading coefficient. For reference, the data is as follows:
x = 150, 190, 400, 330, 115, 494
y = 1537, 1784, 3438, 2943, 1175, 4203
The given outputs using both methods largely agreed, as shown below:
fit_eq =
-0.0007 8.3119 255.8074
eq =
Linear model Poly2:
eq(x) = p1*x^2 + p2*x + p3
Coefficients (with 95% confidence bounds):
p1 = -0.0007088 (-0.003588, 0.00217)
p2 = 8.312 (6.51, 10.11)
p3 = 255.8 (25.01, 486.6) curve fitting, matlab, polyfit MATLAB Answers — New Questions
S curve ramp function
I need help creating a function for an s curve ramp. The code below will create the inserted picture below. However, this code only works for a constant ramp block (connected to x). This code from the piecewise function on the Matlab smf() help file page.
I need two additional inputs (acceleration rate and jerk rate). The output should ramp the input velocity (x) signal based on the acceleration rate (a), and jerk rate (j). I need the block or code to be dynamic. I do not want to put a time value inside of my code. I will be exporting the code to structure text and input the code into a Siemens PLC.
I don’t want to include a fixed dt in my code because I will be running the code in a PLC. Maybe it would be better to design this function in simulink and set a fixed time solver and use integrator blocks?
x = 0:0.01:10; % domain
a = 1; % unsaturated interval’s left endpoint
b = 8; % unsaturated interval’s right endpoint
y = smf(x, a, b);
plot(x, y), grid on
xline(a, ‘–‘)
xline(b, ‘–‘)
title("S-curve piecewise function")
xlabel("x")
ylabel("Amplitude")
ylim([-0.05 1.05])
%% S-curve piecewise function
function y = smf(x, a, b)
m = (a + b)/2;
y = (x > a & x <= m) .* ( 2*((x-a)/(b-a)).^2) + …
(x > m & x <= b) .* (1-2*((x-b)/(b-a)).^2) + …
(x > b);
endI need help creating a function for an s curve ramp. The code below will create the inserted picture below. However, this code only works for a constant ramp block (connected to x). This code from the piecewise function on the Matlab smf() help file page.
I need two additional inputs (acceleration rate and jerk rate). The output should ramp the input velocity (x) signal based on the acceleration rate (a), and jerk rate (j). I need the block or code to be dynamic. I do not want to put a time value inside of my code. I will be exporting the code to structure text and input the code into a Siemens PLC.
I don’t want to include a fixed dt in my code because I will be running the code in a PLC. Maybe it would be better to design this function in simulink and set a fixed time solver and use integrator blocks?
x = 0:0.01:10; % domain
a = 1; % unsaturated interval’s left endpoint
b = 8; % unsaturated interval’s right endpoint
y = smf(x, a, b);
plot(x, y), grid on
xline(a, ‘–‘)
xline(b, ‘–‘)
title("S-curve piecewise function")
xlabel("x")
ylabel("Amplitude")
ylim([-0.05 1.05])
%% S-curve piecewise function
function y = smf(x, a, b)
m = (a + b)/2;
y = (x > a & x <= m) .* ( 2*((x-a)/(b-a)).^2) + …
(x > m & x <= b) .* (1-2*((x-b)/(b-a)).^2) + …
(x > b);
end I need help creating a function for an s curve ramp. The code below will create the inserted picture below. However, this code only works for a constant ramp block (connected to x). This code from the piecewise function on the Matlab smf() help file page.
I need two additional inputs (acceleration rate and jerk rate). The output should ramp the input velocity (x) signal based on the acceleration rate (a), and jerk rate (j). I need the block or code to be dynamic. I do not want to put a time value inside of my code. I will be exporting the code to structure text and input the code into a Siemens PLC.
I don’t want to include a fixed dt in my code because I will be running the code in a PLC. Maybe it would be better to design this function in simulink and set a fixed time solver and use integrator blocks?
x = 0:0.01:10; % domain
a = 1; % unsaturated interval’s left endpoint
b = 8; % unsaturated interval’s right endpoint
y = smf(x, a, b);
plot(x, y), grid on
xline(a, ‘–‘)
xline(b, ‘–‘)
title("S-curve piecewise function")
xlabel("x")
ylabel("Amplitude")
ylim([-0.05 1.05])
%% S-curve piecewise function
function y = smf(x, a, b)
m = (a + b)/2;
y = (x > a & x <= m) .* ( 2*((x-a)/(b-a)).^2) + …
(x > m & x <= b) .* (1-2*((x-b)/(b-a)).^2) + …
(x > b);
end s curve MATLAB Answers — New Questions
How to create excel sheet for developed model using MATLAB
I have subsystem which is having few input/output. I want to do testing using excel sheet.
How to create excel using script which generate input and output inside excel.
or any other way to test the model.
Please let me know the solutionI have subsystem which is having few input/output. I want to do testing using excel sheet.
How to create excel using script which generate input and output inside excel.
or any other way to test the model.
Please let me know the solution I have subsystem which is having few input/output. I want to do testing using excel sheet.
How to create excel using script which generate input and output inside excel.
or any other way to test the model.
Please let me know the solution importing excel data, testing, mil, matlab MATLAB Answers — New Questions
How to express constants of integral
Hi everyone,
I am a matlab beginner. How can I find the constants of integral C1 and C2 ?
For example i know that, how can i find constants of integral C1 and C2 in this script? Thanks 🙂
syms x
y1 = exp(-2*x+sqrt(6)*x);
y2 = exp(-2*x-sqrt(6)*x);
g = 2*x^2-3*x+6;
A = [y1 y2;diff(y1,x) diff(y2,x)]
b = [0; g]
Ab
u = simplify(Ab)
u = int(u,x)
simplify(u)Hi everyone,
I am a matlab beginner. How can I find the constants of integral C1 and C2 ?
For example i know that, how can i find constants of integral C1 and C2 in this script? Thanks 🙂
syms x
y1 = exp(-2*x+sqrt(6)*x);
y2 = exp(-2*x-sqrt(6)*x);
g = 2*x^2-3*x+6;
A = [y1 y2;diff(y1,x) diff(y2,x)]
b = [0; g]
Ab
u = simplify(Ab)
u = int(u,x)
simplify(u) Hi everyone,
I am a matlab beginner. How can I find the constants of integral C1 and C2 ?
For example i know that, how can i find constants of integral C1 and C2 in this script? Thanks 🙂
syms x
y1 = exp(-2*x+sqrt(6)*x);
y2 = exp(-2*x-sqrt(6)*x);
g = 2*x^2-3*x+6;
A = [y1 y2;diff(y1,x) diff(y2,x)]
b = [0; g]
Ab
u = simplify(Ab)
u = int(u,x)
simplify(u) integral, constants of integral MATLAB Answers — New Questions
2019b download installer
I need to download 2019 version of Matlab for my macbook pro 10.13.6. How can I download it. ThanksI need to download 2019 version of Matlab for my macbook pro 10.13.6. How can I download it. Thanks I need to download 2019 version of Matlab for my macbook pro 10.13.6. How can I download it. Thanks matlab MATLAB Answers — New Questions
I want to build a double pendulum system in Simulink but am getting errors relating to the tolerance and step size
How do I solve this coupled second order differential equation.
Errors:
Right now it uses ode45 to solve it but I have tried every model, added the memory block, changed the initial conditions to be smaller, changed the max step size and relative errors but nothing works.How do I solve this coupled second order differential equation.
Errors:
Right now it uses ode45 to solve it but I have tried every model, added the memory block, changed the initial conditions to be smaller, changed the max step size and relative errors but nothing works. How do I solve this coupled second order differential equation.
Errors:
Right now it uses ode45 to solve it but I have tried every model, added the memory block, changed the initial conditions to be smaller, changed the max step size and relative errors but nothing works. stepsize, ode45, ode, differential equations, simulink, matlab MATLAB Answers — New Questions
How to model a simple brake in Simscape (mechanical rotational domain)?
Hello, I am currently trying to model a simple brake in Simscape in the mechanical rotational domain.
The input to the block should be pressure.
The braking torque should increase linearly between the following points:0 bar = 0 Nm1 bar = 10 Nm
Is such a block available in the foundation library?
Would it be possible to implement such a component as a custom Simscape component?Hello, I am currently trying to model a simple brake in Simscape in the mechanical rotational domain.
The input to the block should be pressure.
The braking torque should increase linearly between the following points:0 bar = 0 Nm1 bar = 10 Nm
Is such a block available in the foundation library?
Would it be possible to implement such a component as a custom Simscape component? Hello, I am currently trying to model a simple brake in Simscape in the mechanical rotational domain.
The input to the block should be pressure.
The braking torque should increase linearly between the following points:0 bar = 0 Nm1 bar = 10 Nm
Is such a block available in the foundation library?
Would it be possible to implement such a component as a custom Simscape component? MATLAB Answers — New Questions
How to debug C# .NET assembly called from MATLAB?
I’m trying to use some .NET assemblies from MATLAB but I am encountering a MATLAB System Error.
I was wondering if there is some additional debug logs I can turn on to see the details of the system error to determine what in my .NET assembly might be causing the crash.I’m trying to use some .NET assemblies from MATLAB but I am encountering a MATLAB System Error.
I was wondering if there is some additional debug logs I can turn on to see the details of the system error to determine what in my .NET assembly might be causing the crash. I’m trying to use some .NET assemblies from MATLAB but I am encountering a MATLAB System Error.
I was wondering if there is some additional debug logs I can turn on to see the details of the system error to determine what in my .NET assembly might be causing the crash. MATLAB Answers — New Questions
How do I set the size of a tile from tiledlayout?
I am producing a number of figures with a different number of tiles from tiledlayout. I’d like to make sure all tiles are the same size across the figures. I have only found options to set the figure size. This is problematic since I have to change the figure size every time the number of tiles changes.I am producing a number of figures with a different number of tiles from tiledlayout. I’d like to make sure all tiles are the same size across the figures. I have only found options to set the figure size. This is problematic since I have to change the figure size every time the number of tiles changes. I am producing a number of figures with a different number of tiles from tiledlayout. I’d like to make sure all tiles are the same size across the figures. I have only found options to set the figure size. This is problematic since I have to change the figure size every time the number of tiles changes. tiledlayout, plotting MATLAB Answers — New Questions