Tag Archives: matlab
Interpolating between columns for an index
I am trying to use a seperate array as an index and a variable.
E.g.
Row 1 I want to use as index, or lookup.
Row 2 are data
550 750 950
1 2 8
Column 1 would be reference from row 1
Column 2 would be multiplied against row 2 depending on how Column 1 relates to row 1
550 22
580 21
650 20
623 28
850 14
So my goal is using the second set of data.
at 550, 22 would be multiplied by 1,
at 650, 20 would be multiplied by 1.5
at 850, 14 would be multiplied by 5
I tried search for awhile on the community and through the "basics"
I might be wording this wrong by calling it indexing.I am trying to use a seperate array as an index and a variable.
E.g.
Row 1 I want to use as index, or lookup.
Row 2 are data
550 750 950
1 2 8
Column 1 would be reference from row 1
Column 2 would be multiplied against row 2 depending on how Column 1 relates to row 1
550 22
580 21
650 20
623 28
850 14
So my goal is using the second set of data.
at 550, 22 would be multiplied by 1,
at 650, 20 would be multiplied by 1.5
at 850, 14 would be multiplied by 5
I tried search for awhile on the community and through the "basics"
I might be wording this wrong by calling it indexing. I am trying to use a seperate array as an index and a variable.
E.g.
Row 1 I want to use as index, or lookup.
Row 2 are data
550 750 950
1 2 8
Column 1 would be reference from row 1
Column 2 would be multiplied against row 2 depending on how Column 1 relates to row 1
550 22
580 21
650 20
623 28
850 14
So my goal is using the second set of data.
at 550, 22 would be multiplied by 1,
at 650, 20 would be multiplied by 1.5
at 850, 14 would be multiplied by 5
I tried search for awhile on the community and through the "basics"
I might be wording this wrong by calling it indexing. basics, interpolation, indexing MATLAB Answers — New Questions
Trying to sign out of MATLAB desktop
I am trying to sign out of my MATLAB account on the desktop app, yet it is not letting me.
I keep getting this message, although I have nothing open aside from MATLAB and no scripts are running: Before signing out you must:
Close all MATLAB sessions, including the current one.Note: Restarting MATLAB requires internet access.I am trying to sign out of my MATLAB account on the desktop app, yet it is not letting me.
I keep getting this message, although I have nothing open aside from MATLAB and no scripts are running: Before signing out you must:
Close all MATLAB sessions, including the current one.Note: Restarting MATLAB requires internet access. I am trying to sign out of my MATLAB account on the desktop app, yet it is not letting me.
I keep getting this message, although I have nothing open aside from MATLAB and no scripts are running: Before signing out you must:
Close all MATLAB sessions, including the current one.Note: Restarting MATLAB requires internet access. matlab MATLAB Answers — New Questions
Detecting circles in an image to measure inner and outer diameter
Any reason why this code won’t detect the inner and outer diamter of the tube seen in the image below?
a = imread(‘E1-E2.jpg’);
imshow(a);
% Center and radius
[centers,radii] = imfindcircles(a,[20 1000],’ObjectPolarity’,’bright’, ‘Sensitivity’,0.95);
diameter = radii*2;
viscircles(centers, radii,’Color’,’b’);Any reason why this code won’t detect the inner and outer diamter of the tube seen in the image below?
a = imread(‘E1-E2.jpg’);
imshow(a);
% Center and radius
[centers,radii] = imfindcircles(a,[20 1000],’ObjectPolarity’,’bright’, ‘Sensitivity’,0.95);
diameter = radii*2;
viscircles(centers, radii,’Color’,’b’); Any reason why this code won’t detect the inner and outer diamter of the tube seen in the image below?
a = imread(‘E1-E2.jpg’);
imshow(a);
% Center and radius
[centers,radii] = imfindcircles(a,[20 1000],’ObjectPolarity’,’bright’, ‘Sensitivity’,0.95);
diameter = radii*2;
viscircles(centers, radii,’Color’,’b’); image, circle, wrong lens, image analysis MATLAB Answers — New Questions
Reading data from Microsoft Excel
What is the syntax for reading data from Microsoft Excel sheets? I tried the following and it returned error messages.
A = xlsread(‘amat.xlsx’,’sheet1′,’a1:a10′)
I even changed the case of S in sheet to capital and the error persisted. Anyone with an idea?What is the syntax for reading data from Microsoft Excel sheets? I tried the following and it returned error messages.
A = xlsread(‘amat.xlsx’,’sheet1′,’a1:a10′)
I even changed the case of S in sheet to capital and the error persisted. Anyone with an idea? What is the syntax for reading data from Microsoft Excel sheets? I tried the following and it returned error messages.
A = xlsread(‘amat.xlsx’,’sheet1′,’a1:a10′)
I even changed the case of S in sheet to capital and the error persisted. Anyone with an idea? transferred MATLAB Answers — New Questions
How to deal with corrupted matlabprefs?
I run a matlab-script that use batch processing to collect sample from different sensors at same time.
Some sensors are connect using UDP protocol, modbus, and serial port.
As a rule, they work fine. However, sometimes I have an error related to matlabprefs.mat.
As a consequence, one of the sensors can stop to collect data, i.e., I can not read correctly form a specific serial port, and in the next time I run the same matlab script, it will fail producing some complaining about "matlabprefs.mat" (see example below).
I have this problem frequently.
I am affraid becasue If I can not deal properlly with this problem,I can not trust on matlab to control my data sample system.
Please, could you help me to figure out a deffinitive solution for this issue?
Warning: Initializing MATLAB Graphics failed.
This indicates a potentially serious problem in your MATLAB setup, which should be resolved as soon as possible. Error detected was:
MATLAB:load:unableToReadMatFile
Unable to read MAT-file C:UsersuserAppDataRoamingMathWorksMATLABR2023amatlabprefs.mat. File might be corrupt.
> In hgrc (line 151)
In matlab.graphics.internal.initialize (line 15)I run a matlab-script that use batch processing to collect sample from different sensors at same time.
Some sensors are connect using UDP protocol, modbus, and serial port.
As a rule, they work fine. However, sometimes I have an error related to matlabprefs.mat.
As a consequence, one of the sensors can stop to collect data, i.e., I can not read correctly form a specific serial port, and in the next time I run the same matlab script, it will fail producing some complaining about "matlabprefs.mat" (see example below).
I have this problem frequently.
I am affraid becasue If I can not deal properlly with this problem,I can not trust on matlab to control my data sample system.
Please, could you help me to figure out a deffinitive solution for this issue?
Warning: Initializing MATLAB Graphics failed.
This indicates a potentially serious problem in your MATLAB setup, which should be resolved as soon as possible. Error detected was:
MATLAB:load:unableToReadMatFile
Unable to read MAT-file C:UsersuserAppDataRoamingMathWorksMATLABR2023amatlabprefs.mat. File might be corrupt.
> In hgrc (line 151)
In matlab.graphics.internal.initialize (line 15) I run a matlab-script that use batch processing to collect sample from different sensors at same time.
Some sensors are connect using UDP protocol, modbus, and serial port.
As a rule, they work fine. However, sometimes I have an error related to matlabprefs.mat.
As a consequence, one of the sensors can stop to collect data, i.e., I can not read correctly form a specific serial port, and in the next time I run the same matlab script, it will fail producing some complaining about "matlabprefs.mat" (see example below).
I have this problem frequently.
I am affraid becasue If I can not deal properlly with this problem,I can not trust on matlab to control my data sample system.
Please, could you help me to figure out a deffinitive solution for this issue?
Warning: Initializing MATLAB Graphics failed.
This indicates a potentially serious problem in your MATLAB setup, which should be resolved as soon as possible. Error detected was:
MATLAB:load:unableToReadMatFile
Unable to read MAT-file C:UsersuserAppDataRoamingMathWorksMATLABR2023amatlabprefs.mat. File might be corrupt.
> In hgrc (line 151)
In matlab.graphics.internal.initialize (line 15) matlabprefs.mat MATLAB Answers — New Questions
function chaining when one function has multiple outputs
Similar question has been asked before, but I would ask the question in a more specific manner. If the function in the input end has more than one output, there will be the error ‘Not enough input arguments’. Is there a neat way to make chained function out of that situation?
f(g) % only the first output of g is kept as input for f
function [x, y] = g()
x = 1;
y = 2;
end
function out = f(x, y)
out = x+y;
end
Storing the outputs of the first function in two variables could be a solution, but I like to see how chaining could be done in this kind of scenario for the sake of learning.
[x, y] = g();
f(x, y)Similar question has been asked before, but I would ask the question in a more specific manner. If the function in the input end has more than one output, there will be the error ‘Not enough input arguments’. Is there a neat way to make chained function out of that situation?
f(g) % only the first output of g is kept as input for f
function [x, y] = g()
x = 1;
y = 2;
end
function out = f(x, y)
out = x+y;
end
Storing the outputs of the first function in two variables could be a solution, but I like to see how chaining could be done in this kind of scenario for the sake of learning.
[x, y] = g();
f(x, y) Similar question has been asked before, but I would ask the question in a more specific manner. If the function in the input end has more than one output, there will be the error ‘Not enough input arguments’. Is there a neat way to make chained function out of that situation?
f(g) % only the first output of g is kept as input for f
function [x, y] = g()
x = 1;
y = 2;
end
function out = f(x, y)
out = x+y;
end
Storing the outputs of the first function in two variables could be a solution, but I like to see how chaining could be done in this kind of scenario for the sake of learning.
[x, y] = g();
f(x, y) chained_function, function_chaining, function_composition MATLAB Answers — New Questions
MATLAB Web Apps are not supported on this device (Phone)
Good night everybody,
I am currently trying to develop a MATLAB Web App on MATLAB Web Server R2020b. This application works fine on Desktop, however if I try to access it on any phone an error "MATLAB Web Apps are not supported on this device" appears. I have accessed the link (https://es.mathworks.com/help/compiler/webapps/supported-browsers-and-platform-incompatibilities.html#:~:text=Web%20apps%20are%20compatible%20with,Chrome%E2%84%A2%20browser%20on%20Chromebooks.) of the error and there is nothing about incompatibility with phones. Are phones and maybe some other devices unhandled by Web Apps or this is some unrelated error which I can’t manage to find? As an example, if I try to access with Chrome or Firefox on a Pixel 2 the error of the image appears, however if I turn on "View in desktop mode" it works correctly and I can see my app.
Thank you all,
MarcosGood night everybody,
I am currently trying to develop a MATLAB Web App on MATLAB Web Server R2020b. This application works fine on Desktop, however if I try to access it on any phone an error "MATLAB Web Apps are not supported on this device" appears. I have accessed the link (https://es.mathworks.com/help/compiler/webapps/supported-browsers-and-platform-incompatibilities.html#:~:text=Web%20apps%20are%20compatible%20with,Chrome%E2%84%A2%20browser%20on%20Chromebooks.) of the error and there is nothing about incompatibility with phones. Are phones and maybe some other devices unhandled by Web Apps or this is some unrelated error which I can’t manage to find? As an example, if I try to access with Chrome or Firefox on a Pixel 2 the error of the image appears, however if I turn on "View in desktop mode" it works correctly and I can see my app.
Thank you all,
Marcos Good night everybody,
I am currently trying to develop a MATLAB Web App on MATLAB Web Server R2020b. This application works fine on Desktop, however if I try to access it on any phone an error "MATLAB Web Apps are not supported on this device" appears. I have accessed the link (https://es.mathworks.com/help/compiler/webapps/supported-browsers-and-platform-incompatibilities.html#:~:text=Web%20apps%20are%20compatible%20with,Chrome%E2%84%A2%20browser%20on%20Chromebooks.) of the error and there is nothing about incompatibility with phones. Are phones and maybe some other devices unhandled by Web Apps or this is some unrelated error which I can’t manage to find? As an example, if I try to access with Chrome or Firefox on a Pixel 2 the error of the image appears, however if I turn on "View in desktop mode" it works correctly and I can see my app.
Thank you all,
Marcos matlab, web app MATLAB Answers — New Questions
Would like to determine when a UDP packet is physically received
Hello,
Is there anyway to determine when a machine physically receives a UDP packet from the network?
Thanks!Hello,
Is there anyway to determine when a machine physically receives a UDP packet from the network?
Thanks! Hello,
Is there anyway to determine when a machine physically receives a UDP packet from the network?
Thanks! udp MATLAB Answers — New Questions
How to apply orientation constraints between two rigid bodies
I am trying to do an inverse kinematics analysis on a rigid body tree that has 3 rigid bodies, all with revolute joints, operating in a 2D plane. One of the contraints of the system that this is based off is that the first and third body must be parallel. How would I apply a constraint to ensure that this happens? I am attempting to mimic the physical motion of the model below, where the base frame is the hole near the top of the 3D model.I am trying to do an inverse kinematics analysis on a rigid body tree that has 3 rigid bodies, all with revolute joints, operating in a 2D plane. One of the contraints of the system that this is based off is that the first and third body must be parallel. How would I apply a constraint to ensure that this happens? I am attempting to mimic the physical motion of the model below, where the base frame is the hole near the top of the 3D model. I am trying to do an inverse kinematics analysis on a rigid body tree that has 3 rigid bodies, all with revolute joints, operating in a 2D plane. One of the contraints of the system that this is based off is that the first and third body must be parallel. How would I apply a constraint to ensure that this happens? I am attempting to mimic the physical motion of the model below, where the base frame is the hole near the top of the 3D model. robotics, inverse kinematics MATLAB Answers — New Questions
Arduino Fails to Program with “avrdude: ser_open(): can’t set com-state” Error
I have an Arduino Uno device and have attempted to attach it to one of my computer’s COM Ports via a USB cable. I have downloaded the MATLAB Support Package for Arduino Hardware, and ensured that it is correctly accessed by my MATLAB installation via the following commands:
>> restoredefaultpath
>> rehash toolboxcache
Following this, I enter the "arduinosetup" command into my MATLAB Command Window, and follow the instructions described in the following MATLAB Documentation:
https://www.mathworks.com/help/supportpkg/arduinoio/ug/configure-setup-for-arduino-hardware.html
I have ensured that I am selecting both the correct board as well as the correct COM port. However, when I press "Program", I receive the following error message:
Failed to program the arduino board. Click the following link to see the error log. Contact Technical support if you need more help.
Clicking the link in that message provides me a TXT file with a fairly large stack trace. The most important lines, however, seem to be at the end. These read the following:
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:ProgramDataMATLABSupportPackagesR2023aaIDEhardwaretoolsavr/etc/avrdude.conf"
Using Port : COM5
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: ser_open(): can’t set com-state for "\.COM5"
avrdude done. Thank you.
An error occurred while uploading the sketch
Upon receiving this error, I tried a few initial troubleshooting steps:Uninstalling and then reinstalling the MATLAB Support Package for Arduino Hardware.Connecting to a different COM port.Restarting both my system and my Arduino board.
Unfortunately, none of the above steps changed the resulting error message. How do I fix this and ensure that I am able to interact with my Arduino board via MATLAB?I have an Arduino Uno device and have attempted to attach it to one of my computer’s COM Ports via a USB cable. I have downloaded the MATLAB Support Package for Arduino Hardware, and ensured that it is correctly accessed by my MATLAB installation via the following commands:
>> restoredefaultpath
>> rehash toolboxcache
Following this, I enter the "arduinosetup" command into my MATLAB Command Window, and follow the instructions described in the following MATLAB Documentation:
https://www.mathworks.com/help/supportpkg/arduinoio/ug/configure-setup-for-arduino-hardware.html
I have ensured that I am selecting both the correct board as well as the correct COM port. However, when I press "Program", I receive the following error message:
Failed to program the arduino board. Click the following link to see the error log. Contact Technical support if you need more help.
Clicking the link in that message provides me a TXT file with a fairly large stack trace. The most important lines, however, seem to be at the end. These read the following:
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:ProgramDataMATLABSupportPackagesR2023aaIDEhardwaretoolsavr/etc/avrdude.conf"
Using Port : COM5
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: ser_open(): can’t set com-state for "\.COM5"
avrdude done. Thank you.
An error occurred while uploading the sketch
Upon receiving this error, I tried a few initial troubleshooting steps:Uninstalling and then reinstalling the MATLAB Support Package for Arduino Hardware.Connecting to a different COM port.Restarting both my system and my Arduino board.
Unfortunately, none of the above steps changed the resulting error message. How do I fix this and ensure that I am able to interact with my Arduino board via MATLAB? I have an Arduino Uno device and have attempted to attach it to one of my computer’s COM Ports via a USB cable. I have downloaded the MATLAB Support Package for Arduino Hardware, and ensured that it is correctly accessed by my MATLAB installation via the following commands:
>> restoredefaultpath
>> rehash toolboxcache
Following this, I enter the "arduinosetup" command into my MATLAB Command Window, and follow the instructions described in the following MATLAB Documentation:
https://www.mathworks.com/help/supportpkg/arduinoio/ug/configure-setup-for-arduino-hardware.html
I have ensured that I am selecting both the correct board as well as the correct COM port. However, when I press "Program", I receive the following error message:
Failed to program the arduino board. Click the following link to see the error log. Contact Technical support if you need more help.
Clicking the link in that message provides me a TXT file with a fairly large stack trace. The most important lines, however, seem to be at the end. These read the following:
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:ProgramDataMATLABSupportPackagesR2023aaIDEhardwaretoolsavr/etc/avrdude.conf"
Using Port : COM5
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: ser_open(): can’t set com-state for "\.COM5"
avrdude done. Thank you.
An error occurred while uploading the sketch
Upon receiving this error, I tried a few initial troubleshooting steps:Uninstalling and then reinstalling the MATLAB Support Package for Arduino Hardware.Connecting to a different COM port.Restarting both my system and my Arduino board.
Unfortunately, none of the above steps changed the resulting error message. How do I fix this and ensure that I am able to interact with my Arduino board via MATLAB? arduino, program, driver, drivers, avrdude, com, port MATLAB Answers — New Questions
thingspeak server closing connection immediately
mqtt3.thingspeak.com closing the connection immediately when trying to connect using A6 gsm module. Has been working flawlessly up to a week ago.Not able to publish any data to private channel. No encryption used (http).mqtt3.thingspeak.com closing the connection immediately when trying to connect using A6 gsm module. Has been working flawlessly up to a week ago.Not able to publish any data to private channel. No encryption used (http). mqtt3.thingspeak.com closing the connection immediately when trying to connect using A6 gsm module. Has been working flawlessly up to a week ago.Not able to publish any data to private channel. No encryption used (http). mqtt broker, tihngspeak MATLAB Answers — New Questions
Theoretical details regarding symbolic integration in Matlab
Dear all,
I am using symbolic integration in Matlab (in particular the "int"-function). I would like to use it as a reference in my research. Therefore, it would be nice to obtain some details which methods Matlab is actually using. Does anybody know? Is there a source to get more details?
Best,
MichaelDear all,
I am using symbolic integration in Matlab (in particular the "int"-function). I would like to use it as a reference in my research. Therefore, it would be nice to obtain some details which methods Matlab is actually using. Does anybody know? Is there a source to get more details?
Best,
Michael Dear all,
I am using symbolic integration in Matlab (in particular the "int"-function). I would like to use it as a reference in my research. Therefore, it would be nice to obtain some details which methods Matlab is actually using. Does anybody know? Is there a source to get more details?
Best,
Michael integration, symbolic, theory MATLAB Answers — New Questions
Why do I get different results on different machines when using “fmincon” from the Optimization Toolbox?
When I try to optimize my objective function with "fmincon", the optimization exits with a flag 0. However on a different machine, it exits with a flag 5. Why do these results differ?When I try to optimize my objective function with "fmincon", the optimization exits with a flag 0. However on a different machine, it exits with a flag 5. Why do these results differ? When I try to optimize my objective function with "fmincon", the optimization exits with a flag 0. However on a different machine, it exits with a flag 5. Why do these results differ? fmincon, condition, firstorderopt, optimization, numericalreproducibility MATLAB Answers — New Questions
app designer error: Attempt to add “theta” to a static workspace.
Hello, i wrote a code and it works while running the script. but when i use it in an app this error shows up Attempt to add "theta" to a static workspace. can somebody help me out. thanks
The code:
%% Constants and parameters
J1 = 1; % Polarization of outer magnet
J2 = 1; % Polarization of inner magnet
u0 = pi*4e-7; % Magnetic constant
%% Position vectors, define appropriately
r = [0.25, 0.3, 0.20 , 0.24]; % radius of magnets (outer to inner)
z = [0.05, 0.15, 0.08, 0.18]; % z cordinate of magnets (outer to inner)
%% main function g
g = @(a, b, c) computeG(a, b, c);
% Initialize F_Z
F_Z = 0;
% Compute F_Z based on the given formula
for i = 1:2
for k = 1:2
for j = 3:4
for l = 3:4
deltaZ = z(k) – z(l);
ri2 = r(i)^2;
rj2 = r(j)^2;
Fijkl = r(i) * r(j) * g(deltaZ, ri2+rj2+deltaZ^2, -2 * r(i) * r(j));
power = 1 + i + j + k + l;
F_Z = F_Z + ((-1)^power) * Fijkl;
end
end
end
end
F_Z = ((J1 * J2) / (2 * u0)) * F_Z;
%% Define the function computeG
function result = computeG(a, b, c)
A = (a^2 – b) / c * pi + sqrt(c^2 – (a^2 – b)^2) / c *(log((-16 * c^2) / ((c^2 – (a^2 – b)^2)^1.5)) + log(c^2 / ((c^2 – (a^2 – b)^2)^1.5)));
S = computeS(a, b, c);
result = A + S;
end
%% Define the function computeS
function S = computeS(a, b, c)
% Define constants
epsilon = c / (c – b);
beta = (b + c) / (b – c);
mu = c / (b + c);
% Calculate terms for S
term1 = (2 * 1i * a) / (c * sqrt(b + c)) * …
((b + c) * ellipticE(asin(sqrt(beta)), beta^(-1)) – c * ellipticF(asin(sqrt(beta)), beta^(-1)));
term2 = (2 * a) / (c * sqrt(b – c) * sqrt(epsilon)) * …
(c / sqrt(mu) * ellipticE1(1 / beta) – c * sqrt(mu) * ellipticK(1 / beta));
term3 = sqrt(epsilon * (1 / beta)) * …
((b – a^2) * ellipticK(2 * mu) + (a^2 – b + c) * ellipticPi(2 * c / (c + b – a^2), 2 * mu));
% Sum all terms
S = term1 + term2 + term3;
end
% Elliptic integral functions using symbolic math toolbox
function val = ellipticK(m)
syms theta;
val = double(int(1 / sqrt(1 – m * sin(theta)^2), theta, 0, pi/2));
end
function val = ellipticF(phi, m)
syms theta;
val = double(int(1 / sqrt(1 – m * sin(theta)^2), theta, 0, phi));
end
function val = ellipticE(phi, m)
syms theta;
val = double(int(sqrt(1 – m * sin(theta)^2), theta, 0, phi));
end
function val = ellipticE1(m)
syms theta;
val = double(int(sqrt(1 – m * sin(theta)^2), theta, 0, pi/2));
end
function val = ellipticPi(n, m)
syms theta;
val = double(int(1 / (sqrt(1 – n * sin(theta)^2) * sqrt(1 – m * sin(theta)^2)), theta, 0, pi/2));
endHello, i wrote a code and it works while running the script. but when i use it in an app this error shows up Attempt to add "theta" to a static workspace. can somebody help me out. thanks
The code:
%% Constants and parameters
J1 = 1; % Polarization of outer magnet
J2 = 1; % Polarization of inner magnet
u0 = pi*4e-7; % Magnetic constant
%% Position vectors, define appropriately
r = [0.25, 0.3, 0.20 , 0.24]; % radius of magnets (outer to inner)
z = [0.05, 0.15, 0.08, 0.18]; % z cordinate of magnets (outer to inner)
%% main function g
g = @(a, b, c) computeG(a, b, c);
% Initialize F_Z
F_Z = 0;
% Compute F_Z based on the given formula
for i = 1:2
for k = 1:2
for j = 3:4
for l = 3:4
deltaZ = z(k) – z(l);
ri2 = r(i)^2;
rj2 = r(j)^2;
Fijkl = r(i) * r(j) * g(deltaZ, ri2+rj2+deltaZ^2, -2 * r(i) * r(j));
power = 1 + i + j + k + l;
F_Z = F_Z + ((-1)^power) * Fijkl;
end
end
end
end
F_Z = ((J1 * J2) / (2 * u0)) * F_Z;
%% Define the function computeG
function result = computeG(a, b, c)
A = (a^2 – b) / c * pi + sqrt(c^2 – (a^2 – b)^2) / c *(log((-16 * c^2) / ((c^2 – (a^2 – b)^2)^1.5)) + log(c^2 / ((c^2 – (a^2 – b)^2)^1.5)));
S = computeS(a, b, c);
result = A + S;
end
%% Define the function computeS
function S = computeS(a, b, c)
% Define constants
epsilon = c / (c – b);
beta = (b + c) / (b – c);
mu = c / (b + c);
% Calculate terms for S
term1 = (2 * 1i * a) / (c * sqrt(b + c)) * …
((b + c) * ellipticE(asin(sqrt(beta)), beta^(-1)) – c * ellipticF(asin(sqrt(beta)), beta^(-1)));
term2 = (2 * a) / (c * sqrt(b – c) * sqrt(epsilon)) * …
(c / sqrt(mu) * ellipticE1(1 / beta) – c * sqrt(mu) * ellipticK(1 / beta));
term3 = sqrt(epsilon * (1 / beta)) * …
((b – a^2) * ellipticK(2 * mu) + (a^2 – b + c) * ellipticPi(2 * c / (c + b – a^2), 2 * mu));
% Sum all terms
S = term1 + term2 + term3;
end
% Elliptic integral functions using symbolic math toolbox
function val = ellipticK(m)
syms theta;
val = double(int(1 / sqrt(1 – m * sin(theta)^2), theta, 0, pi/2));
end
function val = ellipticF(phi, m)
syms theta;
val = double(int(1 / sqrt(1 – m * sin(theta)^2), theta, 0, phi));
end
function val = ellipticE(phi, m)
syms theta;
val = double(int(sqrt(1 – m * sin(theta)^2), theta, 0, phi));
end
function val = ellipticE1(m)
syms theta;
val = double(int(sqrt(1 – m * sin(theta)^2), theta, 0, pi/2));
end
function val = ellipticPi(n, m)
syms theta;
val = double(int(1 / (sqrt(1 – n * sin(theta)^2) * sqrt(1 – m * sin(theta)^2)), theta, 0, pi/2));
end Hello, i wrote a code and it works while running the script. but when i use it in an app this error shows up Attempt to add "theta" to a static workspace. can somebody help me out. thanks
The code:
%% Constants and parameters
J1 = 1; % Polarization of outer magnet
J2 = 1; % Polarization of inner magnet
u0 = pi*4e-7; % Magnetic constant
%% Position vectors, define appropriately
r = [0.25, 0.3, 0.20 , 0.24]; % radius of magnets (outer to inner)
z = [0.05, 0.15, 0.08, 0.18]; % z cordinate of magnets (outer to inner)
%% main function g
g = @(a, b, c) computeG(a, b, c);
% Initialize F_Z
F_Z = 0;
% Compute F_Z based on the given formula
for i = 1:2
for k = 1:2
for j = 3:4
for l = 3:4
deltaZ = z(k) – z(l);
ri2 = r(i)^2;
rj2 = r(j)^2;
Fijkl = r(i) * r(j) * g(deltaZ, ri2+rj2+deltaZ^2, -2 * r(i) * r(j));
power = 1 + i + j + k + l;
F_Z = F_Z + ((-1)^power) * Fijkl;
end
end
end
end
F_Z = ((J1 * J2) / (2 * u0)) * F_Z;
%% Define the function computeG
function result = computeG(a, b, c)
A = (a^2 – b) / c * pi + sqrt(c^2 – (a^2 – b)^2) / c *(log((-16 * c^2) / ((c^2 – (a^2 – b)^2)^1.5)) + log(c^2 / ((c^2 – (a^2 – b)^2)^1.5)));
S = computeS(a, b, c);
result = A + S;
end
%% Define the function computeS
function S = computeS(a, b, c)
% Define constants
epsilon = c / (c – b);
beta = (b + c) / (b – c);
mu = c / (b + c);
% Calculate terms for S
term1 = (2 * 1i * a) / (c * sqrt(b + c)) * …
((b + c) * ellipticE(asin(sqrt(beta)), beta^(-1)) – c * ellipticF(asin(sqrt(beta)), beta^(-1)));
term2 = (2 * a) / (c * sqrt(b – c) * sqrt(epsilon)) * …
(c / sqrt(mu) * ellipticE1(1 / beta) – c * sqrt(mu) * ellipticK(1 / beta));
term3 = sqrt(epsilon * (1 / beta)) * …
((b – a^2) * ellipticK(2 * mu) + (a^2 – b + c) * ellipticPi(2 * c / (c + b – a^2), 2 * mu));
% Sum all terms
S = term1 + term2 + term3;
end
% Elliptic integral functions using symbolic math toolbox
function val = ellipticK(m)
syms theta;
val = double(int(1 / sqrt(1 – m * sin(theta)^2), theta, 0, pi/2));
end
function val = ellipticF(phi, m)
syms theta;
val = double(int(1 / sqrt(1 – m * sin(theta)^2), theta, 0, phi));
end
function val = ellipticE(phi, m)
syms theta;
val = double(int(sqrt(1 – m * sin(theta)^2), theta, 0, phi));
end
function val = ellipticE1(m)
syms theta;
val = double(int(sqrt(1 – m * sin(theta)^2), theta, 0, pi/2));
end
function val = ellipticPi(n, m)
syms theta;
val = double(int(1 / (sqrt(1 – n * sin(theta)^2) * sqrt(1 – m * sin(theta)^2)), theta, 0, pi/2));
end appdesigner, app designer MATLAB Answers — New Questions
Speed of vpaintegral vs. int+vpa
Dear all,
I am currently testing the possibilities of integrating symbolic functions in Matlab. In the documentation of "int" (https://de.mathworks.com/help/symbolic/sym.int.html), I found the following statement which is not in agreement with my personal observations:
"To approximate integrals directly, use vpaintegral instead of vpa. The vpaintegral function is faster and provides control over integration tolerances."
I run the following example and observe that a combination of "int" and "vpa" needs 0.35 secs vs. 47.69 secs in case of "vpaintegral" both having the same precision of 32 valid digits.
syms x y
% define integration boundary
f1 = 0;
eqn = 0.980580675690920 * (0.4-x) – 0.196116135138184 * (1-y) == 0;
f2 = solve(eqn,y);
f3 = 1;
y_max = 0.5;
f = piecewise(x<0.2, min(f1,y_max), 0.2<=x<0.4, min(f2,y_max), …
x>=0.4, min(f3,y_max)); %#ok<CHAIN>
% define integrand
mon = x*y;
% integration over x-y-domain limited by the boundary, y=0, x=0 and x=0.5
tic
F = int(int(mon,y,0,f),x,0,0.5);
vpa(F)
toc
tic
vpaintegral(vpaintegral(mon,y,0,f),x,0,0.5,’RelTol’, 1e-32, ‘AbsTol’, 0)
toc
I am curious whether I miss something here.Dear all,
I am currently testing the possibilities of integrating symbolic functions in Matlab. In the documentation of "int" (https://de.mathworks.com/help/symbolic/sym.int.html), I found the following statement which is not in agreement with my personal observations:
"To approximate integrals directly, use vpaintegral instead of vpa. The vpaintegral function is faster and provides control over integration tolerances."
I run the following example and observe that a combination of "int" and "vpa" needs 0.35 secs vs. 47.69 secs in case of "vpaintegral" both having the same precision of 32 valid digits.
syms x y
% define integration boundary
f1 = 0;
eqn = 0.980580675690920 * (0.4-x) – 0.196116135138184 * (1-y) == 0;
f2 = solve(eqn,y);
f3 = 1;
y_max = 0.5;
f = piecewise(x<0.2, min(f1,y_max), 0.2<=x<0.4, min(f2,y_max), …
x>=0.4, min(f3,y_max)); %#ok<CHAIN>
% define integrand
mon = x*y;
% integration over x-y-domain limited by the boundary, y=0, x=0 and x=0.5
tic
F = int(int(mon,y,0,f),x,0,0.5);
vpa(F)
toc
tic
vpaintegral(vpaintegral(mon,y,0,f),x,0,0.5,’RelTol’, 1e-32, ‘AbsTol’, 0)
toc
I am curious whether I miss something here. Dear all,
I am currently testing the possibilities of integrating symbolic functions in Matlab. In the documentation of "int" (https://de.mathworks.com/help/symbolic/sym.int.html), I found the following statement which is not in agreement with my personal observations:
"To approximate integrals directly, use vpaintegral instead of vpa. The vpaintegral function is faster and provides control over integration tolerances."
I run the following example and observe that a combination of "int" and "vpa" needs 0.35 secs vs. 47.69 secs in case of "vpaintegral" both having the same precision of 32 valid digits.
syms x y
% define integration boundary
f1 = 0;
eqn = 0.980580675690920 * (0.4-x) – 0.196116135138184 * (1-y) == 0;
f2 = solve(eqn,y);
f3 = 1;
y_max = 0.5;
f = piecewise(x<0.2, min(f1,y_max), 0.2<=x<0.4, min(f2,y_max), …
x>=0.4, min(f3,y_max)); %#ok<CHAIN>
% define integrand
mon = x*y;
% integration over x-y-domain limited by the boundary, y=0, x=0 and x=0.5
tic
F = int(int(mon,y,0,f),x,0,0.5);
vpa(F)
toc
tic
vpaintegral(vpaintegral(mon,y,0,f),x,0,0.5,’RelTol’, 1e-32, ‘AbsTol’, 0)
toc
I am curious whether I miss something here. integral, speed MATLAB Answers — New Questions
Brace indexing is not supported for variables of this type.
Dear Matlab communities:
I am running a spm script for analyizing neuroimaging data, the first script here (ModelSpecificationBinaryMask.m) is to loop another job file ModelSpecificationBinaryMask_job.m over the two subjects while assigning the regressor files that correspond to each of the runs for one subject.
However, I am seeing the follwing errors:
Brace indexing is not supported for variables of this type.
Error in spm_jobman>canonicalise_jobs (line 415)
comp(i) = comp(i) && any(strcmp(fieldnames(job{i}{j}), …
Error in spm_jobman (line 152)
mljob = canonicalise_jobs(jobs);
Error in ModelSpecificationBinaryMask (line 50)
spm_jobman(‘run’, jobs, inputs);
ModelSpecificationBinaryMask.m
clear
close all
clc
% Created by GB on 9/9/19.
% Edited by LC on 8/19/24.
for sub = [101,102]
jobfile = {‘/Volumes/PUMPKIN/scripts/GabbyScripts/ModelSpecificationBinaryMaskTHRESHOFF_job.m’};
nrun = 1; % Assuming nrun should be 1 since we are processing one subject at a time
ncue = 8; % 8 runs for cue task
jobs = repmat(jobfile, 1, nrun);
inputs = cell(25, 1); % Initialize cell array for inputs (25 because you have 3 inputs per run and 8 runs)
% Create a homepath, a base location of all the data
homepath = ‘/Volumes/PUMPKIN/Preprocessed/groupA/Volumes’;
evpath = ‘/Volumes/PUMPKIN/Regressors’;
for n = 1:nrun
sub_path = fullfile(‘/Volumes/PUMPKIN/halfpipeXspm/sub-‘, num2str(sub(n)), ‘/1stLevel’);
%mkdir(sub_path);
inputs{1, n} = {sub_path}; % fMRI model specification: Directory – cfg_files
% Loop through each run for the subject
for run = 1:ncue
run_dir = fullfile(homepath, strcat(‘sub_’, num2str(sub(n))), ‘-‘, num2str(run));
% List all ‘vol_*.nii’ files in the current folder
files = dir(fullfile(run_dir, ‘vol_*.nii’));
if ~isempty(files)
% Now assign images
inputs{2+(run-1)*3, n} = {fullfile(run_dir, {files.name})}; % fMRI model specification: Scans – cfg_files
% Insert multiple condition files (i.e., evs)
ev_file = dir(fullfile(evpath, strcat(‘sub’, num2str(sub(n)), ‘run’, num2str(run), ‘_exev_CS_faceCue.mat’)));
inputs{3+(run-1)*3, n} = {fullfile(evpath, ev_file.name)};
% Insert multiple regressors (6 rigid body motion parameters)
rp_file = dir(fullfile(run_dir, ‘rp_af*.txt’));
inputs{4+(run-1)*3, n} = {fullfile(run_dir, rp_file.name)};
end
clear files rp_file
end
clear currfold
end
% Run the job using SPM
spm_jobman(‘run’, jobs, inputs);
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% ModelSpecificationBinaryMask_job.m
%———————————————————————–
% Job saved on 17-Jun-2016 14:21:03 by cfg_util (rev $Rev: 6134 $)
% spm SPM – SPM12 (6225)
% cfg_basicio BasicIO – Unknown
%———————————————————————–
disp(‘Script is running’);
matlabbatch(1).spm.stats.fmri_spec.dir = {‘/Volumes/PUMPKIN/halfpipeXspm/sub-*/1stLevel’};
matlabbatch(1).spm.stats.fmri_spec.timing.units = ‘secs’;
matlabbatch(1).spm.stats.fmri_spec.timing.RT = 2;
matlabbatch(1).spm.stats.fmri_spec.timing.fmri_t = 32;
matlabbatch(1).spm.stats.fmri_spec.timing.fmri_t0 = 1;
matlabbatch(1).spm.stats.fmri_spec.sess(1).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(1).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(1).multi = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(1).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(1).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(1).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(2).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(2).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(2).multi ='<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(2).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(2).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(2).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(3).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(3).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(3).multi = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(3).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(3).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(3).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(4).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(4).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(4).multi = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(4).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(4).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(4).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(5).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(5).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(5).multi = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(5).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(5).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(5).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(6).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(6).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(6).multi = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(6).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(6).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(6).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(7).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(7).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(7).multi ='<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(7).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(7).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(7).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(8).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(8).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(8).multi = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(8).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(8).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(8).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.fact = struct(‘name’, {}, ‘levels’, {});
matlabbatch(1).spm.stats.fmri_spec.bases.hrf.derivs = [0 0];
matlabbatch(1).spm.stats.fmri_spec.volt = 1;
matlabbatch(1).spm.stats.fmri_spec.global = ‘None’;
matlabbatch(1).spm.stats.fmri_spec.mthresh = 0.0; %no voxels are thresholded so all voxels are being used%
matlabbatch(1).spm.stats.fmri_spec.mask = {‘/Volumes/PUMPKIN/scripts/LancyScripts/peripheral/C1-101-117/binarygreymattermask.nii’};
matlabbatch(1).spm.stats.fmri_spec.cvi = ‘AR(1)’;
disp(‘Script completed’);Dear Matlab communities:
I am running a spm script for analyizing neuroimaging data, the first script here (ModelSpecificationBinaryMask.m) is to loop another job file ModelSpecificationBinaryMask_job.m over the two subjects while assigning the regressor files that correspond to each of the runs for one subject.
However, I am seeing the follwing errors:
Brace indexing is not supported for variables of this type.
Error in spm_jobman>canonicalise_jobs (line 415)
comp(i) = comp(i) && any(strcmp(fieldnames(job{i}{j}), …
Error in spm_jobman (line 152)
mljob = canonicalise_jobs(jobs);
Error in ModelSpecificationBinaryMask (line 50)
spm_jobman(‘run’, jobs, inputs);
ModelSpecificationBinaryMask.m
clear
close all
clc
% Created by GB on 9/9/19.
% Edited by LC on 8/19/24.
for sub = [101,102]
jobfile = {‘/Volumes/PUMPKIN/scripts/GabbyScripts/ModelSpecificationBinaryMaskTHRESHOFF_job.m’};
nrun = 1; % Assuming nrun should be 1 since we are processing one subject at a time
ncue = 8; % 8 runs for cue task
jobs = repmat(jobfile, 1, nrun);
inputs = cell(25, 1); % Initialize cell array for inputs (25 because you have 3 inputs per run and 8 runs)
% Create a homepath, a base location of all the data
homepath = ‘/Volumes/PUMPKIN/Preprocessed/groupA/Volumes’;
evpath = ‘/Volumes/PUMPKIN/Regressors’;
for n = 1:nrun
sub_path = fullfile(‘/Volumes/PUMPKIN/halfpipeXspm/sub-‘, num2str(sub(n)), ‘/1stLevel’);
%mkdir(sub_path);
inputs{1, n} = {sub_path}; % fMRI model specification: Directory – cfg_files
% Loop through each run for the subject
for run = 1:ncue
run_dir = fullfile(homepath, strcat(‘sub_’, num2str(sub(n))), ‘-‘, num2str(run));
% List all ‘vol_*.nii’ files in the current folder
files = dir(fullfile(run_dir, ‘vol_*.nii’));
if ~isempty(files)
% Now assign images
inputs{2+(run-1)*3, n} = {fullfile(run_dir, {files.name})}; % fMRI model specification: Scans – cfg_files
% Insert multiple condition files (i.e., evs)
ev_file = dir(fullfile(evpath, strcat(‘sub’, num2str(sub(n)), ‘run’, num2str(run), ‘_exev_CS_faceCue.mat’)));
inputs{3+(run-1)*3, n} = {fullfile(evpath, ev_file.name)};
% Insert multiple regressors (6 rigid body motion parameters)
rp_file = dir(fullfile(run_dir, ‘rp_af*.txt’));
inputs{4+(run-1)*3, n} = {fullfile(run_dir, rp_file.name)};
end
clear files rp_file
end
clear currfold
end
% Run the job using SPM
spm_jobman(‘run’, jobs, inputs);
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% ModelSpecificationBinaryMask_job.m
%———————————————————————–
% Job saved on 17-Jun-2016 14:21:03 by cfg_util (rev $Rev: 6134 $)
% spm SPM – SPM12 (6225)
% cfg_basicio BasicIO – Unknown
%———————————————————————–
disp(‘Script is running’);
matlabbatch(1).spm.stats.fmri_spec.dir = {‘/Volumes/PUMPKIN/halfpipeXspm/sub-*/1stLevel’};
matlabbatch(1).spm.stats.fmri_spec.timing.units = ‘secs’;
matlabbatch(1).spm.stats.fmri_spec.timing.RT = 2;
matlabbatch(1).spm.stats.fmri_spec.timing.fmri_t = 32;
matlabbatch(1).spm.stats.fmri_spec.timing.fmri_t0 = 1;
matlabbatch(1).spm.stats.fmri_spec.sess(1).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(1).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(1).multi = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(1).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(1).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(1).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(2).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(2).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(2).multi ='<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(2).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(2).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(2).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(3).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(3).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(3).multi = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(3).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(3).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(3).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(4).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(4).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(4).multi = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(4).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(4).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(4).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(5).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(5).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(5).multi = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(5).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(5).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(5).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(6).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(6).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(6).multi = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(6).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(6).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(6).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(7).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(7).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(7).multi ='<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(7).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(7).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(7).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(8).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(8).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(8).multi = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(8).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(8).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(8).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.fact = struct(‘name’, {}, ‘levels’, {});
matlabbatch(1).spm.stats.fmri_spec.bases.hrf.derivs = [0 0];
matlabbatch(1).spm.stats.fmri_spec.volt = 1;
matlabbatch(1).spm.stats.fmri_spec.global = ‘None’;
matlabbatch(1).spm.stats.fmri_spec.mthresh = 0.0; %no voxels are thresholded so all voxels are being used%
matlabbatch(1).spm.stats.fmri_spec.mask = {‘/Volumes/PUMPKIN/scripts/LancyScripts/peripheral/C1-101-117/binarygreymattermask.nii’};
matlabbatch(1).spm.stats.fmri_spec.cvi = ‘AR(1)’;
disp(‘Script completed’); Dear Matlab communities:
I am running a spm script for analyizing neuroimaging data, the first script here (ModelSpecificationBinaryMask.m) is to loop another job file ModelSpecificationBinaryMask_job.m over the two subjects while assigning the regressor files that correspond to each of the runs for one subject.
However, I am seeing the follwing errors:
Brace indexing is not supported for variables of this type.
Error in spm_jobman>canonicalise_jobs (line 415)
comp(i) = comp(i) && any(strcmp(fieldnames(job{i}{j}), …
Error in spm_jobman (line 152)
mljob = canonicalise_jobs(jobs);
Error in ModelSpecificationBinaryMask (line 50)
spm_jobman(‘run’, jobs, inputs);
ModelSpecificationBinaryMask.m
clear
close all
clc
% Created by GB on 9/9/19.
% Edited by LC on 8/19/24.
for sub = [101,102]
jobfile = {‘/Volumes/PUMPKIN/scripts/GabbyScripts/ModelSpecificationBinaryMaskTHRESHOFF_job.m’};
nrun = 1; % Assuming nrun should be 1 since we are processing one subject at a time
ncue = 8; % 8 runs for cue task
jobs = repmat(jobfile, 1, nrun);
inputs = cell(25, 1); % Initialize cell array for inputs (25 because you have 3 inputs per run and 8 runs)
% Create a homepath, a base location of all the data
homepath = ‘/Volumes/PUMPKIN/Preprocessed/groupA/Volumes’;
evpath = ‘/Volumes/PUMPKIN/Regressors’;
for n = 1:nrun
sub_path = fullfile(‘/Volumes/PUMPKIN/halfpipeXspm/sub-‘, num2str(sub(n)), ‘/1stLevel’);
%mkdir(sub_path);
inputs{1, n} = {sub_path}; % fMRI model specification: Directory – cfg_files
% Loop through each run for the subject
for run = 1:ncue
run_dir = fullfile(homepath, strcat(‘sub_’, num2str(sub(n))), ‘-‘, num2str(run));
% List all ‘vol_*.nii’ files in the current folder
files = dir(fullfile(run_dir, ‘vol_*.nii’));
if ~isempty(files)
% Now assign images
inputs{2+(run-1)*3, n} = {fullfile(run_dir, {files.name})}; % fMRI model specification: Scans – cfg_files
% Insert multiple condition files (i.e., evs)
ev_file = dir(fullfile(evpath, strcat(‘sub’, num2str(sub(n)), ‘run’, num2str(run), ‘_exev_CS_faceCue.mat’)));
inputs{3+(run-1)*3, n} = {fullfile(evpath, ev_file.name)};
% Insert multiple regressors (6 rigid body motion parameters)
rp_file = dir(fullfile(run_dir, ‘rp_af*.txt’));
inputs{4+(run-1)*3, n} = {fullfile(run_dir, rp_file.name)};
end
clear files rp_file
end
clear currfold
end
% Run the job using SPM
spm_jobman(‘run’, jobs, inputs);
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% ModelSpecificationBinaryMask_job.m
%———————————————————————–
% Job saved on 17-Jun-2016 14:21:03 by cfg_util (rev $Rev: 6134 $)
% spm SPM – SPM12 (6225)
% cfg_basicio BasicIO – Unknown
%———————————————————————–
disp(‘Script is running’);
matlabbatch(1).spm.stats.fmri_spec.dir = {‘/Volumes/PUMPKIN/halfpipeXspm/sub-*/1stLevel’};
matlabbatch(1).spm.stats.fmri_spec.timing.units = ‘secs’;
matlabbatch(1).spm.stats.fmri_spec.timing.RT = 2;
matlabbatch(1).spm.stats.fmri_spec.timing.fmri_t = 32;
matlabbatch(1).spm.stats.fmri_spec.timing.fmri_t0 = 1;
matlabbatch(1).spm.stats.fmri_spec.sess(1).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(1).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(1).multi = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(1).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(1).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(1).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(2).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(2).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(2).multi ='<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(2).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(2).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(2).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(3).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(3).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(3).multi = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(3).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(3).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(3).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(4).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(4).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(4).multi = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(4).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(4).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(4).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(5).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(5).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(5).multi = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(5).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(5).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(5).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(6).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(6).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(6).multi = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(6).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(6).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(6).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(7).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(7).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(7).multi ='<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(7).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(7).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(7).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.sess(8).scans = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(8).cond = struct(‘name’, {}, ‘onset’, {}, ‘duration’, {}, ‘tmod’, {}, ‘pmod’, {}, ‘orth’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(8).multi = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(8).regress = struct(‘name’, {}, ‘val’, {});
matlabbatch(1).spm.stats.fmri_spec.sess(8).multi_reg = ‘<UNDEFINED>’;
matlabbatch(1).spm.stats.fmri_spec.sess(8).hpf = 128;
matlabbatch(1).spm.stats.fmri_spec.fact = struct(‘name’, {}, ‘levels’, {});
matlabbatch(1).spm.stats.fmri_spec.bases.hrf.derivs = [0 0];
matlabbatch(1).spm.stats.fmri_spec.volt = 1;
matlabbatch(1).spm.stats.fmri_spec.global = ‘None’;
matlabbatch(1).spm.stats.fmri_spec.mthresh = 0.0; %no voxels are thresholded so all voxels are being used%
matlabbatch(1).spm.stats.fmri_spec.mask = {‘/Volumes/PUMPKIN/scripts/LancyScripts/peripheral/C1-101-117/binarygreymattermask.nii’};
matlabbatch(1).spm.stats.fmri_spec.cvi = ‘AR(1)’;
disp(‘Script completed’); spm, image processing, error MATLAB Answers — New Questions
Is there an “inverse” of decsg?
Is there a function that is like the invese of decsg? By that I mean: dl = decsg(gd) takes a geometry description matrix gd and returns a decomposed geometry description matrix dl. But what I need is the opposite: Given dl I need to "reconstitute" gd.Is there a function that is like the invese of decsg? By that I mean: dl = decsg(gd) takes a geometry description matrix gd and returns a decomposed geometry description matrix dl. But what I need is the opposite: Given dl I need to "reconstitute" gd. Is there a function that is like the invese of decsg? By that I mean: dl = decsg(gd) takes a geometry description matrix gd and returns a decomposed geometry description matrix dl. But what I need is the opposite: Given dl I need to "reconstitute" gd. decsg, geometry, pde toolbox MATLAB Answers — New Questions
VariSpec software in conjunction with MATLAB
I’m currently trying to use a laser alongside a VariSpec Liquid Crystal Tunable Filter (LCTF) for fluorescent imaging microscopy. Long story short, the software that goes with the microscope is Micro-Manager and the software for the LCTF is VSGUI (or VariSpecGUI).
I want to write code that will effectively carry out a sequence of events on the VSGUI and MM software for me using MATLAB, automatically. From what I’ve read, this is fairly straightforward to do for the Micro-Manager software as there’s some pre-written .m files / script that can be used for the operation of MM and if push comes to shove there is also the Microscopy Toolbox. However, with the VariSpec VSGUI software, I’m struggling to find any files relating to it. I know they exist because the manual for the LCTF states "CRi provides a set of MATLAB files to control VariSpec filters. There is a core support .DLL file and a series of .m files"
So great, the files exist and I don’t need to start from scratch, however, this CRi company does not seem to exist (think it might have been bought over?) and there are no websites that I can find with the files.
Long shot, but does anyone have any of the files that I’m talking about to operate the VariSpec filters?
I don’t think I’m fully capable of writing out a full script from scratch.I’m currently trying to use a laser alongside a VariSpec Liquid Crystal Tunable Filter (LCTF) for fluorescent imaging microscopy. Long story short, the software that goes with the microscope is Micro-Manager and the software for the LCTF is VSGUI (or VariSpecGUI).
I want to write code that will effectively carry out a sequence of events on the VSGUI and MM software for me using MATLAB, automatically. From what I’ve read, this is fairly straightforward to do for the Micro-Manager software as there’s some pre-written .m files / script that can be used for the operation of MM and if push comes to shove there is also the Microscopy Toolbox. However, with the VariSpec VSGUI software, I’m struggling to find any files relating to it. I know they exist because the manual for the LCTF states "CRi provides a set of MATLAB files to control VariSpec filters. There is a core support .DLL file and a series of .m files"
So great, the files exist and I don’t need to start from scratch, however, this CRi company does not seem to exist (think it might have been bought over?) and there are no websites that I can find with the files.
Long shot, but does anyone have any of the files that I’m talking about to operate the VariSpec filters?
I don’t think I’m fully capable of writing out a full script from scratch. I’m currently trying to use a laser alongside a VariSpec Liquid Crystal Tunable Filter (LCTF) for fluorescent imaging microscopy. Long story short, the software that goes with the microscope is Micro-Manager and the software for the LCTF is VSGUI (or VariSpecGUI).
I want to write code that will effectively carry out a sequence of events on the VSGUI and MM software for me using MATLAB, automatically. From what I’ve read, this is fairly straightforward to do for the Micro-Manager software as there’s some pre-written .m files / script that can be used for the operation of MM and if push comes to shove there is also the Microscopy Toolbox. However, with the VariSpec VSGUI software, I’m struggling to find any files relating to it. I know they exist because the manual for the LCTF states "CRi provides a set of MATLAB files to control VariSpec filters. There is a core support .DLL file and a series of .m files"
So great, the files exist and I don’t need to start from scratch, however, this CRi company does not seem to exist (think it might have been bought over?) and there are no websites that I can find with the files.
Long shot, but does anyone have any of the files that I’m talking about to operate the VariSpec filters?
I don’t think I’m fully capable of writing out a full script from scratch. varispec, .m files, vsgui, lctf, software MATLAB Answers — New Questions
R2018b does not complete initialisation
I have been using R2018b successfully for some time, but a few days ago it stopped working.
When I launch Matlab now it remains in the ‘Initialising’ state until I close it down. I cannot navigate to a folder or open the project or model.
I also have R2020b installed and that is still working ok.
There are no errors or warnings displayed.
I checked all the things mentioned in other similar discussions – license is ok, the preferences are not corrupted, the R2XXXx folder is not corrupted, stopping virus protection makes no difference.
I executed the command "matlab -timing" and the timing log contains this:
MATLAB Startup Performance Metrics (In Seconds)
total item gap description
=========================================================
0.00 0.00 0.00 MATLAB script
0.13 0.13 0.00 main
1.11 0.99 -0.00 Session Initialize
1.26 0.00 0.15 Toolbox cache load Start
1.30 0.05 0.00 LM Startup
1.58 0.01 0.27 splash
2.34 0.18 0.58 Constant Initialization
2.36 0.78 0.00 Engine Startup
2.58 0.22 0.00 InitSunVM
6.27 3.55 0.15 PostVMInit
6.28 3.92 0.00 mljInit
6.75 0.47 0.00 StartDesktop
6.75 4.39 0.00 Java initialization
6.89 0.01 0.13 psParser
9.18 2.43 6.75 Init Desktop
Any help would be much appreciated.I have been using R2018b successfully for some time, but a few days ago it stopped working.
When I launch Matlab now it remains in the ‘Initialising’ state until I close it down. I cannot navigate to a folder or open the project or model.
I also have R2020b installed and that is still working ok.
There are no errors or warnings displayed.
I checked all the things mentioned in other similar discussions – license is ok, the preferences are not corrupted, the R2XXXx folder is not corrupted, stopping virus protection makes no difference.
I executed the command "matlab -timing" and the timing log contains this:
MATLAB Startup Performance Metrics (In Seconds)
total item gap description
=========================================================
0.00 0.00 0.00 MATLAB script
0.13 0.13 0.00 main
1.11 0.99 -0.00 Session Initialize
1.26 0.00 0.15 Toolbox cache load Start
1.30 0.05 0.00 LM Startup
1.58 0.01 0.27 splash
2.34 0.18 0.58 Constant Initialization
2.36 0.78 0.00 Engine Startup
2.58 0.22 0.00 InitSunVM
6.27 3.55 0.15 PostVMInit
6.28 3.92 0.00 mljInit
6.75 0.47 0.00 StartDesktop
6.75 4.39 0.00 Java initialization
6.89 0.01 0.13 psParser
9.18 2.43 6.75 Init Desktop
Any help would be much appreciated. I have been using R2018b successfully for some time, but a few days ago it stopped working.
When I launch Matlab now it remains in the ‘Initialising’ state until I close it down. I cannot navigate to a folder or open the project or model.
I also have R2020b installed and that is still working ok.
There are no errors or warnings displayed.
I checked all the things mentioned in other similar discussions – license is ok, the preferences are not corrupted, the R2XXXx folder is not corrupted, stopping virus protection makes no difference.
I executed the command "matlab -timing" and the timing log contains this:
MATLAB Startup Performance Metrics (In Seconds)
total item gap description
=========================================================
0.00 0.00 0.00 MATLAB script
0.13 0.13 0.00 main
1.11 0.99 -0.00 Session Initialize
1.26 0.00 0.15 Toolbox cache load Start
1.30 0.05 0.00 LM Startup
1.58 0.01 0.27 splash
2.34 0.18 0.58 Constant Initialization
2.36 0.78 0.00 Engine Startup
2.58 0.22 0.00 InitSunVM
6.27 3.55 0.15 PostVMInit
6.28 3.92 0.00 mljInit
6.75 0.47 0.00 StartDesktop
6.75 4.39 0.00 Java initialization
6.89 0.01 0.13 psParser
9.18 2.43 6.75 Init Desktop
Any help would be much appreciated. r2018b, startup MATLAB Answers — New Questions
Find strings within other strings then pull data from that point
dear collegaes, please let me ask your help to find a solution for my data analisys.
I have a P0300.txt file that contains a long strip.
here is a portion of P0300.txt:
59 04 03 01 00 65 01 3E 51 09 00 00 51 1C 00 E1
I need to find sets of data, sets could be 2 or 4 digits.
lets say I need to find 01 3E
DATA = regexp(fileread(‘P0300.txt’), ‘r?n’, ‘split’)’;
>> A = string(DATA);
>> B = strfind(A,’01 3E’);
B gives me the position where 01 3E is, in this case B = 19
after this I need to extract the 6 digits on the rigth 51 09 00 <– this values can change depend on test conditions
Any idea on how can I do that?
your feedback will be highly appreciateddear collegaes, please let me ask your help to find a solution for my data analisys.
I have a P0300.txt file that contains a long strip.
here is a portion of P0300.txt:
59 04 03 01 00 65 01 3E 51 09 00 00 51 1C 00 E1
I need to find sets of data, sets could be 2 or 4 digits.
lets say I need to find 01 3E
DATA = regexp(fileread(‘P0300.txt’), ‘r?n’, ‘split’)’;
>> A = string(DATA);
>> B = strfind(A,’01 3E’);
B gives me the position where 01 3E is, in this case B = 19
after this I need to extract the 6 digits on the rigth 51 09 00 <– this values can change depend on test conditions
Any idea on how can I do that?
your feedback will be highly appreciated dear collegaes, please let me ask your help to find a solution for my data analisys.
I have a P0300.txt file that contains a long strip.
here is a portion of P0300.txt:
59 04 03 01 00 65 01 3E 51 09 00 00 51 1C 00 E1
I need to find sets of data, sets could be 2 or 4 digits.
lets say I need to find 01 3E
DATA = regexp(fileread(‘P0300.txt’), ‘r?n’, ‘split’)’;
>> A = string(DATA);
>> B = strfind(A,’01 3E’);
B gives me the position where 01 3E is, in this case B = 19
after this I need to extract the 6 digits on the rigth 51 09 00 <– this values can change depend on test conditions
Any idea on how can I do that?
your feedback will be highly appreciated strings, text, data MATLAB Answers — New Questions