Category: Matlab
Category Archives: Matlab
Calculating Surface Curvature from Image Data
Hello,
I’m trying to calculate the curvature of each surface point from a morphology picture. However, when using surfature(), I do not get the results I want. A lot of points have a gaussian curvature of 0, which is not plausible for the example I use.
I tried a lot of different methods for calculating and ploting, but never got a good result…
I wrote the following:
% reading in picture
data = imread("Morphology.PNG");
% if not yet, convert to gray image
if size(data, 3) == 3
data = rgb2gray(data);
end
% smoothing image
data = imgaussfilt(data, 4);
% converting to double
data = double(data);
z = data;
% generating 2D arrays for X and Y with size of data-dimensions
[Rows, Cols] = size(data);
[x, y] = meshgrid(1:Cols, 1:Rows);
% calculating gaussian and normal curvature
[K, H] = surfature(x, y, data);
% display surface
figure;
surf(x, y, z, "EdgeColor","none");
title(‘Surface Morphology’);
colorbar;
% ploting the results
figure;
surf(x, y, z, K, "EdgeColor","none");
title(‘3D Surface Gaussian Curvature Map’);
colorbar;
disp(K);Hello,
I’m trying to calculate the curvature of each surface point from a morphology picture. However, when using surfature(), I do not get the results I want. A lot of points have a gaussian curvature of 0, which is not plausible for the example I use.
I tried a lot of different methods for calculating and ploting, but never got a good result…
I wrote the following:
% reading in picture
data = imread("Morphology.PNG");
% if not yet, convert to gray image
if size(data, 3) == 3
data = rgb2gray(data);
end
% smoothing image
data = imgaussfilt(data, 4);
% converting to double
data = double(data);
z = data;
% generating 2D arrays for X and Y with size of data-dimensions
[Rows, Cols] = size(data);
[x, y] = meshgrid(1:Cols, 1:Rows);
% calculating gaussian and normal curvature
[K, H] = surfature(x, y, data);
% display surface
figure;
surf(x, y, z, "EdgeColor","none");
title(‘Surface Morphology’);
colorbar;
% ploting the results
figure;
surf(x, y, z, K, "EdgeColor","none");
title(‘3D Surface Gaussian Curvature Map’);
colorbar;
disp(K); Hello,
I’m trying to calculate the curvature of each surface point from a morphology picture. However, when using surfature(), I do not get the results I want. A lot of points have a gaussian curvature of 0, which is not plausible for the example I use.
I tried a lot of different methods for calculating and ploting, but never got a good result…
I wrote the following:
% reading in picture
data = imread("Morphology.PNG");
% if not yet, convert to gray image
if size(data, 3) == 3
data = rgb2gray(data);
end
% smoothing image
data = imgaussfilt(data, 4);
% converting to double
data = double(data);
z = data;
% generating 2D arrays for X and Y with size of data-dimensions
[Rows, Cols] = size(data);
[x, y] = meshgrid(1:Cols, 1:Rows);
% calculating gaussian and normal curvature
[K, H] = surfature(x, y, data);
% display surface
figure;
surf(x, y, z, "EdgeColor","none");
title(‘Surface Morphology’);
colorbar;
% ploting the results
figure;
surf(x, y, z, K, "EdgeColor","none");
title(‘3D Surface Gaussian Curvature Map’);
colorbar;
disp(K); surfature, surface, curvature, image processing MATLAB Answers — New Questions
“Application install was not successful” when trying to install Matlab app
When trying to install an app (compiled app designer app) I’m receiving ""Application install was not successful".
I have tested:
Several different installers/apps (all have previously worked and works on other systems)
Uninstalled and reinstalled both Matlab and Matlab runtime
Cleared the Matlab folders in AppData Local and Roaming
Rebooted my system
Verified that there are no remaining files in the installation directory from previous installs.
Booting the .exe installer from various locations
After booting the installer .exe I get to the Windows User Account Control. After accepting, the matlab installer window flashes up shortly before presenting the below message.
Any suggestions on how to proceed?When trying to install an app (compiled app designer app) I’m receiving ""Application install was not successful".
I have tested:
Several different installers/apps (all have previously worked and works on other systems)
Uninstalled and reinstalled both Matlab and Matlab runtime
Cleared the Matlab folders in AppData Local and Roaming
Rebooted my system
Verified that there are no remaining files in the installation directory from previous installs.
Booting the .exe installer from various locations
After booting the installer .exe I get to the Windows User Account Control. After accepting, the matlab installer window flashes up shortly before presenting the below message.
Any suggestions on how to proceed? When trying to install an app (compiled app designer app) I’m receiving ""Application install was not successful".
I have tested:
Several different installers/apps (all have previously worked and works on other systems)
Uninstalled and reinstalled both Matlab and Matlab runtime
Cleared the Matlab folders in AppData Local and Roaming
Rebooted my system
Verified that there are no remaining files in the installation directory from previous installs.
Booting the .exe installer from various locations
After booting the installer .exe I get to the Windows User Account Control. After accepting, the matlab installer window flashes up shortly before presenting the below message.
Any suggestions on how to proceed? matlab app installer, installer, matlab application, application install was not successful MATLAB Answers — New Questions
How can I connect matlab with MAXM86146?
I would analyze the data of MAXM86146I would analyze the data of MAXM86146 I would analyze the data of MAXM86146 sofware, maxm86146 MATLAB Answers — New Questions
How to integrate system GPU with MATLAB?
Hi,
Aatually, I am working on deep learning project. I am train a custom model with different pretrained model. While I am training it take too much time to train a model. So, I go throught with gpu but I saw it’s support on nvidia gpu. And I have 8GB intel GPU on my system but I am uable to integrate with MATLAB. Could you please help to integrate GPU with MATLAB.Hi,
Aatually, I am working on deep learning project. I am train a custom model with different pretrained model. While I am training it take too much time to train a model. So, I go throught with gpu but I saw it’s support on nvidia gpu. And I have 8GB intel GPU on my system but I am uable to integrate with MATLAB. Could you please help to integrate GPU with MATLAB. Hi,
Aatually, I am working on deep learning project. I am train a custom model with different pretrained model. While I am training it take too much time to train a model. So, I go throught with gpu but I saw it’s support on nvidia gpu. And I have 8GB intel GPU on my system but I am uable to integrate with MATLAB. Could you please help to integrate GPU with MATLAB. image processing, deep learning, gpu, intel MATLAB Answers — New Questions
Triangulation of hollow objects
Hi all,
simply, how to make the simple hollow 3D triangle depicted below?
Is there some contraint method I could use instead? I use the following command to get the surface:
tri = triangulation(delaunay(x,y),x,y,z);Hi all,
simply, how to make the simple hollow 3D triangle depicted below?
Is there some contraint method I could use instead? I use the following command to get the surface:
tri = triangulation(delaunay(x,y),x,y,z); Hi all,
simply, how to make the simple hollow 3D triangle depicted below?
Is there some contraint method I could use instead? I use the following command to get the surface:
tri = triangulation(delaunay(x,y),x,y,z); delaunay, triangulation MATLAB Answers — New Questions
how print multiple values on screen in one line in matlab
I am doing image image processing in matlab , so if many object will be detected at once, then i want multiple vallues in at once in one line . I mean I will be getting cordinates of every box which is detected .I am doing image image processing in matlab , so if many object will be detected at once, then i want multiple vallues in at once in one line . I mean I will be getting cordinates of every box which is detected . I am doing image image processing in matlab , so if many object will be detected at once, then i want multiple vallues in at once in one line . I mean I will be getting cordinates of every box which is detected . image processing, fprintf MATLAB Answers — New Questions
How to connect MATLAB on windows OS to Clickhouse database server on a cloud Linux virtual machine?
Hi,
My computations are stored in a Clickhouse databse server on a Linux (Ubuntu) virtual machine (VM). I would like to access the data from the Clickhouse server on the VM to MATLAB in my local machine on windows OS, so that I can process the data locally.
I tried to explore the database tool box, but since I am new to this, I haven’t been able to connect to the database on the VM.
I would appreciate pointers from the experts.
Thanks in advance.Hi,
My computations are stored in a Clickhouse databse server on a Linux (Ubuntu) virtual machine (VM). I would like to access the data from the Clickhouse server on the VM to MATLAB in my local machine on windows OS, so that I can process the data locally.
I tried to explore the database tool box, but since I am new to this, I haven’t been able to connect to the database on the VM.
I would appreciate pointers from the experts.
Thanks in advance. Hi,
My computations are stored in a Clickhouse databse server on a Linux (Ubuntu) virtual machine (VM). I would like to access the data from the Clickhouse server on the VM to MATLAB in my local machine on windows OS, so that I can process the data locally.
I tried to explore the database tool box, but since I am new to this, I haven’t been able to connect to the database on the VM.
I would appreciate pointers from the experts.
Thanks in advance. database, clickhouse MATLAB Answers — New Questions
Error using barrier Objective function is undefined at initial point. Fmincon cannot continue.Error in Calibration (line 161) [x, fval ] = fmincon(GGG, x0, A, b, Aeq, beq, lb,
Hello,
Please can someone help me solve this issue. I keep getting the below error. Attached also is my matlab codes.
Thanks,
Celestine.
>> Calibration
Error using barrier
Objective function is undefined at initial point. Fmincon cannot continue.
Error in fmincon (line 861)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] =
barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, …
Error in Calibration (line 161)
[x, fval ] = fmincon(GGG, x0, A, b, Aeq, beq, lb, ub, nonlcon, opts);Hello,
Please can someone help me solve this issue. I keep getting the below error. Attached also is my matlab codes.
Thanks,
Celestine.
>> Calibration
Error using barrier
Objective function is undefined at initial point. Fmincon cannot continue.
Error in fmincon (line 861)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] =
barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, …
Error in Calibration (line 161)
[x, fval ] = fmincon(GGG, x0, A, b, Aeq, beq, lb, ub, nonlcon, opts); Hello,
Please can someone help me solve this issue. I keep getting the below error. Attached also is my matlab codes.
Thanks,
Celestine.
>> Calibration
Error using barrier
Objective function is undefined at initial point. Fmincon cannot continue.
Error in fmincon (line 861)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] =
barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, …
Error in Calibration (line 161)
[x, fval ] = fmincon(GGG, x0, A, b, Aeq, beq, lb, ub, nonlcon, opts); fmincon, optimization MATLAB Answers — New Questions
Nonorthogonal eigenvectors for general eigenvalue problem with eig() and eigs()
I am working with a finite element model and want to decompose my system using the eigenvectors of the system. The eigenvalue problem is of the form: K*V = M*V*D, where V is the eigenvector matrix and D is the eigenvalue matrix. Both M and K are block diagonal symmetric matrices. For the generalized eigenvalue problem it should be the case that V’*M*V = a matrix whose only nonzero terms are along the diagonal, but I am getting nonzero terms on either side of these. Using the code included below for something like N =5, I get (after rounding to nearest 3rd decimal to remove near zero terms)
abs( Orthgonal_Check_eig) = [ 78.8050 0 0 0 0
0 43.4540 0 0 0
0 0 0 34.9310 0
0 0 34.9310 0 0
0 0 0 0 29.6430]
Where I am taking the absolute value because this case has complex eigenvectors (though I believe I’ve seen it with real eigenvector matrices as well). If I rerun the code it does not always happen, but I am trying to understand why this can occur for both eig() and eigs() so that I can determine if it is the conditioning of the matrices or if it is inherent to the approximations inside of eig() and eigs(). Is there a better one of the two to use to avoid this issue?
N = 5;
M = zeros(N,N);
K = zeros(N,N);
for ii = 1:N
% Diagonal Terms
M(ii,ii) = rand*50;
K(ii,ii) = rand*500;
if ii ~=N
% Off Diagonal Terms
off_diagonal = rand*50;
M(ii,ii+1) = off_diagonal;
K(ii,ii+1) = off_diagonal*10;
M(ii+1,ii) = off_diagonal;
K(ii+1,ii) = off_diagonal*10;
end
end
M= round(M);
K= round(K);
[Veig,~] = eig(K,M);
[Veigs,~] = eigs(K,M,3);
Orthgonal_Check_eig = Veig’*M*Veig;
Orthgonal_Check_eigs =Veigs’*M*Veigs;I am working with a finite element model and want to decompose my system using the eigenvectors of the system. The eigenvalue problem is of the form: K*V = M*V*D, where V is the eigenvector matrix and D is the eigenvalue matrix. Both M and K are block diagonal symmetric matrices. For the generalized eigenvalue problem it should be the case that V’*M*V = a matrix whose only nonzero terms are along the diagonal, but I am getting nonzero terms on either side of these. Using the code included below for something like N =5, I get (after rounding to nearest 3rd decimal to remove near zero terms)
abs( Orthgonal_Check_eig) = [ 78.8050 0 0 0 0
0 43.4540 0 0 0
0 0 0 34.9310 0
0 0 34.9310 0 0
0 0 0 0 29.6430]
Where I am taking the absolute value because this case has complex eigenvectors (though I believe I’ve seen it with real eigenvector matrices as well). If I rerun the code it does not always happen, but I am trying to understand why this can occur for both eig() and eigs() so that I can determine if it is the conditioning of the matrices or if it is inherent to the approximations inside of eig() and eigs(). Is there a better one of the two to use to avoid this issue?
N = 5;
M = zeros(N,N);
K = zeros(N,N);
for ii = 1:N
% Diagonal Terms
M(ii,ii) = rand*50;
K(ii,ii) = rand*500;
if ii ~=N
% Off Diagonal Terms
off_diagonal = rand*50;
M(ii,ii+1) = off_diagonal;
K(ii,ii+1) = off_diagonal*10;
M(ii+1,ii) = off_diagonal;
K(ii+1,ii) = off_diagonal*10;
end
end
M= round(M);
K= round(K);
[Veig,~] = eig(K,M);
[Veigs,~] = eigs(K,M,3);
Orthgonal_Check_eig = Veig’*M*Veig;
Orthgonal_Check_eigs =Veigs’*M*Veigs; I am working with a finite element model and want to decompose my system using the eigenvectors of the system. The eigenvalue problem is of the form: K*V = M*V*D, where V is the eigenvector matrix and D is the eigenvalue matrix. Both M and K are block diagonal symmetric matrices. For the generalized eigenvalue problem it should be the case that V’*M*V = a matrix whose only nonzero terms are along the diagonal, but I am getting nonzero terms on either side of these. Using the code included below for something like N =5, I get (after rounding to nearest 3rd decimal to remove near zero terms)
abs( Orthgonal_Check_eig) = [ 78.8050 0 0 0 0
0 43.4540 0 0 0
0 0 0 34.9310 0
0 0 34.9310 0 0
0 0 0 0 29.6430]
Where I am taking the absolute value because this case has complex eigenvectors (though I believe I’ve seen it with real eigenvector matrices as well). If I rerun the code it does not always happen, but I am trying to understand why this can occur for both eig() and eigs() so that I can determine if it is the conditioning of the matrices or if it is inherent to the approximations inside of eig() and eigs(). Is there a better one of the two to use to avoid this issue?
N = 5;
M = zeros(N,N);
K = zeros(N,N);
for ii = 1:N
% Diagonal Terms
M(ii,ii) = rand*50;
K(ii,ii) = rand*500;
if ii ~=N
% Off Diagonal Terms
off_diagonal = rand*50;
M(ii,ii+1) = off_diagonal;
K(ii,ii+1) = off_diagonal*10;
M(ii+1,ii) = off_diagonal;
K(ii+1,ii) = off_diagonal*10;
end
end
M= round(M);
K= round(K);
[Veig,~] = eig(K,M);
[Veigs,~] = eigs(K,M,3);
Orthgonal_Check_eig = Veig’*M*Veig;
Orthgonal_Check_eigs =Veigs’*M*Veigs; eigenvalue problem, eig, eigs, orthogonality MATLAB Answers — New Questions
How to use previous version of matlab online?
I have a code written in matlab 2012a and I want to use matlab 2012a to run it online. However, my online version is 2020b. Can you suggest a way to use the previous version online ?I have a code written in matlab 2012a and I want to use matlab 2012a to run it online. However, my online version is 2020b. Can you suggest a way to use the previous version online ? I have a code written in matlab 2012a and I want to use matlab 2012a to run it online. However, my online version is 2020b. Can you suggest a way to use the previous version online ? matlab compiler MATLAB Answers — New Questions
Problem with Simscape Onramp task 9
Hello, I can´t answer the last task, task 9, of the section 8.1 of the simscape onramp course, I do exactly what I´m requested to do but I always get it wrong, I´ve been for several hours trying it but I simply don´t understand what I´m getting wrong. I´ve looked for the answer on Youtube but literally nobady has upload it, at least I haven´t found anybody, does anybody knows how to obtain the answer or can anybody tell me where can I find the way to solve it?, thank you!Hello, I can´t answer the last task, task 9, of the section 8.1 of the simscape onramp course, I do exactly what I´m requested to do but I always get it wrong, I´ve been for several hours trying it but I simply don´t understand what I´m getting wrong. I´ve looked for the answer on Youtube but literally nobady has upload it, at least I haven´t found anybody, does anybody knows how to obtain the answer or can anybody tell me where can I find the way to solve it?, thank you! Hello, I can´t answer the last task, task 9, of the section 8.1 of the simscape onramp course, I do exactly what I´m requested to do but I always get it wrong, I´ve been for several hours trying it but I simply don´t understand what I´m getting wrong. I´ve looked for the answer on Youtube but literally nobady has upload it, at least I haven´t found anybody, does anybody knows how to obtain the answer or can anybody tell me where can I find the way to solve it?, thank you! simscape MATLAB Answers — New Questions
Matlab 2024a giving the wrong Jacobian
if I run the below code in MATLAB 2024a, jacobian is zero. However, this is wrong.
If I use "clear" instead of "clear all", the answer is correct. However, in 2023b in both cases (clear or clear all) I get the correct answer?
is this a bug? or what is the point?
clear all
clc
syms a b c d m n s r x y k
dy1 = -x*( r*x.^2 – r*(a+b)*x + a*b +(c*y-r*d));
dy2 = s + m*x-n*y ;
dr = r-x;
F=[dy1;dy2;dr]
% equilibrium_points = solve(F == 0, [x, y, r]);
% equilibrium_points = …,
% [equilibrium_points.x, equilibrium_points.y, equilibrium_points.r];
J=jacobian(F,[x y r])if I run the below code in MATLAB 2024a, jacobian is zero. However, this is wrong.
If I use "clear" instead of "clear all", the answer is correct. However, in 2023b in both cases (clear or clear all) I get the correct answer?
is this a bug? or what is the point?
clear all
clc
syms a b c d m n s r x y k
dy1 = -x*( r*x.^2 – r*(a+b)*x + a*b +(c*y-r*d));
dy2 = s + m*x-n*y ;
dr = r-x;
F=[dy1;dy2;dr]
% equilibrium_points = solve(F == 0, [x, y, r]);
% equilibrium_points = …,
% [equilibrium_points.x, equilibrium_points.y, equilibrium_points.r];
J=jacobian(F,[x y r]) if I run the below code in MATLAB 2024a, jacobian is zero. However, this is wrong.
If I use "clear" instead of "clear all", the answer is correct. However, in 2023b in both cases (clear or clear all) I get the correct answer?
is this a bug? or what is the point?
clear all
clc
syms a b c d m n s r x y k
dy1 = -x*( r*x.^2 – r*(a+b)*x + a*b +(c*y-r*d));
dy2 = s + m*x-n*y ;
dr = r-x;
F=[dy1;dy2;dr]
% equilibrium_points = solve(F == 0, [x, y, r]);
% equilibrium_points = …,
% [equilibrium_points.x, equilibrium_points.y, equilibrium_points.r];
J=jacobian(F,[x y r]) jacobian, symbolic toolbox MATLAB Answers — New Questions
How to change path scenario in Virtual Vehicle Composer?
Hello, I am developing some control logic in Virtual Vehicle Composer (VVC). There are some example scenarios like the one below. However, when I use the "Double lane change" scenario, the steering response is a bit weird (too sudden compared to other simulations such as CarSim). So, I want to know how to change the scenario or manually replace the driver model.
I tried once, but it was difficult to consider the related signals from other vehicles. If anyone has attempted this or if I could get some help regarding this, I would appreciate it.Hello, I am developing some control logic in Virtual Vehicle Composer (VVC). There are some example scenarios like the one below. However, when I use the "Double lane change" scenario, the steering response is a bit weird (too sudden compared to other simulations such as CarSim). So, I want to know how to change the scenario or manually replace the driver model.
I tried once, but it was difficult to consider the related signals from other vehicles. If anyone has attempted this or if I could get some help regarding this, I would appreciate it. Hello, I am developing some control logic in Virtual Vehicle Composer (VVC). There are some example scenarios like the one below. However, when I use the "Double lane change" scenario, the steering response is a bit weird (too sudden compared to other simulations such as CarSim). So, I want to know how to change the scenario or manually replace the driver model.
I tried once, but it was difficult to consider the related signals from other vehicles. If anyone has attempted this or if I could get some help regarding this, I would appreciate it. simulink, virtualvehiclecomposer MATLAB Answers — New Questions
How to fix this error please?
Error using eye
Requested 57660×57660 (24.8GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause
MATLAB to become unresponsive. See array size limit or preference panel for more information.
Error in Ex11_Bayes_AVO_Inversion (line 79)
Sigma_e = var_e*eye(nt*ntheta); % White noise covarianceError using eye
Requested 57660×57660 (24.8GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause
MATLAB to become unresponsive. See array size limit or preference panel for more information.
Error in Ex11_Bayes_AVO_Inversion (line 79)
Sigma_e = var_e*eye(nt*ntheta); % White noise covariance Error using eye
Requested 57660×57660 (24.8GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause
MATLAB to become unresponsive. See array size limit or preference panel for more information.
Error in Ex11_Bayes_AVO_Inversion (line 79)
Sigma_e = var_e*eye(nt*ntheta); % White noise covariance matlab error, error MATLAB Answers — New Questions
How do I extract or call a set of data like PSD(particle size distribution) to Matlab from Aspen Plus using Actxserver without using Excel?
I have been assigned a project which works by linking Aspen Plus with Matlab. What my work is to extract multiple data points to matlab using actx server. For example, I was able to get temperature & pressure data as they are single variable whereas, for Particle Size Distribution(PSD) data it cosists of an array of elements. We have mess sizes & mole fraction of crystals. How do I tell matlab to get that data from Aspen Plus? Please help me with this doubt. Currently using Aspen V12 version.I have been assigned a project which works by linking Aspen Plus with Matlab. What my work is to extract multiple data points to matlab using actx server. For example, I was able to get temperature & pressure data as they are single variable whereas, for Particle Size Distribution(PSD) data it cosists of an array of elements. We have mess sizes & mole fraction of crystals. How do I tell matlab to get that data from Aspen Plus? Please help me with this doubt. Currently using Aspen V12 version. I have been assigned a project which works by linking Aspen Plus with Matlab. What my work is to extract multiple data points to matlab using actx server. For example, I was able to get temperature & pressure data as they are single variable whereas, for Particle Size Distribution(PSD) data it cosists of an array of elements. We have mess sizes & mole fraction of crystals. How do I tell matlab to get that data from Aspen Plus? Please help me with this doubt. Currently using Aspen V12 version. matlab, aspenplus, actxserver MATLAB Answers — New Questions
Average Calculation and Array in For Loop
I collected two data sets. Data 1 collected a data point every 0.01 seconds, while Data 2 collected a data point every 1 min. They were taken at the same time, so they will have the same time stamps.
What I wanted to do was to average all the values of Data 1 for every minute, so that I will end up with the same amount of data points as Data2. I was thinking of using a for loop top iterate through every element of data1. Then, check if the minute of element i is the ssme as the minute of the previous element i-1. If so, I added the two numbers into a variable x and increased the count by count = count + 1. This went one until a new minute was reached. Then, the average of all previous elements (corresponding to the "old" minute) would be calculated by x/count. Then, this value would be appended into a new array called averages. Finally, for the new minute, the sum x would be resetted by x = data1(i) and the count would also be resetted to 1.
The code is attached below. However, when I run it it gives me the error: Error using count. Not enough input arguments. Error in plots_data (line 31): average = x / count; What is wrong?
for i = 1:length(data1)
% Check if the minute of the current data point is the same as the previous one
if i > 1 && m(i) == m(i-1) % m are the minutes
% If it is, accumulate the thrust value and increase the count
x = x + data1(i);
count = count + i;
else
% If it’s a new minute, calculate the average thrust for the previous minute
average = x / count;
averages = [averages; average];
% Reset sum and count for the new minute
x = data1(i);
count = 1;
end
endI collected two data sets. Data 1 collected a data point every 0.01 seconds, while Data 2 collected a data point every 1 min. They were taken at the same time, so they will have the same time stamps.
What I wanted to do was to average all the values of Data 1 for every minute, so that I will end up with the same amount of data points as Data2. I was thinking of using a for loop top iterate through every element of data1. Then, check if the minute of element i is the ssme as the minute of the previous element i-1. If so, I added the two numbers into a variable x and increased the count by count = count + 1. This went one until a new minute was reached. Then, the average of all previous elements (corresponding to the "old" minute) would be calculated by x/count. Then, this value would be appended into a new array called averages. Finally, for the new minute, the sum x would be resetted by x = data1(i) and the count would also be resetted to 1.
The code is attached below. However, when I run it it gives me the error: Error using count. Not enough input arguments. Error in plots_data (line 31): average = x / count; What is wrong?
for i = 1:length(data1)
% Check if the minute of the current data point is the same as the previous one
if i > 1 && m(i) == m(i-1) % m are the minutes
% If it is, accumulate the thrust value and increase the count
x = x + data1(i);
count = count + i;
else
% If it’s a new minute, calculate the average thrust for the previous minute
average = x / count;
averages = [averages; average];
% Reset sum and count for the new minute
x = data1(i);
count = 1;
end
end I collected two data sets. Data 1 collected a data point every 0.01 seconds, while Data 2 collected a data point every 1 min. They were taken at the same time, so they will have the same time stamps.
What I wanted to do was to average all the values of Data 1 for every minute, so that I will end up with the same amount of data points as Data2. I was thinking of using a for loop top iterate through every element of data1. Then, check if the minute of element i is the ssme as the minute of the previous element i-1. If so, I added the two numbers into a variable x and increased the count by count = count + 1. This went one until a new minute was reached. Then, the average of all previous elements (corresponding to the "old" minute) would be calculated by x/count. Then, this value would be appended into a new array called averages. Finally, for the new minute, the sum x would be resetted by x = data1(i) and the count would also be resetted to 1.
The code is attached below. However, when I run it it gives me the error: Error using count. Not enough input arguments. Error in plots_data (line 31): average = x / count; What is wrong?
for i = 1:length(data1)
% Check if the minute of the current data point is the same as the previous one
if i > 1 && m(i) == m(i-1) % m are the minutes
% If it is, accumulate the thrust value and increase the count
x = x + data1(i);
count = count + i;
else
% If it’s a new minute, calculate the average thrust for the previous minute
average = x / count;
averages = [averages; average];
% Reset sum and count for the new minute
x = data1(i);
count = 1;
end
end array MATLAB Answers — New Questions
convert one fixed point format to integer
I have a variable that varies from 0 to 1 and its format is 32 bit fixdt(1,32,30). I want to convert this number 0 to 1 as 0-4095. Help is required for converting fixdt(1,32,30) to 12 bits integer value ranging from 0 to 4095.I have a variable that varies from 0 to 1 and its format is 32 bit fixdt(1,32,30). I want to convert this number 0 to 1 as 0-4095. Help is required for converting fixdt(1,32,30) to 12 bits integer value ranging from 0 to 4095. I have a variable that varies from 0 to 1 and its format is 32 bit fixdt(1,32,30). I want to convert this number 0 to 1 as 0-4095. Help is required for converting fixdt(1,32,30) to 12 bits integer value ranging from 0 to 4095. data type conversion MATLAB Answers — New Questions
How to detect the specific area from an oscilloscope signal
Hello,
I don’t have any experience with MATLAB or coding, therefore I ask you about the general idea and method so that I can solve that easier.
I have two types of patterns, as shown in the attachment, the first type has the unique signal before coming back to the noise level for 0.15-0.2s. While the second one has typically longer time,
Each type has about hundreds files of similar pattern. So how can I create a a program to detect if it is type 1 or type 2 when inserting a random file (.csv format) in 2 groups?Hello,
I don’t have any experience with MATLAB or coding, therefore I ask you about the general idea and method so that I can solve that easier.
I have two types of patterns, as shown in the attachment, the first type has the unique signal before coming back to the noise level for 0.15-0.2s. While the second one has typically longer time,
Each type has about hundreds files of similar pattern. So how can I create a a program to detect if it is type 1 or type 2 when inserting a random file (.csv format) in 2 groups? Hello,
I don’t have any experience with MATLAB or coding, therefore I ask you about the general idea and method so that I can solve that easier.
I have two types of patterns, as shown in the attachment, the first type has the unique signal before coming back to the noise level for 0.15-0.2s. While the second one has typically longer time,
Each type has about hundreds files of similar pattern. So how can I create a a program to detect if it is type 1 or type 2 when inserting a random file (.csv format) in 2 groups? triboelectric, plot, csv MATLAB Answers — New Questions
mex call with fftw_threads causes CRASH AFTER CLOSING MATLAB
strange behavior:
if I work in my matlab source with fft and ifft and then call in the same source my mex-function which works with fftw_threads and of course fftw,ifft, it works very good, but after closing matlab, I’ll get "Segmentation violation detected" with something like fftw_plan_awake….
If I do this process the other way around, first call of my mex function and afterwards fft,ifft in my matlab source, closing matlab, I have no "Segmentation violation detected".
As well, if I run my mex-function without fftw_threads everything is fine!! (irrelevant if I call matlab fft then mex fct or mex fct then matlab fft)
In both source, matlab and c-mex-source, I only make some easy standard fft, nothing special. New is the try to work with fftw_threads.
My Question: what happens in the background so that matlab crashes after closing in some constellations?
Thank you!strange behavior:
if I work in my matlab source with fft and ifft and then call in the same source my mex-function which works with fftw_threads and of course fftw,ifft, it works very good, but after closing matlab, I’ll get "Segmentation violation detected" with something like fftw_plan_awake….
If I do this process the other way around, first call of my mex function and afterwards fft,ifft in my matlab source, closing matlab, I have no "Segmentation violation detected".
As well, if I run my mex-function without fftw_threads everything is fine!! (irrelevant if I call matlab fft then mex fct or mex fct then matlab fft)
In both source, matlab and c-mex-source, I only make some easy standard fft, nothing special. New is the try to work with fftw_threads.
My Question: what happens in the background so that matlab crashes after closing in some constellations?
Thank you! strange behavior:
if I work in my matlab source with fft and ifft and then call in the same source my mex-function which works with fftw_threads and of course fftw,ifft, it works very good, but after closing matlab, I’ll get "Segmentation violation detected" with something like fftw_plan_awake….
If I do this process the other way around, first call of my mex function and afterwards fft,ifft in my matlab source, closing matlab, I have no "Segmentation violation detected".
As well, if I run my mex-function without fftw_threads everything is fine!! (irrelevant if I call matlab fft then mex fct or mex fct then matlab fft)
In both source, matlab and c-mex-source, I only make some easy standard fft, nothing special. New is the try to work with fftw_threads.
My Question: what happens in the background so that matlab crashes after closing in some constellations?
Thank you! mex fftw_threads, crash after closing matlab MATLAB Answers — New Questions
Import data from google sheets to matlab
Hello guys,
I wanted to import data from google sheets to matlab. However I couldn’t find any information about it. Since the google sheets always geting update I can’t just copy and paste so I wanted to import new data for every time I run the matlab script. Is there a way?
Thanks in advance.Hello guys,
I wanted to import data from google sheets to matlab. However I couldn’t find any information about it. Since the google sheets always geting update I can’t just copy and paste so I wanted to import new data for every time I run the matlab script. Is there a way?
Thanks in advance. Hello guys,
I wanted to import data from google sheets to matlab. However I couldn’t find any information about it. Since the google sheets always geting update I can’t just copy and paste so I wanted to import new data for every time I run the matlab script. Is there a way?
Thanks in advance. google sheets MATLAB Answers — New Questions