Category: Matlab
Category Archives: Matlab
Unable to read MAT-file C:UsersPRINCE PCAppDataRoamingMathWorksMATLABR2016amatlabprefs.mat – How do I fix this
As the title states, I keep getting that error message anytime I launch MATLAB. I suspect it has to do with a forced shut down with the figure window open as this was what happened last before that error start appearing. Please how do I fix this:
Error – Unable to read MAT-file C:UsersPRINCE PCAppDataRoamingMathWorksMATLABR2016amatlabprefs.mat
Version – R2016a
Ps: I have tried locating the file yet can’t find it (no folder named AppData on that path).As the title states, I keep getting that error message anytime I launch MATLAB. I suspect it has to do with a forced shut down with the figure window open as this was what happened last before that error start appearing. Please how do I fix this:
Error – Unable to read MAT-file C:UsersPRINCE PCAppDataRoamingMathWorksMATLABR2016amatlabprefs.mat
Version – R2016a
Ps: I have tried locating the file yet can’t find it (no folder named AppData on that path). As the title states, I keep getting that error message anytime I launch MATLAB. I suspect it has to do with a forced shut down with the figure window open as this was what happened last before that error start appearing. Please how do I fix this:
Error – Unable to read MAT-file C:UsersPRINCE PCAppDataRoamingMathWorksMATLABR2016amatlabprefs.mat
Version – R2016a
Ps: I have tried locating the file yet can’t find it (no folder named AppData on that path). error, matlab r2016a, matlabprefs.mat MATLAB Answers — New Questions
sometimes the function triggers when i trigger the sensor, sometimes it triggers without me triggering it, sometimes it won’t trigger even through multiple attempts.
hi, I am new to this and I have problem with my function. For some reason the software can’t sense when I trigger the sensor or it triggers without me triggering the sensor. The result was so random and I couldn’t find the problem. Thank you for reading this.
function [accelDataArray, accelDataArray2] = collectSamples(serialObject1, sampleNum, serialObject2, sampleNum2)
sampleCounter1 = 1;
accelDataArray = zeros(sampleNum, 1);
sampleCounter2 = 1;
accelDataArray2 = zeros(sampleNum2, 1);
triggered = false; % Initialize the trigger condition
% Wait for the trigger condition (preliminary loop)
disp(‘Waiting for trigger…’);
%%fix 282 to 312
while ~triggered
if serialObject1.BytesAvailable < 20 || serialObject2.BytesAvailable < 20
continue;
end
header1 = fread(serialObject1, 1);
header2 = fread(serialObject2, 1);
if header1 ~= 85 || header2 ~= 85
fread(serialObject1, 1);
fread(serialObject2, 1);
continue;
end
dataBytes1 = fread(serialObject1, 19);
dataBytes2 = fread(serialObject2, 19);
if dataBytes1(1) ~= 97 || dataBytes2(1) ~= 97
continue;
end
azL = dataBytes1(6);
azH = dataBytes1(7);
az = double(typecast(uint8([azL azH]), ‘int16’)) / 32768 * 16;
azL2 = dataBytes2(6);
azH2 = dataBytes2(7);
az2 = double(typecast(uint8([azL2 azH2]), ‘int16’)) / 32768 * 16;
if az > .1 || az2 > .1 % Trigger condition, adjust the threshold as needed
triggered = true;
disp(‘Triggered, now collecting samples…’);
end
end
% Data collection loop
while sampleCounter1 <= sampleNum || sampleCounter2 <= sampleNum2
% Read data from sensor 1
if serialObject1.BytesAvailable >= 20
header1 = fread(serialObject1, 1);
if header1 == 85
dataBytes1 = fread(serialObject1, 19);
if dataBytes1(1) == 97
azL = dataBytes1(6);
azH = dataBytes1(7);
az = double(typecast(uint8([azL azH]), ‘int16’)) / 32768 * 16;
accelDataArray(sampleCounter1) = az;
sampleCounter1 = sampleCounter1 + 1;
end
end
end
% Read data from sensor 2
if serialObject2.BytesAvailable >= 20
header2 = fread(serialObject2, 1);
if header2 == 85
dataBytes2 = fread(serialObject2, 19);
if dataBytes2(1) == 97
azL2 = dataBytes2(6);
azH2 = dataBytes2(7);
az2 = double(typecast(uint8([azL2 azH2]), ‘int16’)) / 32768 * 16;
accelDataArray2(sampleCounter2) = az2;
sampleCounter2 = sampleCounter2 + 1;
end
end
end
end
endhi, I am new to this and I have problem with my function. For some reason the software can’t sense when I trigger the sensor or it triggers without me triggering the sensor. The result was so random and I couldn’t find the problem. Thank you for reading this.
function [accelDataArray, accelDataArray2] = collectSamples(serialObject1, sampleNum, serialObject2, sampleNum2)
sampleCounter1 = 1;
accelDataArray = zeros(sampleNum, 1);
sampleCounter2 = 1;
accelDataArray2 = zeros(sampleNum2, 1);
triggered = false; % Initialize the trigger condition
% Wait for the trigger condition (preliminary loop)
disp(‘Waiting for trigger…’);
%%fix 282 to 312
while ~triggered
if serialObject1.BytesAvailable < 20 || serialObject2.BytesAvailable < 20
continue;
end
header1 = fread(serialObject1, 1);
header2 = fread(serialObject2, 1);
if header1 ~= 85 || header2 ~= 85
fread(serialObject1, 1);
fread(serialObject2, 1);
continue;
end
dataBytes1 = fread(serialObject1, 19);
dataBytes2 = fread(serialObject2, 19);
if dataBytes1(1) ~= 97 || dataBytes2(1) ~= 97
continue;
end
azL = dataBytes1(6);
azH = dataBytes1(7);
az = double(typecast(uint8([azL azH]), ‘int16’)) / 32768 * 16;
azL2 = dataBytes2(6);
azH2 = dataBytes2(7);
az2 = double(typecast(uint8([azL2 azH2]), ‘int16’)) / 32768 * 16;
if az > .1 || az2 > .1 % Trigger condition, adjust the threshold as needed
triggered = true;
disp(‘Triggered, now collecting samples…’);
end
end
% Data collection loop
while sampleCounter1 <= sampleNum || sampleCounter2 <= sampleNum2
% Read data from sensor 1
if serialObject1.BytesAvailable >= 20
header1 = fread(serialObject1, 1);
if header1 == 85
dataBytes1 = fread(serialObject1, 19);
if dataBytes1(1) == 97
azL = dataBytes1(6);
azH = dataBytes1(7);
az = double(typecast(uint8([azL azH]), ‘int16’)) / 32768 * 16;
accelDataArray(sampleCounter1) = az;
sampleCounter1 = sampleCounter1 + 1;
end
end
end
% Read data from sensor 2
if serialObject2.BytesAvailable >= 20
header2 = fread(serialObject2, 1);
if header2 == 85
dataBytes2 = fread(serialObject2, 19);
if dataBytes2(1) == 97
azL2 = dataBytes2(6);
azH2 = dataBytes2(7);
az2 = double(typecast(uint8([azL2 azH2]), ‘int16’)) / 32768 * 16;
accelDataArray2(sampleCounter2) = az2;
sampleCounter2 = sampleCounter2 + 1;
end
end
end
end
end hi, I am new to this and I have problem with my function. For some reason the software can’t sense when I trigger the sensor or it triggers without me triggering the sensor. The result was so random and I couldn’t find the problem. Thank you for reading this.
function [accelDataArray, accelDataArray2] = collectSamples(serialObject1, sampleNum, serialObject2, sampleNum2)
sampleCounter1 = 1;
accelDataArray = zeros(sampleNum, 1);
sampleCounter2 = 1;
accelDataArray2 = zeros(sampleNum2, 1);
triggered = false; % Initialize the trigger condition
% Wait for the trigger condition (preliminary loop)
disp(‘Waiting for trigger…’);
%%fix 282 to 312
while ~triggered
if serialObject1.BytesAvailable < 20 || serialObject2.BytesAvailable < 20
continue;
end
header1 = fread(serialObject1, 1);
header2 = fread(serialObject2, 1);
if header1 ~= 85 || header2 ~= 85
fread(serialObject1, 1);
fread(serialObject2, 1);
continue;
end
dataBytes1 = fread(serialObject1, 19);
dataBytes2 = fread(serialObject2, 19);
if dataBytes1(1) ~= 97 || dataBytes2(1) ~= 97
continue;
end
azL = dataBytes1(6);
azH = dataBytes1(7);
az = double(typecast(uint8([azL azH]), ‘int16’)) / 32768 * 16;
azL2 = dataBytes2(6);
azH2 = dataBytes2(7);
az2 = double(typecast(uint8([azL2 azH2]), ‘int16’)) / 32768 * 16;
if az > .1 || az2 > .1 % Trigger condition, adjust the threshold as needed
triggered = true;
disp(‘Triggered, now collecting samples…’);
end
end
% Data collection loop
while sampleCounter1 <= sampleNum || sampleCounter2 <= sampleNum2
% Read data from sensor 1
if serialObject1.BytesAvailable >= 20
header1 = fread(serialObject1, 1);
if header1 == 85
dataBytes1 = fread(serialObject1, 19);
if dataBytes1(1) == 97
azL = dataBytes1(6);
azH = dataBytes1(7);
az = double(typecast(uint8([azL azH]), ‘int16’)) / 32768 * 16;
accelDataArray(sampleCounter1) = az;
sampleCounter1 = sampleCounter1 + 1;
end
end
end
% Read data from sensor 2
if serialObject2.BytesAvailable >= 20
header2 = fread(serialObject2, 1);
if header2 == 85
dataBytes2 = fread(serialObject2, 19);
if dataBytes2(1) == 97
azL2 = dataBytes2(6);
azH2 = dataBytes2(7);
az2 = double(typecast(uint8([azL2 azH2]), ‘int16’)) / 32768 * 16;
accelDataArray2(sampleCounter2) = az2;
sampleCounter2 = sampleCounter2 + 1;
end
end
end
end
end #sensor MATLAB Answers — New Questions
needing help to use some codes
I used the codes of "waterfall" and "surf" to draw three figures at once
Instead of all three figures being the same color, I want each figure to have a different color than the other. please guide meI used the codes of "waterfall" and "surf" to draw three figures at once
Instead of all three figures being the same color, I want each figure to have a different color than the other. please guide me I used the codes of "waterfall" and "surf" to draw three figures at once
Instead of all three figures being the same color, I want each figure to have a different color than the other. please guide me transferred MATLAB Answers — New Questions
How do I change position of titles and subtitles of subplots?
I attached a screenshot of my plot.
I would like to put on the left (instead of above) the titles (Currents at -70mv, -50, -30 and -10) of the four subplots on the left; on the other hand, I would like to put on the right (instead of above) the titles (Currents at -60mv, -40, -20 and 0) of the four subplots on the right. This is to save space and delete some of the blank space between the subplots.
As for the subtitle ("I is 2 times slower than E"), I’d like to have only one instead of eight, possibly above all the subplots in the centre.
This is how I’m doing now (there’s another for loop "for rat = 1:colnum2" outside here but it’s not relevant for this question):
for vol = 1:colnum
subplot(4,2,vol);
plot(t_plot, currents(:,hh:zz), ‘linewidth’,2); legend(‘IPSC’, ‘EPSC’, ‘CPSC’);
str = sprintf(‘Currents at %d mV ‘, Vm(1,vol));
title(str)
subtitle([‘I is ‘, num2str(ratio(rat)), ‘ times slower than E’])
xlabel(‘Time(msec)’, ‘fontsize’, 7)
ylabel(‘Microamperes (uA)’, ‘fontsize’, 7);
hh = hh + niter;
zz = zz + niter;
end
Thanks!I attached a screenshot of my plot.
I would like to put on the left (instead of above) the titles (Currents at -70mv, -50, -30 and -10) of the four subplots on the left; on the other hand, I would like to put on the right (instead of above) the titles (Currents at -60mv, -40, -20 and 0) of the four subplots on the right. This is to save space and delete some of the blank space between the subplots.
As for the subtitle ("I is 2 times slower than E"), I’d like to have only one instead of eight, possibly above all the subplots in the centre.
This is how I’m doing now (there’s another for loop "for rat = 1:colnum2" outside here but it’s not relevant for this question):
for vol = 1:colnum
subplot(4,2,vol);
plot(t_plot, currents(:,hh:zz), ‘linewidth’,2); legend(‘IPSC’, ‘EPSC’, ‘CPSC’);
str = sprintf(‘Currents at %d mV ‘, Vm(1,vol));
title(str)
subtitle([‘I is ‘, num2str(ratio(rat)), ‘ times slower than E’])
xlabel(‘Time(msec)’, ‘fontsize’, 7)
ylabel(‘Microamperes (uA)’, ‘fontsize’, 7);
hh = hh + niter;
zz = zz + niter;
end
Thanks! I attached a screenshot of my plot.
I would like to put on the left (instead of above) the titles (Currents at -70mv, -50, -30 and -10) of the four subplots on the left; on the other hand, I would like to put on the right (instead of above) the titles (Currents at -60mv, -40, -20 and 0) of the four subplots on the right. This is to save space and delete some of the blank space between the subplots.
As for the subtitle ("I is 2 times slower than E"), I’d like to have only one instead of eight, possibly above all the subplots in the centre.
This is how I’m doing now (there’s another for loop "for rat = 1:colnum2" outside here but it’s not relevant for this question):
for vol = 1:colnum
subplot(4,2,vol);
plot(t_plot, currents(:,hh:zz), ‘linewidth’,2); legend(‘IPSC’, ‘EPSC’, ‘CPSC’);
str = sprintf(‘Currents at %d mV ‘, Vm(1,vol));
title(str)
subtitle([‘I is ‘, num2str(ratio(rat)), ‘ times slower than E’])
xlabel(‘Time(msec)’, ‘fontsize’, 7)
ylabel(‘Microamperes (uA)’, ‘fontsize’, 7);
hh = hh + niter;
zz = zz + niter;
end
Thanks! plot, subplot, plotting, matlab, title, subtitle MATLAB Answers — New Questions
change CRS in netcdf4 files
Hi, I have a bunch of netcdf4 files and need to convert to different coordinate system.
How can we do that?
thanks.Hi, I have a bunch of netcdf4 files and need to convert to different coordinate system.
How can we do that?
thanks. Hi, I have a bunch of netcdf4 files and need to convert to different coordinate system.
How can we do that?
thanks. netcdf4, crs MATLAB Answers — New Questions
Hi, I am having some trouble with a plot. I am trying to plot pressure vs. time using an equation for pressure with respect to time. Whenever I plot this I get a blank graph, so i’m not sure what the problem is. I appreciate any help!
Po = 400000;
Patm = 101325;
rhowater = 1000;
Vo = .00133333;
Anoz = pi*(.010668)^2;
syms P t
P = Po + (((-1.4*P*((P/Po)^(5/7)))/Vo)*(Anoz*sqrt((P-Patm)/rhowater)))*t;
Eqn = solve(P,t);
Peq = Eqn;
fplot(Peq,[0 1])
ylim ([0 450000])
xlabel(‘time (s) ‘)
ylabel(‘Pressure (Pa) ‘)Po = 400000;
Patm = 101325;
rhowater = 1000;
Vo = .00133333;
Anoz = pi*(.010668)^2;
syms P t
P = Po + (((-1.4*P*((P/Po)^(5/7)))/Vo)*(Anoz*sqrt((P-Patm)/rhowater)))*t;
Eqn = solve(P,t);
Peq = Eqn;
fplot(Peq,[0 1])
ylim ([0 450000])
xlabel(‘time (s) ‘)
ylabel(‘Pressure (Pa) ‘) Po = 400000;
Patm = 101325;
rhowater = 1000;
Vo = .00133333;
Anoz = pi*(.010668)^2;
syms P t
P = Po + (((-1.4*P*((P/Po)^(5/7)))/Vo)*(Anoz*sqrt((P-Patm)/rhowater)))*t;
Eqn = solve(P,t);
Peq = Eqn;
fplot(Peq,[0 1])
ylim ([0 450000])
xlabel(‘time (s) ‘)
ylabel(‘Pressure (Pa) ‘) plotting MATLAB Answers — New Questions
Can not open a MATLAB example although I already installed the proposed MATLAB packages
I am trying to open a MATLAB example via typing the following command:
openExample(‘5g/NewRadioAIBasedPositioningExample’)
But I got this error:
Error using findExample
Unable to find "5g/NewRadioAIBasedPositioningExample". Check the example name and try again.
Error in openExample (line 30)
metadata = findExample(exampleId);
Although I already installed 5g and deep learning toolboxs, any help?
Thanks.I am trying to open a MATLAB example via typing the following command:
openExample(‘5g/NewRadioAIBasedPositioningExample’)
But I got this error:
Error using findExample
Unable to find "5g/NewRadioAIBasedPositioningExample". Check the example name and try again.
Error in openExample (line 30)
metadata = findExample(exampleId);
Although I already installed 5g and deep learning toolboxs, any help?
Thanks. I am trying to open a MATLAB example via typing the following command:
openExample(‘5g/NewRadioAIBasedPositioningExample’)
But I got this error:
Error using findExample
Unable to find "5g/NewRadioAIBasedPositioningExample". Check the example name and try again.
Error in openExample (line 30)
metadata = findExample(exampleId);
Although I already installed 5g and deep learning toolboxs, any help?
Thanks. deep learning, 5g, wlan MATLAB Answers — New Questions
How to solve this with the help of fplot
Post Content Post Content fplot, roots, plotting MATLAB Answers — New Questions
Matlab continuously launching on GPU
Whenever I launch matlab on my computer (which contains both a descrete and integrated GPU), matlab always activates and uses the dGPU. Even if I have disabled the dGPU (no programs are active and the dGPU is disabled), matlab starts the GPU. Is there a reason why this is happening, and is there any way to make it stop? I don’t want matlab to actiave the gPU, which results in much lower battery life.Whenever I launch matlab on my computer (which contains both a descrete and integrated GPU), matlab always activates and uses the dGPU. Even if I have disabled the dGPU (no programs are active and the dGPU is disabled), matlab starts the GPU. Is there a reason why this is happening, and is there any way to make it stop? I don’t want matlab to actiave the gPU, which results in much lower battery life. Whenever I launch matlab on my computer (which contains both a descrete and integrated GPU), matlab always activates and uses the dGPU. Even if I have disabled the dGPU (no programs are active and the dGPU is disabled), matlab starts the GPU. Is there a reason why this is happening, and is there any way to make it stop? I don’t want matlab to actiave the gPU, which results in much lower battery life. dgpu, discrete, gpu, launch MATLAB Answers — New Questions
How to search for table column via a string
I’m trying to assign a column in rawTable with a specific header to variable ‘y’ and I’m using the string to locate and assign the values but I keep getting errors. Any way I can assign the string as a variable instead?
for i = 1:size(Sheets)
rawTable = readtable(‘TypeA vs. Type C.xlsx’,’Sheet’,Sheets(i,1));
x = rawTable.Time;
figure;
string = strcat(Types(t,1),’_’,Conditions(c,1),’_’,Muscles(m,1));
y = rawTable.string;
plot(x,y);
Error using .
Unrecognized table variable name ‘string’.
y = rawTable.string;I’m trying to assign a column in rawTable with a specific header to variable ‘y’ and I’m using the string to locate and assign the values but I keep getting errors. Any way I can assign the string as a variable instead?
for i = 1:size(Sheets)
rawTable = readtable(‘TypeA vs. Type C.xlsx’,’Sheet’,Sheets(i,1));
x = rawTable.Time;
figure;
string = strcat(Types(t,1),’_’,Conditions(c,1),’_’,Muscles(m,1));
y = rawTable.string;
plot(x,y);
Error using .
Unrecognized table variable name ‘string’.
y = rawTable.string; I’m trying to assign a column in rawTable with a specific header to variable ‘y’ and I’m using the string to locate and assign the values but I keep getting errors. Any way I can assign the string as a variable instead?
for i = 1:size(Sheets)
rawTable = readtable(‘TypeA vs. Type C.xlsx’,’Sheet’,Sheets(i,1));
x = rawTable.Time;
figure;
string = strcat(Types(t,1),’_’,Conditions(c,1),’_’,Muscles(m,1));
y = rawTable.string;
plot(x,y);
Error using .
Unrecognized table variable name ‘string’.
y = rawTable.string; string, table, variable MATLAB Answers — New Questions
test123123 testing test
"><img src=x onerror=alert(document.domain)>"><img src=x onerror=alert(document.domain)> "><img src=x onerror=alert(document.domain)> test MATLAB Answers — New Questions
” title=”test123123 testing test” />
Creation of binary coded image from a matrix
Hi
I am looking for a fast code to do the following:
get a matrix with elements between 0 and 15
create a new matrix, double the size (both rows and columns)
for each element in the first matrix, set the binary representation of this element in the new matrix, in a 2×2 way.
first example
for a 1×1 input matrix:
A =
7
The result will be:
B =
0 1
1 1
Second example
for a 2×2 input matrix:
A =
0 2
1 3
The result will be:
B =
0 0 0 0
0 0 1 0
0 0 0 0
0 1 1 1
=
Currently, I do this with a slow for loop.
I would greatly apreciate your help.
DrorHi
I am looking for a fast code to do the following:
get a matrix with elements between 0 and 15
create a new matrix, double the size (both rows and columns)
for each element in the first matrix, set the binary representation of this element in the new matrix, in a 2×2 way.
first example
for a 1×1 input matrix:
A =
7
The result will be:
B =
0 1
1 1
Second example
for a 2×2 input matrix:
A =
0 2
1 3
The result will be:
B =
0 0 0 0
0 0 1 0
0 0 0 0
0 1 1 1
=
Currently, I do this with a slow for loop.
I would greatly apreciate your help.
Dror Hi
I am looking for a fast code to do the following:
get a matrix with elements between 0 and 15
create a new matrix, double the size (both rows and columns)
for each element in the first matrix, set the binary representation of this element in the new matrix, in a 2×2 way.
first example
for a 1×1 input matrix:
A =
7
The result will be:
B =
0 1
1 1
Second example
for a 2×2 input matrix:
A =
0 2
1 3
The result will be:
B =
0 0 0 0
0 0 1 0
0 0 0 0
0 1 1 1
=
Currently, I do this with a slow for loop.
I would greatly apreciate your help.
Dror matrix, binary MATLAB Answers — New Questions
How can I download file log data manually from my Speedgoat target?
Is there a way to download file logs manually from my Speedgoat target, either with or without MATLAB?
I am looking for a way to transfer, import, and delete the files using basic protocols like FTP or SCP.Is there a way to download file logs manually from my Speedgoat target, either with or without MATLAB?
I am looking for a way to transfer, import, and delete the files using basic protocols like FTP or SCP. Is there a way to download file logs manually from my Speedgoat target, either with or without MATLAB?
I am looking for a way to transfer, import, and delete the files using basic protocols like FTP or SCP. speedgoat, ftp, scp, filelog, logging MATLAB Answers — New Questions
how to solve “Unable to download third party software: LWIP Sources” when I tried to install “Embedded Coder Support Package for STMicroelectronics Discovery Boards”
I have been attempting to install the support package "Embedded Coder Support Package for STMicroelectronics Discovery Boards" in the r2018a version of matlab, while I keep getting this error. I have tried to run matlab as Administrator, but it didn’t work.
After installing this, I tried to install another support package, Embedded Coder Support Package for ARM Cortex-M Processors, and it is successful. So I believe there is no issue about my internet.
Somebody please help me.I have been attempting to install the support package "Embedded Coder Support Package for STMicroelectronics Discovery Boards" in the r2018a version of matlab, while I keep getting this error. I have tried to run matlab as Administrator, but it didn’t work.
After installing this, I tried to install another support package, Embedded Coder Support Package for ARM Cortex-M Processors, and it is successful. So I believe there is no issue about my internet.
Somebody please help me. I have been attempting to install the support package "Embedded Coder Support Package for STMicroelectronics Discovery Boards" in the r2018a version of matlab, while I keep getting this error. I have tried to run matlab as Administrator, but it didn’t work.
After installing this, I tried to install another support package, Embedded Coder Support Package for ARM Cortex-M Processors, and it is successful. So I believe there is no issue about my internet.
Somebody please help me. third party package MATLAB Answers — New Questions
I wanted to create create 3 UART connections with a Zynq Processor to take data from 3 different receivers. Is there any resources online?
I am working with ADALM Pluto fitted with a Zynq processor and would like to process to transmit and receive data through the SDR. I want to use 3 receivers and gather their data simultaneously. Is there any MATLAB or Simulink resources that might benefit me in any way?
My main goal would be to create 3 different UART connections running at the same time.I am working with ADALM Pluto fitted with a Zynq processor and would like to process to transmit and receive data through the SDR. I want to use 3 receivers and gather their data simultaneously. Is there any MATLAB or Simulink resources that might benefit me in any way?
My main goal would be to create 3 different UART connections running at the same time. I am working with ADALM Pluto fitted with a Zynq processor and would like to process to transmit and receive data through the SDR. I want to use 3 receivers and gather their data simultaneously. Is there any MATLAB or Simulink resources that might benefit me in any way?
My main goal would be to create 3 different UART connections running at the same time. simulink, sdr, uart, serial port MATLAB Answers — New Questions
how to run two scripts (one MEX function and one that calls upon a digital library) in parallel using parfor and parallel pools?
I am trying to achieve parallel exectution of two functions that would normally need two separate matlab(r2023a) windows open in order to successfuly execute. The PULM() function is a MEX funtion and DMD_Funtion is a matlab function that uses a library (‘alp4395’). because of this, a threadpool does not work because ‘Use of MEX functions is not supported on a thread-based worker.’ The reason either a parallel processing function or 2 MATLAB windows are needed is because PULM() needs to initialize into its ready state then it waits for a trigger (meaning matlab will stay ‘Busy’ and wont execute any other commands until PULM is finished, which waits indefinitely for a trigger), which is the DMD_Function(), then finishes the rest of the PULM MEX functions to collect data and exit.
I have been trying to use parpool(‘Processes’) instead, however it seems that it is unable to successfully ‘exit gracefully’ from the C code, probably due to timing issues with the trigger. PULM() needs several seconds to be in its ‘Ready’ state before the DMD_Funtion() is ran or else the PULM() will be waiting for triggers and basically never exit. I noticed that even with the Pause(5) or even 10 that I put in before the the DMD funtion is ran, all that happens is that both workers wait 5 seconds before running simultaneously instead of being delayed like they are supposed to. How do I delay the exectution of the DMD funtion? is it possible that i = 3 is running before i = 2 causing both of interations to pause before executing? Are there any other ways I could accomplish parallel processing in this way without the use of 2 MATLAB windows?
Initially I thought using 2 push buttons on a GUI would work because I believed that push buttons worked in parallel, but I soon realized they were executed sequentially. So I now have to use parallel toolbox functions so that one push button with execute everything in parallel.
Here’s the code for the parfor:
parfor i=2:3
if i==2
%pause(1);
%DMD_Function(patternNumber,AvergeNumber,SamplingRate,BinningNumber=768/SamplingRate) 768/32
PULM(PonitNumber,NumberofRecording,AvergeNumber);
%disp(‘run 1’);
disp(‘done 1’)
else
pause(5);
DMD_Function(patternNumber,AvergeNumber,SamplingRate,BinningNumber);
disp(‘done 2’)
end
end
Note: ‘done 1’ does not display meaning it does not complete the MEX function but ‘All records were saved to file’ does display which is right before ‘Exit Gracefully’ for the Digitizer.
In a separate code I tried to why the pause was just making them both wait 5 seconds then simultaneously running instead of being delayed. Threadpools seem to do what I want, it executes i==2 and delays i == 3. I am still not sure as to why Processespools doesn’t do the same thing. I even tried to stop the execution of the i==3 line by having it check if i == 2 wrote in a file, but it just ccomes up with an error. this is the reason why I was wondering if i==3 is being executed faster than i==2.
stateFile = ‘state.txt’;
parfor i = 2:3
if i == 2
%pause(5);
disp(‘hi’)
fid = fopen(stateFile, ‘w’);
fwrite(fid, ‘5’, ‘char’);
fclose(fid);
else
pause(5);
if isfile(stateFile)
fid = fopen(stateFile, ‘r’);
state = fread(fid, ‘*char’)’;
fclose(fid);
% Check if the state value matches
if strcmp(state, ‘5’)
disp(‘hello’);
end
end
end
endI am trying to achieve parallel exectution of two functions that would normally need two separate matlab(r2023a) windows open in order to successfuly execute. The PULM() function is a MEX funtion and DMD_Funtion is a matlab function that uses a library (‘alp4395’). because of this, a threadpool does not work because ‘Use of MEX functions is not supported on a thread-based worker.’ The reason either a parallel processing function or 2 MATLAB windows are needed is because PULM() needs to initialize into its ready state then it waits for a trigger (meaning matlab will stay ‘Busy’ and wont execute any other commands until PULM is finished, which waits indefinitely for a trigger), which is the DMD_Function(), then finishes the rest of the PULM MEX functions to collect data and exit.
I have been trying to use parpool(‘Processes’) instead, however it seems that it is unable to successfully ‘exit gracefully’ from the C code, probably due to timing issues with the trigger. PULM() needs several seconds to be in its ‘Ready’ state before the DMD_Funtion() is ran or else the PULM() will be waiting for triggers and basically never exit. I noticed that even with the Pause(5) or even 10 that I put in before the the DMD funtion is ran, all that happens is that both workers wait 5 seconds before running simultaneously instead of being delayed like they are supposed to. How do I delay the exectution of the DMD funtion? is it possible that i = 3 is running before i = 2 causing both of interations to pause before executing? Are there any other ways I could accomplish parallel processing in this way without the use of 2 MATLAB windows?
Initially I thought using 2 push buttons on a GUI would work because I believed that push buttons worked in parallel, but I soon realized they were executed sequentially. So I now have to use parallel toolbox functions so that one push button with execute everything in parallel.
Here’s the code for the parfor:
parfor i=2:3
if i==2
%pause(1);
%DMD_Function(patternNumber,AvergeNumber,SamplingRate,BinningNumber=768/SamplingRate) 768/32
PULM(PonitNumber,NumberofRecording,AvergeNumber);
%disp(‘run 1’);
disp(‘done 1’)
else
pause(5);
DMD_Function(patternNumber,AvergeNumber,SamplingRate,BinningNumber);
disp(‘done 2’)
end
end
Note: ‘done 1’ does not display meaning it does not complete the MEX function but ‘All records were saved to file’ does display which is right before ‘Exit Gracefully’ for the Digitizer.
In a separate code I tried to why the pause was just making them both wait 5 seconds then simultaneously running instead of being delayed. Threadpools seem to do what I want, it executes i==2 and delays i == 3. I am still not sure as to why Processespools doesn’t do the same thing. I even tried to stop the execution of the i==3 line by having it check if i == 2 wrote in a file, but it just ccomes up with an error. this is the reason why I was wondering if i==3 is being executed faster than i==2.
stateFile = ‘state.txt’;
parfor i = 2:3
if i == 2
%pause(5);
disp(‘hi’)
fid = fopen(stateFile, ‘w’);
fwrite(fid, ‘5’, ‘char’);
fclose(fid);
else
pause(5);
if isfile(stateFile)
fid = fopen(stateFile, ‘r’);
state = fread(fid, ‘*char’)’;
fclose(fid);
% Check if the state value matches
if strcmp(state, ‘5’)
disp(‘hello’);
end
end
end
end I am trying to achieve parallel exectution of two functions that would normally need two separate matlab(r2023a) windows open in order to successfuly execute. The PULM() function is a MEX funtion and DMD_Funtion is a matlab function that uses a library (‘alp4395’). because of this, a threadpool does not work because ‘Use of MEX functions is not supported on a thread-based worker.’ The reason either a parallel processing function or 2 MATLAB windows are needed is because PULM() needs to initialize into its ready state then it waits for a trigger (meaning matlab will stay ‘Busy’ and wont execute any other commands until PULM is finished, which waits indefinitely for a trigger), which is the DMD_Function(), then finishes the rest of the PULM MEX functions to collect data and exit.
I have been trying to use parpool(‘Processes’) instead, however it seems that it is unable to successfully ‘exit gracefully’ from the C code, probably due to timing issues with the trigger. PULM() needs several seconds to be in its ‘Ready’ state before the DMD_Funtion() is ran or else the PULM() will be waiting for triggers and basically never exit. I noticed that even with the Pause(5) or even 10 that I put in before the the DMD funtion is ran, all that happens is that both workers wait 5 seconds before running simultaneously instead of being delayed like they are supposed to. How do I delay the exectution of the DMD funtion? is it possible that i = 3 is running before i = 2 causing both of interations to pause before executing? Are there any other ways I could accomplish parallel processing in this way without the use of 2 MATLAB windows?
Initially I thought using 2 push buttons on a GUI would work because I believed that push buttons worked in parallel, but I soon realized they were executed sequentially. So I now have to use parallel toolbox functions so that one push button with execute everything in parallel.
Here’s the code for the parfor:
parfor i=2:3
if i==2
%pause(1);
%DMD_Function(patternNumber,AvergeNumber,SamplingRate,BinningNumber=768/SamplingRate) 768/32
PULM(PonitNumber,NumberofRecording,AvergeNumber);
%disp(‘run 1’);
disp(‘done 1’)
else
pause(5);
DMD_Function(patternNumber,AvergeNumber,SamplingRate,BinningNumber);
disp(‘done 2’)
end
end
Note: ‘done 1’ does not display meaning it does not complete the MEX function but ‘All records were saved to file’ does display which is right before ‘Exit Gracefully’ for the Digitizer.
In a separate code I tried to why the pause was just making them both wait 5 seconds then simultaneously running instead of being delayed. Threadpools seem to do what I want, it executes i==2 and delays i == 3. I am still not sure as to why Processespools doesn’t do the same thing. I even tried to stop the execution of the i==3 line by having it check if i == 2 wrote in a file, but it just ccomes up with an error. this is the reason why I was wondering if i==3 is being executed faster than i==2.
stateFile = ‘state.txt’;
parfor i = 2:3
if i == 2
%pause(5);
disp(‘hi’)
fid = fopen(stateFile, ‘w’);
fwrite(fid, ‘5’, ‘char’);
fclose(fid);
else
pause(5);
if isfile(stateFile)
fid = fopen(stateFile, ‘r’);
state = fread(fid, ‘*char’)’;
fclose(fid);
% Check if the state value matches
if strcmp(state, ‘5’)
disp(‘hello’);
end
end
end
end parallel computing, parallel computing toolbox, parfor, data acquisition, digitizer, help, dmd, parallel pools MATLAB Answers — New Questions
Need a Matlab code
Sir I am doing M Sc project based on mixed finite element method i need help in solving the numerical problems which was done by matlabSir I am doing M Sc project based on mixed finite element method i need help in solving the numerical problems which was done by matlab Sir I am doing M Sc project based on mixed finite element method i need help in solving the numerical problems which was done by matlab numerical method, finite element analysis MATLAB Answers — New Questions
How can i draw shaded confidence region with nlparci and lsqcurvfit?
[k,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat] = lsqcurvefit(@simulatedhs,k0,tforward,[Hdata,HSdata],lb,ub);
CI = nlparci(k,Rsd,’jacobian’,Jmat);[k,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat] = lsqcurvefit(@simulatedhs,k0,tforward,[Hdata,HSdata],lb,ub);
CI = nlparci(k,Rsd,’jacobian’,Jmat); [k,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat] = lsqcurvefit(@simulatedhs,k0,tforward,[Hdata,HSdata],lb,ub);
CI = nlparci(k,Rsd,’jacobian’,Jmat); curve fitting, parameter estimation, statistics information, confidence region MATLAB Answers — New Questions
chosing the right Vnom, Qnom point in Shepherd model
Hello, I’m currently using the battery library in Simulink, based on the Shepherd model. When I input the nominal voltage values as specified in the datasheet, I notice that the curve accuracy diminishes after the nominal voltage range. However, when I manually select different points, I obtain a more accurate curve. Which approach is preferable: relying on the nominal voltage values provided in the datasheet or selecting my own points to achieve a more accurate representation of the battery’s behavior?Hello, I’m currently using the battery library in Simulink, based on the Shepherd model. When I input the nominal voltage values as specified in the datasheet, I notice that the curve accuracy diminishes after the nominal voltage range. However, when I manually select different points, I obtain a more accurate curve. Which approach is preferable: relying on the nominal voltage values provided in the datasheet or selecting my own points to achieve a more accurate representation of the battery’s behavior? Hello, I’m currently using the battery library in Simulink, based on the Shepherd model. When I input the nominal voltage values as specified in the datasheet, I notice that the curve accuracy diminishes after the nominal voltage range. However, when I manually select different points, I obtain a more accurate curve. Which approach is preferable: relying on the nominal voltage values provided in the datasheet or selecting my own points to achieve a more accurate representation of the battery’s behavior? matlab, plot, battery_system_management, shepherd MATLAB Answers — New Questions
How to run standalone application from the folder where it is located?
I made a standalone app using matlab app designer. While making package, the default installation folder for package is showing as ProgramFiles or AppData. But I want to run from the local folder only where the app is located in the User PC. Please suggest the way for doing this.I made a standalone app using matlab app designer. While making package, the default installation folder for package is showing as ProgramFiles or AppData. But I want to run from the local folder only where the app is located in the User PC. Please suggest the way for doing this. I made a standalone app using matlab app designer. While making package, the default installation folder for package is showing as ProgramFiles or AppData. But I want to run from the local folder only where the app is located in the User PC. Please suggest the way for doing this. standalone application MATLAB Answers — New Questions