Tag Archives: matlab
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
Can I please get an accessibility statement
Yes I am trying to find your accessibility statement in case I have a student with disabilities in my class thank youYes I am trying to find your accessibility statement in case I have a student with disabilities in my class thank you Yes I am trying to find your accessibility statement in case I have a student with disabilities in my class thank you accessibility MATLAB Answers — New Questions
How to use OutputFcn with fitnlm
Hi all,
How do I execute an OutputFcn function in each iteration inside fitlm? I have tried to run the following code but it does not print anything or throw an exception.
load carbig
tbl = table(Horsepower,Weight,MPG);
modelfun = @(b,x)b(1) + b(2)*x(:,1).^b(3) + …
b(4)*x(:,2).^b(5);
beta0 = [-50 500 -1 500 -1];
opts = statset("fitnlm");
opts.OutputFcn = @(x)disp(x);
mdl = fitnlm(tbl,modelfun,beta0,"Options",opts);Hi all,
How do I execute an OutputFcn function in each iteration inside fitlm? I have tried to run the following code but it does not print anything or throw an exception.
load carbig
tbl = table(Horsepower,Weight,MPG);
modelfun = @(b,x)b(1) + b(2)*x(:,1).^b(3) + …
b(4)*x(:,2).^b(5);
beta0 = [-50 500 -1 500 -1];
opts = statset("fitnlm");
opts.OutputFcn = @(x)disp(x);
mdl = fitnlm(tbl,modelfun,beta0,"Options",opts); Hi all,
How do I execute an OutputFcn function in each iteration inside fitlm? I have tried to run the following code but it does not print anything or throw an exception.
load carbig
tbl = table(Horsepower,Weight,MPG);
modelfun = @(b,x)b(1) + b(2)*x(:,1).^b(3) + …
b(4)*x(:,2).^b(5);
beta0 = [-50 500 -1 500 -1];
opts = statset("fitnlm");
opts.OutputFcn = @(x)disp(x);
mdl = fitnlm(tbl,modelfun,beta0,"Options",opts); fitnlm, outputfcn, fit nonlinear regression model MATLAB Answers — New Questions
Troubleshooting connection issues with Speedgoat target computers
How do I troubleshoot connection issues between my Windows or Linux host PC, and a Speedgoat target computer configured with Simulink Real-Time (SLRT)?How do I troubleshoot connection issues between my Windows or Linux host PC, and a Speedgoat target computer configured with Simulink Real-Time (SLRT)? How do I troubleshoot connection issues between my Windows or Linux host PC, and a Speedgoat target computer configured with Simulink Real-Time (SLRT)? speedgoat, connection, fail, firewall, ports, slrt MATLAB Answers — New Questions
Prevent changing values in GUI
Dear firends,
I have a querry reagrding the GUI formation in MATLAB. I have made a GUI and everything is ok but the values of tab inside the listerner called as ‘angle’ can be changed with edit filed and slider, which has limit obj.angle = [-10,10].
During static code given below also I have made the condtion ‘if (obj.angle ~= obj.angle) & obj.angle<10 & obj.angle>-10’. Hence the static code is not executed if the slider and editfield is out of range of given limit.
But the problem is if I go inside the angle.Value and write some number not in range or limit of angle then even though the static code is not excuted but the value inside angle.Value is updated and stored. I dont want this.
Hence, I request to please suggest some way by which I can prevent the value from being updated manually inside the angle.Value. And the angle.Value should have the same limit as it has when input is given through slider or edit field.
I request to please help.
Thanking all,
Kind regards
classdef classErowin < handle
properties
fig
serial_port
UI
angle
end
properties (SetObservable, AbortSet) % for listeners
angle
end
methods
function obj = class() % constructor
obj.angle = [-10,10]
edit_filed
slider
end
end
methods (Static)
function handlePropEvents(src,evnt)
obj = evnt.AffectedObject;
switch src.Name
case {‘angle’}
if (obj.angle ~= obj.angle) & obj.angle<10 & obj.angle>-10
end
end
end
end
endDear firends,
I have a querry reagrding the GUI formation in MATLAB. I have made a GUI and everything is ok but the values of tab inside the listerner called as ‘angle’ can be changed with edit filed and slider, which has limit obj.angle = [-10,10].
During static code given below also I have made the condtion ‘if (obj.angle ~= obj.angle) & obj.angle<10 & obj.angle>-10’. Hence the static code is not executed if the slider and editfield is out of range of given limit.
But the problem is if I go inside the angle.Value and write some number not in range or limit of angle then even though the static code is not excuted but the value inside angle.Value is updated and stored. I dont want this.
Hence, I request to please suggest some way by which I can prevent the value from being updated manually inside the angle.Value. And the angle.Value should have the same limit as it has when input is given through slider or edit field.
I request to please help.
Thanking all,
Kind regards
classdef classErowin < handle
properties
fig
serial_port
UI
angle
end
properties (SetObservable, AbortSet) % for listeners
angle
end
methods
function obj = class() % constructor
obj.angle = [-10,10]
edit_filed
slider
end
end
methods (Static)
function handlePropEvents(src,evnt)
obj = evnt.AffectedObject;
switch src.Name
case {‘angle’}
if (obj.angle ~= obj.angle) & obj.angle<10 & obj.angle>-10
end
end
end
end
end Dear firends,
I have a querry reagrding the GUI formation in MATLAB. I have made a GUI and everything is ok but the values of tab inside the listerner called as ‘angle’ can be changed with edit filed and slider, which has limit obj.angle = [-10,10].
During static code given below also I have made the condtion ‘if (obj.angle ~= obj.angle) & obj.angle<10 & obj.angle>-10’. Hence the static code is not executed if the slider and editfield is out of range of given limit.
But the problem is if I go inside the angle.Value and write some number not in range or limit of angle then even though the static code is not excuted but the value inside angle.Value is updated and stored. I dont want this.
Hence, I request to please suggest some way by which I can prevent the value from being updated manually inside the angle.Value. And the angle.Value should have the same limit as it has when input is given through slider or edit field.
I request to please help.
Thanking all,
Kind regards
classdef classErowin < handle
properties
fig
serial_port
UI
angle
end
properties (SetObservable, AbortSet) % for listeners
angle
end
methods
function obj = class() % constructor
obj.angle = [-10,10]
edit_filed
slider
end
end
methods (Static)
function handlePropEvents(src,evnt)
obj = evnt.AffectedObject;
switch src.Name
case {‘angle’}
if (obj.angle ~= obj.angle) & obj.angle<10 & obj.angle>-10
end
end
end
end
end gui, matlab gui MATLAB Answers — New Questions
Call a Python function inside a MATLAB loop
In a Matlab script, is there a way to call a Python function, in loop for, in such a way that at every iteration the inputs of the Python function are different?
This is my case, where the arrays "a" and "b" are always different, and they return, obviously, different output:
% My Python function
import numpy as np
from scipy import stats
a = [7, 42, 61, 81, 115, 137, 80, 100, 121, 140, 127, 110, 81, 39, 59, 45, 38, 32, 29, 27, 35, 25, 22, 20, 19, 14, 12, 9, 8, 6, 3, 2, 2, 0, 0, 1, 0, 1, 0, 0];
b = a;
rng = np.random.default_rng()
method = stats.PermutationMethod(n_resamples=9999, random_state=rng)
res = stats.anderson_ksamp([a,b], method=method)
print(res.statistic)
print(res.critical_values)
print(res.pvalue)
To add more details, I would like to have something like this in Matlab:
% Call a Python function inside a MATLAB loop
for i = 1 : 10
a = randi([1 100],1,50);
b = randi([1 100],1,50);
out = call_python_function_here;
endIn a Matlab script, is there a way to call a Python function, in loop for, in such a way that at every iteration the inputs of the Python function are different?
This is my case, where the arrays "a" and "b" are always different, and they return, obviously, different output:
% My Python function
import numpy as np
from scipy import stats
a = [7, 42, 61, 81, 115, 137, 80, 100, 121, 140, 127, 110, 81, 39, 59, 45, 38, 32, 29, 27, 35, 25, 22, 20, 19, 14, 12, 9, 8, 6, 3, 2, 2, 0, 0, 1, 0, 1, 0, 0];
b = a;
rng = np.random.default_rng()
method = stats.PermutationMethod(n_resamples=9999, random_state=rng)
res = stats.anderson_ksamp([a,b], method=method)
print(res.statistic)
print(res.critical_values)
print(res.pvalue)
To add more details, I would like to have something like this in Matlab:
% Call a Python function inside a MATLAB loop
for i = 1 : 10
a = randi([1 100],1,50);
b = randi([1 100],1,50);
out = call_python_function_here;
end In a Matlab script, is there a way to call a Python function, in loop for, in such a way that at every iteration the inputs of the Python function are different?
This is my case, where the arrays "a" and "b" are always different, and they return, obviously, different output:
% My Python function
import numpy as np
from scipy import stats
a = [7, 42, 61, 81, 115, 137, 80, 100, 121, 140, 127, 110, 81, 39, 59, 45, 38, 32, 29, 27, 35, 25, 22, 20, 19, 14, 12, 9, 8, 6, 3, 2, 2, 0, 0, 1, 0, 1, 0, 0];
b = a;
rng = np.random.default_rng()
method = stats.PermutationMethod(n_resamples=9999, random_state=rng)
res = stats.anderson_ksamp([a,b], method=method)
print(res.statistic)
print(res.critical_values)
print(res.pvalue)
To add more details, I would like to have something like this in Matlab:
% Call a Python function inside a MATLAB loop
for i = 1 : 10
a = randi([1 100],1,50);
b = randi([1 100],1,50);
out = call_python_function_here;
end call python MATLAB Answers — New Questions