Tag Archives: matlab
read and store data from struct file during each iteration in the for loop
Hi,
I have a for loop as shown. During each iteration the will store entire output in the struct file named Measurements. (file attached here)
From this struct file file, I need to read and store only ‘Centroid’, ‘Eccentricity’, ‘EquivDiameter’ in the sepearte array.
for i = 1:1:1000
% some operation
Measurements = some operation
endHi,
I have a for loop as shown. During each iteration the will store entire output in the struct file named Measurements. (file attached here)
From this struct file file, I need to read and store only ‘Centroid’, ‘Eccentricity’, ‘EquivDiameter’ in the sepearte array.
for i = 1:1:1000
% some operation
Measurements = some operation
end Hi,
I have a for loop as shown. During each iteration the will store entire output in the struct file named Measurements. (file attached here)
From this struct file file, I need to read and store only ‘Centroid’, ‘Eccentricity’, ‘EquivDiameter’ in the sepearte array.
for i = 1:1:1000
% some operation
Measurements = some operation
end struct, cell array, for loop, store data, struct file MATLAB Answers — New Questions
matrix, where each element is a column vector
Excuse me, I need some help. I have an 11*7 matrix. Each element of this matrix consists of a column vector 1001*1. I want to calculate for each column matrix the maximum value. thanks for your help
ETATT=cell(11,7); % initial matrix
Etat=zeros(1001,1); % column vector, contained in each element of the ETATT matrix
I want to find the maximum value of each Etat contained in ETATT
THANKSExcuse me, I need some help. I have an 11*7 matrix. Each element of this matrix consists of a column vector 1001*1. I want to calculate for each column matrix the maximum value. thanks for your help
ETATT=cell(11,7); % initial matrix
Etat=zeros(1001,1); % column vector, contained in each element of the ETATT matrix
I want to find the maximum value of each Etat contained in ETATT
THANKS Excuse me, I need some help. I have an 11*7 matrix. Each element of this matrix consists of a column vector 1001*1. I want to calculate for each column matrix the maximum value. thanks for your help
ETATT=cell(11,7); % initial matrix
Etat=zeros(1001,1); % column vector, contained in each element of the ETATT matrix
I want to find the maximum value of each Etat contained in ETATT
THANKS cell, max, matrix MATLAB Answers — New Questions
How to prevent plotted contents to spill outside of the axes lines
Using
set(gca, ‘Layer’, ‘top’)
I end up with this:
Is there a way to completely hide plotted contents that appear beyond the axes?Using
set(gca, ‘Layer’, ‘top’)
I end up with this:
Is there a way to completely hide plotted contents that appear beyond the axes? Using
set(gca, ‘Layer’, ‘top’)
I end up with this:
Is there a way to completely hide plotted contents that appear beyond the axes? figure, axes MATLAB Answers — New Questions
inverser la matrice tri-diagonale
a=3*h -2;
b=1;
c=1;
A=diag(a*ones(1,N)) + diag(b*ones(1,N-1),1)+ diag(c*ones(1,N-1),-1)
inverser Aa=3*h -2;
b=1;
c=1;
A=diag(a*ones(1,N)) + diag(b*ones(1,N-1),1)+ diag(c*ones(1,N-1),-1)
inverser A a=3*h -2;
b=1;
c=1;
A=diag(a*ones(1,N)) + diag(b*ones(1,N-1),1)+ diag(c*ones(1,N-1),-1)
inverser A inverser MATLAB Answers — New Questions
how to fast simulink model in matlab when fuzzy controller is added
help mehelp me help me fuzzy controller MATLAB Answers — New Questions
Error in untitled22>solveHeatEquation1D (line 32) U(N+2,n+1) = beta(t); Error in untitled22 (line 11) [t, x, U] = solveHeatEquation1D(T, a, b,mu, u0,alpha, N, M);
a = 0; b = 1;
T = 2;
mu = 0.5;
alpha =1;
gamma=@(t) 0 ;
beta=@(t) 0 ;
u0 = @(x) (x.^4-x.^2);
N = 100;
M = 100;
[t, x, U] = solveHeatEquation1D(T, a, b,mu, u0,alpha, N, M);
surf(t, x, U);
shading interp , colormap ( ‘jet’ )
xlabel(‘t’);
ylabel(‘x’);
zlabel(‘U’);
title(‘la Solution de equation par methode de diff finis’);
function [t, x, U] = solveHeatEquation1D(T, a, b, mu, u0,alpha, N, M)
dt = T/M;
t = 0:dt:T;
dx = (b-a)/N+1;
x = a:dx:b;
U = zeros(N+2, M+1);
E = mu *dt/dx^2;
C = 1 – 2*E;
D = alpha *(dt/(2*dx));
U(:,1) = u0(x);
for n = 1:M
for i = 2:N+1
U(N+2,n+1) = beta(t);
U(1,n+1) = gamma(t);
U(i,n+1) = (E-D)*U(i+1,n) + C*U(i,n) + (D-E)*U(i-1,n);
end
end
enda = 0; b = 1;
T = 2;
mu = 0.5;
alpha =1;
gamma=@(t) 0 ;
beta=@(t) 0 ;
u0 = @(x) (x.^4-x.^2);
N = 100;
M = 100;
[t, x, U] = solveHeatEquation1D(T, a, b,mu, u0,alpha, N, M);
surf(t, x, U);
shading interp , colormap ( ‘jet’ )
xlabel(‘t’);
ylabel(‘x’);
zlabel(‘U’);
title(‘la Solution de equation par methode de diff finis’);
function [t, x, U] = solveHeatEquation1D(T, a, b, mu, u0,alpha, N, M)
dt = T/M;
t = 0:dt:T;
dx = (b-a)/N+1;
x = a:dx:b;
U = zeros(N+2, M+1);
E = mu *dt/dx^2;
C = 1 – 2*E;
D = alpha *(dt/(2*dx));
U(:,1) = u0(x);
for n = 1:M
for i = 2:N+1
U(N+2,n+1) = beta(t);
U(1,n+1) = gamma(t);
U(i,n+1) = (E-D)*U(i+1,n) + C*U(i,n) + (D-E)*U(i-1,n);
end
end
end a = 0; b = 1;
T = 2;
mu = 0.5;
alpha =1;
gamma=@(t) 0 ;
beta=@(t) 0 ;
u0 = @(x) (x.^4-x.^2);
N = 100;
M = 100;
[t, x, U] = solveHeatEquation1D(T, a, b,mu, u0,alpha, N, M);
surf(t, x, U);
shading interp , colormap ( ‘jet’ )
xlabel(‘t’);
ylabel(‘x’);
zlabel(‘U’);
title(‘la Solution de equation par methode de diff finis’);
function [t, x, U] = solveHeatEquation1D(T, a, b, mu, u0,alpha, N, M)
dt = T/M;
t = 0:dt:T;
dx = (b-a)/N+1;
x = a:dx:b;
U = zeros(N+2, M+1);
E = mu *dt/dx^2;
C = 1 – 2*E;
D = alpha *(dt/(2*dx));
U(:,1) = u0(x);
for n = 1:M
for i = 2:N+1
U(N+2,n+1) = beta(t);
U(1,n+1) = gamma(t);
U(i,n+1) = (E-D)*U(i+1,n) + C*U(i,n) + (D-E)*U(i-1,n);
end
end
end error in untitled22 solveheatequation1d (line 32) MATLAB Answers — New Questions
is there a tool to calculate and plot voltage stability curves
i’m looking to matlab code or toolbox that calculate and plot voltage stability for simulink model like IEEE 9 bus system
please if you can help me, any advice will be highly apperciated
thanks in advancei’m looking to matlab code or toolbox that calculate and plot voltage stability for simulink model like IEEE 9 bus system
please if you can help me, any advice will be highly apperciated
thanks in advance i’m looking to matlab code or toolbox that calculate and plot voltage stability for simulink model like IEEE 9 bus system
please if you can help me, any advice will be highly apperciated
thanks in advance simpowersystems, power_system, stability, voltage, simulink MATLAB Answers — New Questions
How can I perform speaker verification for X-Vectors based on the ivectorsystem documentation?
I am trying to create a basic voice based attendance system as a beginner project for biometric based security. I am using MathWorks’ implementation of X-Vector systems for this project. Based on this link’s implementation of X-Vector based speaker verification : https://www.mathworks.com/help/audio/ug/speaker-recognition-using-x-vectors.html, I have already trained the TDNN, X-Vector system and PLDA scoring. I have also obtained thresholds for the PLDA and Cosine Similarity scoring here based on the Detection Error Tradeoff figure using the X-axis values of the EER.
Since the above link states that I-Vector and X-Vector share the same classifier backend ("The x-vector system backend, or classifier, is the same as developed for i-vector systems. For details on the backend, see Speaker Verification Using i-vectors and ivectorSystem."), how would I adapt the ivectorsystem’s verify() function in the speaker verification using I-Vectors example to use X-Vectors instead per this link : https://www.mathworks.com/help/audio/ref/ivectorsystem.html? Presumably, in the X-Vector speaker recognition link, all the helper functions were probably wrapper functions for X-Vector.I am trying to create a basic voice based attendance system as a beginner project for biometric based security. I am using MathWorks’ implementation of X-Vector systems for this project. Based on this link’s implementation of X-Vector based speaker verification : https://www.mathworks.com/help/audio/ug/speaker-recognition-using-x-vectors.html, I have already trained the TDNN, X-Vector system and PLDA scoring. I have also obtained thresholds for the PLDA and Cosine Similarity scoring here based on the Detection Error Tradeoff figure using the X-axis values of the EER.
Since the above link states that I-Vector and X-Vector share the same classifier backend ("The x-vector system backend, or classifier, is the same as developed for i-vector systems. For details on the backend, see Speaker Verification Using i-vectors and ivectorSystem."), how would I adapt the ivectorsystem’s verify() function in the speaker verification using I-Vectors example to use X-Vectors instead per this link : https://www.mathworks.com/help/audio/ref/ivectorsystem.html? Presumably, in the X-Vector speaker recognition link, all the helper functions were probably wrapper functions for X-Vector. I am trying to create a basic voice based attendance system as a beginner project for biometric based security. I am using MathWorks’ implementation of X-Vector systems for this project. Based on this link’s implementation of X-Vector based speaker verification : https://www.mathworks.com/help/audio/ug/speaker-recognition-using-x-vectors.html, I have already trained the TDNN, X-Vector system and PLDA scoring. I have also obtained thresholds for the PLDA and Cosine Similarity scoring here based on the Detection Error Tradeoff figure using the X-axis values of the EER.
Since the above link states that I-Vector and X-Vector share the same classifier backend ("The x-vector system backend, or classifier, is the same as developed for i-vector systems. For details on the backend, see Speaker Verification Using i-vectors and ivectorSystem."), how would I adapt the ivectorsystem’s verify() function in the speaker verification using I-Vectors example to use X-Vectors instead per this link : https://www.mathworks.com/help/audio/ref/ivectorsystem.html? Presumably, in the X-Vector speaker recognition link, all the helper functions were probably wrapper functions for X-Vector. audio processing, speaker recognition MATLAB Answers — New Questions
What models have been used in this research project of PEV fast charging station siting and sizing on coupled transportation and power network?
There is this research paper: https://ecal.berkeley.edu/pubs/PEV-Fast-Charging-Station-Siting.pdf
Please help to find which programs shall we use for this non linear optimisation constraint problem with multiple objective functions and multivariables.
Regards,
VishalThere is this research paper: https://ecal.berkeley.edu/pubs/PEV-Fast-Charging-Station-Siting.pdf
Please help to find which programs shall we use for this non linear optimisation constraint problem with multiple objective functions and multivariables.
Regards,
Vishal There is this research paper: https://ecal.berkeley.edu/pubs/PEV-Fast-Charging-Station-Siting.pdf
Please help to find which programs shall we use for this non linear optimisation constraint problem with multiple objective functions and multivariables.
Regards,
Vishal simpowersystems, optimization, nonlinear MATLAB Answers — New Questions
How to extract seven bands data with map and projection information using shape file?
I want to extract seven bands data with map and projection information using shape file. I am attaching the MATLAB code which is working but extracting only one band data alongwith data file and shape file. I request you to please suggest me how to extract all seven bands data with map and projection information.
I would appreciate your kind cooperation and kind help.
GauriI want to extract seven bands data with map and projection information using shape file. I am attaching the MATLAB code which is working but extracting only one band data alongwith data file and shape file. I request you to please suggest me how to extract all seven bands data with map and projection information.
I would appreciate your kind cooperation and kind help.
Gauri I want to extract seven bands data with map and projection information using shape file. I am attaching the MATLAB code which is working but extracting only one band data alongwith data file and shape file. I request you to please suggest me how to extract all seven bands data with map and projection information.
I would appreciate your kind cooperation and kind help.
Gauri how to extract seven bands data with map and proj? MATLAB Answers — New Questions
Why is the library browser in Simulink so slow in Matlab R2022 (MacOS) and how can it be fixed?
Whenever I want to search for an object in the library browser, when using Simulink, I usually double-click on a blank area and type in the name of the object. On my Windows desktop (and previous laptops) it works just fine, responsive and quick. But with my Simulink on my MacBook Pro M1 (native) it seems to take at least a few seconds, where the entire library browser field for typing seems to freeze, before I get the results.
I am running MATLAB R2022b currently and have also tried with R2022a, both give the same result. My OS is Ventura 13.2+
Some other functions such as panning, moving and zooming seem to stutter also. Finally I’ve noticed that my simulations tend to take quite a bit of time to run (30-60 seconds), while the same simulations take half the time on a significantly older and weaker windows desktop.
Is this issue fixable and how?Whenever I want to search for an object in the library browser, when using Simulink, I usually double-click on a blank area and type in the name of the object. On my Windows desktop (and previous laptops) it works just fine, responsive and quick. But with my Simulink on my MacBook Pro M1 (native) it seems to take at least a few seconds, where the entire library browser field for typing seems to freeze, before I get the results.
I am running MATLAB R2022b currently and have also tried with R2022a, both give the same result. My OS is Ventura 13.2+
Some other functions such as panning, moving and zooming seem to stutter also. Finally I’ve noticed that my simulations tend to take quite a bit of time to run (30-60 seconds), while the same simulations take half the time on a significantly older and weaker windows desktop.
Is this issue fixable and how? Whenever I want to search for an object in the library browser, when using Simulink, I usually double-click on a blank area and type in the name of the object. On my Windows desktop (and previous laptops) it works just fine, responsive and quick. But with my Simulink on my MacBook Pro M1 (native) it seems to take at least a few seconds, where the entire library browser field for typing seems to freeze, before I get the results.
I am running MATLAB R2022b currently and have also tried with R2022a, both give the same result. My OS is Ventura 13.2+
Some other functions such as panning, moving and zooming seem to stutter also. Finally I’ve noticed that my simulations tend to take quite a bit of time to run (30-60 seconds), while the same simulations take half the time on a significantly older and weaker windows desktop.
Is this issue fixable and how? simulink, macos, mac, simulation, library browser MATLAB Answers — New Questions
how to match signatures
i am doing project on signature recognition.
i have to match the signatures in the project.how should we do the matching of the signatures?can we use euclidean distance?if possible how can we write matlab code for that?i am doing project on signature recognition.
i have to match the signatures in the project.how should we do the matching of the signatures?can we use euclidean distance?if possible how can we write matlab code for that? i am doing project on signature recognition.
i have to match the signatures in the project.how should we do the matching of the signatures?can we use euclidean distance?if possible how can we write matlab code for that? MATLAB Answers — New Questions
How to select the harness of model through scripting commands and select the harness in test manager automatically by just specifying the harness name
I am trying to access the test manager through scripting commands .I have used testmanager.SetProperty (‘HarnessName’ ,name) and testmanager.SetProperty(‘HarnessOwner’, modelname) but still the property is not setted in test manager .I want to select the harness in the test manager through scripting functions .The above is not giving anyerror but not selecting the desired harness which I want to select from the harnessList.Please help to solve this if any one knows.Any UI command lines .The model is selected the Harness is drop down showing harness of internaly saved ,lets says the harnesses from xml saved info file .I want to select the harnesses by name .Help me out!I am trying to access the test manager through scripting commands .I have used testmanager.SetProperty (‘HarnessName’ ,name) and testmanager.SetProperty(‘HarnessOwner’, modelname) but still the property is not setted in test manager .I want to select the harness in the test manager through scripting functions .The above is not giving anyerror but not selecting the desired harness which I want to select from the harnessList.Please help to solve this if any one knows.Any UI command lines .The model is selected the Harness is drop down showing harness of internaly saved ,lets says the harnesses from xml saved info file .I want to select the harnesses by name .Help me out! I am trying to access the test manager through scripting commands .I have used testmanager.SetProperty (‘HarnessName’ ,name) and testmanager.SetProperty(‘HarnessOwner’, modelname) but still the property is not setted in test manager .I want to select the harness in the test manager through scripting functions .The above is not giving anyerror but not selecting the desired harness which I want to select from the harnessList.Please help to solve this if any one knows.Any UI command lines .The model is selected the Harness is drop down showing harness of internaly saved ,lets says the harnesses from xml saved info file .I want to select the harnesses by name .Help me out! simulinktestmanager, simulink, handles, model, harness, scripting, testmanagerui access MATLAB Answers — New Questions
addVertex function is slow compared to solve function [FEA, FEM, Finite element, PDE, structural, static-solid]
Hello
During my work with MATLAB’s Partial Differential Equation Toolbox to perform 3D structural, static-solid FEA I recognized that the addVertex function is very slow.
In my models, adding the vertices for the boundary conditions takes much longer then solving the actual model, e.g. sometimes 4 times longer.
Find attached an example. In this case the differnence is not that big but adding the vertices still takes longer then solving, e.g. on my computer:
Adding fixture constraint. Completed after 0.43 minutes.
Solving FEA. Completed after 0.29 minutes.
In this example the fixture is delimited only by a plane. Usally in my models the situation is more complex. That’s why many vertices must be added to define the boundary conditions.
Are there any options to speed this up, e.g. parallel computing?
Kind regards
FritzHello
During my work with MATLAB’s Partial Differential Equation Toolbox to perform 3D structural, static-solid FEA I recognized that the addVertex function is very slow.
In my models, adding the vertices for the boundary conditions takes much longer then solving the actual model, e.g. sometimes 4 times longer.
Find attached an example. In this case the differnence is not that big but adding the vertices still takes longer then solving, e.g. on my computer:
Adding fixture constraint. Completed after 0.43 minutes.
Solving FEA. Completed after 0.29 minutes.
In this example the fixture is delimited only by a plane. Usally in my models the situation is more complex. That’s why many vertices must be added to define the boundary conditions.
Are there any options to speed this up, e.g. parallel computing?
Kind regards
Fritz Hello
During my work with MATLAB’s Partial Differential Equation Toolbox to perform 3D structural, static-solid FEA I recognized that the addVertex function is very slow.
In my models, adding the vertices for the boundary conditions takes much longer then solving the actual model, e.g. sometimes 4 times longer.
Find attached an example. In this case the differnence is not that big but adding the vertices still takes longer then solving, e.g. on my computer:
Adding fixture constraint. Completed after 0.43 minutes.
Solving FEA. Completed after 0.29 minutes.
In this example the fixture is delimited only by a plane. Usally in my models the situation is more complex. That’s why many vertices must be added to define the boundary conditions.
Are there any options to speed this up, e.g. parallel computing?
Kind regards
Fritz fea, pde, fem, structural, addvertex, static-solid MATLAB Answers — New Questions
Window not accommodate my formulated analytical equations (Qy), it might go thousands, probably due to coded through sprintf; any assistance please
my code need alot of data to nonlinear equation,
function [FUN] = magige222(matr)
matL=abs(matr); [NodLp,pQ]=size(matr); data1=3; data2=data1+2-1; Nod3=NodLp-data1; p=pQ-1; nodes=9; LP=Nod3-nodes; JJ=NodLp-8+1; HLD=0; % matr loop eqns; not general matrix (MAG)
FUN = ‘FUN=@(Qy)[‘;
for j=JJ:NodLp % looping headloses eqns
for k=1:p
if (sum(matL(j,1:k))<=sum(matL(j,1:p)))&&matL(j,k)~=0 FUN = [FUN, sprintf(‘(%d.*Qy(%d).*abs(Qy(%d)*8.*L(1,%d)*1./(9.81*3.14.^2.*D(1,%d).^5).*(0.25.*(log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(%d)).*(0.25.*(log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(%d)).*(0.25.*(log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(%d)).*0.00001.^-0.5)).^-2).^-0.5)).^-2).^-0.5)).^-2)))+’,matr(j,k),k,k,k,k,k,k,k,k,k,k,k,k,k)]; end
if (k==p) FUN = [FUN, sprintf(‘(%d);’,matr(j,k+1))]; end
end
end
for j=data2:NodLp-8 % Nodal mass balance eqns
for k=1:p
if (sum(matL(j,1:k))<=sum(matL(j,1:p)))&&(matL(j,k)~=0) FUN = [FUN, sprintf(‘(%d.*Qy(%d))+’,matr(j,k),k)]; end
if (k==p) FUN = [FUN, sprintf(‘(%d);’,matr(j,k+1))]; end % FUN = [FUN, sprintf(‘matr(j,k+1);’,j,k)]; end
end
end
FUN = [FUN, ‘(1.*Qy(1))+(-1.*Qy(2))+(0);(1.*Qy(2))+(-1.*Qy(3))+(-1.*Qy(9))+(-1.*Qy(15))+(-5.900000e-02);(1.*Qy(3))+(-1.*Qy(4))+(-1.*Qy(8))+(-5.900000e-02);(1.*Qy(4))+(1.*Qy(5))+(-1.*Qy(7))+(-1.780000e-01);(-1.*Qy(5))+(1.*Qy(6))+(-1.*Qy(11))+(-1.*Qy(12))+(-5.900000e-02);(1.*Qy(7))+(-1.*Qy(10))+(1.*Qy(11))+(-1.*Qy(13))+(-1.900000e-01);(1.*Qy(8))+(1.*Qy(9))+(1.*Qy(10))+(-1.*Qy(14))+(-1.780000e-01);(1.*Qy(14))+(1.*Qy(20))+(1.*Qy(21))+(-9.100000e-02);(1.*Qy(16))+(1.*Qy(19))+(-1.*Qy(20))+(0);(1.*Qy(15))+(-1.*Qy(16))+(1.*Qy(17))+(0);(1.*Qy(17))+(-1.*Qy(18))+(-3.000000e-02);(1.*Qy(18))+(-1.*Qy(19))+(-3.000000e-02);(1.*Qy(12))+(1.*Qy(13))+(-1.*Qy(21))+(0)];’];
end
the output those I got as executed the code
8.*L(1,70)*1./(9.81*3.14.^2.*D(1,70).^5).*(0.25.*(log… Output truncated. Text exceeds maximum line length for Command Window display.my code need alot of data to nonlinear equation,
function [FUN] = magige222(matr)
matL=abs(matr); [NodLp,pQ]=size(matr); data1=3; data2=data1+2-1; Nod3=NodLp-data1; p=pQ-1; nodes=9; LP=Nod3-nodes; JJ=NodLp-8+1; HLD=0; % matr loop eqns; not general matrix (MAG)
FUN = ‘FUN=@(Qy)[‘;
for j=JJ:NodLp % looping headloses eqns
for k=1:p
if (sum(matL(j,1:k))<=sum(matL(j,1:p)))&&matL(j,k)~=0 FUN = [FUN, sprintf(‘(%d.*Qy(%d).*abs(Qy(%d)*8.*L(1,%d)*1./(9.81*3.14.^2.*D(1,%d).^5).*(0.25.*(log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(%d)).*(0.25.*(log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(%d)).*(0.25.*(log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(%d)).*0.00001.^-0.5)).^-2).^-0.5)).^-2).^-0.5)).^-2)))+’,matr(j,k),k,k,k,k,k,k,k,k,k,k,k,k,k)]; end
if (k==p) FUN = [FUN, sprintf(‘(%d);’,matr(j,k+1))]; end
end
end
for j=data2:NodLp-8 % Nodal mass balance eqns
for k=1:p
if (sum(matL(j,1:k))<=sum(matL(j,1:p)))&&(matL(j,k)~=0) FUN = [FUN, sprintf(‘(%d.*Qy(%d))+’,matr(j,k),k)]; end
if (k==p) FUN = [FUN, sprintf(‘(%d);’,matr(j,k+1))]; end % FUN = [FUN, sprintf(‘matr(j,k+1);’,j,k)]; end
end
end
FUN = [FUN, ‘(1.*Qy(1))+(-1.*Qy(2))+(0);(1.*Qy(2))+(-1.*Qy(3))+(-1.*Qy(9))+(-1.*Qy(15))+(-5.900000e-02);(1.*Qy(3))+(-1.*Qy(4))+(-1.*Qy(8))+(-5.900000e-02);(1.*Qy(4))+(1.*Qy(5))+(-1.*Qy(7))+(-1.780000e-01);(-1.*Qy(5))+(1.*Qy(6))+(-1.*Qy(11))+(-1.*Qy(12))+(-5.900000e-02);(1.*Qy(7))+(-1.*Qy(10))+(1.*Qy(11))+(-1.*Qy(13))+(-1.900000e-01);(1.*Qy(8))+(1.*Qy(9))+(1.*Qy(10))+(-1.*Qy(14))+(-1.780000e-01);(1.*Qy(14))+(1.*Qy(20))+(1.*Qy(21))+(-9.100000e-02);(1.*Qy(16))+(1.*Qy(19))+(-1.*Qy(20))+(0);(1.*Qy(15))+(-1.*Qy(16))+(1.*Qy(17))+(0);(1.*Qy(17))+(-1.*Qy(18))+(-3.000000e-02);(1.*Qy(18))+(-1.*Qy(19))+(-3.000000e-02);(1.*Qy(12))+(1.*Qy(13))+(-1.*Qy(21))+(0)];’];
end
the output those I got as executed the code
8.*L(1,70)*1./(9.81*3.14.^2.*D(1,70).^5).*(0.25.*(log… Output truncated. Text exceeds maximum line length for Command Window display. my code need alot of data to nonlinear equation,
function [FUN] = magige222(matr)
matL=abs(matr); [NodLp,pQ]=size(matr); data1=3; data2=data1+2-1; Nod3=NodLp-data1; p=pQ-1; nodes=9; LP=Nod3-nodes; JJ=NodLp-8+1; HLD=0; % matr loop eqns; not general matrix (MAG)
FUN = ‘FUN=@(Qy)[‘;
for j=JJ:NodLp % looping headloses eqns
for k=1:p
if (sum(matL(j,1:k))<=sum(matL(j,1:p)))&&matL(j,k)~=0 FUN = [FUN, sprintf(‘(%d.*Qy(%d).*abs(Qy(%d)*8.*L(1,%d)*1./(9.81*3.14.^2.*D(1,%d).^5).*(0.25.*(log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(%d)).*(0.25.*(log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(%d)).*(0.25.*(log10(ee./(3.7.*D(1,%d))+2.51*3.14*vs.*D(1,%d)./(4.*Qy(%d)).*0.00001.^-0.5)).^-2).^-0.5)).^-2).^-0.5)).^-2)))+’,matr(j,k),k,k,k,k,k,k,k,k,k,k,k,k,k)]; end
if (k==p) FUN = [FUN, sprintf(‘(%d);’,matr(j,k+1))]; end
end
end
for j=data2:NodLp-8 % Nodal mass balance eqns
for k=1:p
if (sum(matL(j,1:k))<=sum(matL(j,1:p)))&&(matL(j,k)~=0) FUN = [FUN, sprintf(‘(%d.*Qy(%d))+’,matr(j,k),k)]; end
if (k==p) FUN = [FUN, sprintf(‘(%d);’,matr(j,k+1))]; end % FUN = [FUN, sprintf(‘matr(j,k+1);’,j,k)]; end
end
end
FUN = [FUN, ‘(1.*Qy(1))+(-1.*Qy(2))+(0);(1.*Qy(2))+(-1.*Qy(3))+(-1.*Qy(9))+(-1.*Qy(15))+(-5.900000e-02);(1.*Qy(3))+(-1.*Qy(4))+(-1.*Qy(8))+(-5.900000e-02);(1.*Qy(4))+(1.*Qy(5))+(-1.*Qy(7))+(-1.780000e-01);(-1.*Qy(5))+(1.*Qy(6))+(-1.*Qy(11))+(-1.*Qy(12))+(-5.900000e-02);(1.*Qy(7))+(-1.*Qy(10))+(1.*Qy(11))+(-1.*Qy(13))+(-1.900000e-01);(1.*Qy(8))+(1.*Qy(9))+(1.*Qy(10))+(-1.*Qy(14))+(-1.780000e-01);(1.*Qy(14))+(1.*Qy(20))+(1.*Qy(21))+(-9.100000e-02);(1.*Qy(16))+(1.*Qy(19))+(-1.*Qy(20))+(0);(1.*Qy(15))+(-1.*Qy(16))+(1.*Qy(17))+(0);(1.*Qy(17))+(-1.*Qy(18))+(-3.000000e-02);(1.*Qy(18))+(-1.*Qy(19))+(-3.000000e-02);(1.*Qy(12))+(1.*Qy(13))+(-1.*Qy(21))+(0)];’];
end
the output those I got as executed the code
8.*L(1,70)*1./(9.81*3.14.^2.*D(1,70).^5).*(0.25.*(log… Output truncated. Text exceeds maximum line length for Command Window display. sprintf MATLAB Answers — New Questions
How to define variable resistance as a function of heat input?
Hi
I am trying to develop a transient thermal model that considers both convective heat transfer and evaporative heat transfer using a variable convective heat transfer block. If the input to the variable heat transfer block is selected based on the temperature of the system (i.e. if T<T_sat – convective heat transfer cofficient is used, else evaporative heat transfer coefficient is used). Here T, is taken from a temperature sensor monitoring the wall temperature of the heat source, whilst T_sat is the saturation temperature of the liquid.
I also need the convective heat transfer coefficient to be a function of the heat input, hence the PS from heat flow rate sensor to the function block.
When this model is simulated, I get an discontinutity error. Is there a better way to do this. Any thoughts would be much appreciated?
Many thanksHi
I am trying to develop a transient thermal model that considers both convective heat transfer and evaporative heat transfer using a variable convective heat transfer block. If the input to the variable heat transfer block is selected based on the temperature of the system (i.e. if T<T_sat – convective heat transfer cofficient is used, else evaporative heat transfer coefficient is used). Here T, is taken from a temperature sensor monitoring the wall temperature of the heat source, whilst T_sat is the saturation temperature of the liquid.
I also need the convective heat transfer coefficient to be a function of the heat input, hence the PS from heat flow rate sensor to the function block.
When this model is simulated, I get an discontinutity error. Is there a better way to do this. Any thoughts would be much appreciated?
Many thanks Hi
I am trying to develop a transient thermal model that considers both convective heat transfer and evaporative heat transfer using a variable convective heat transfer block. If the input to the variable heat transfer block is selected based on the temperature of the system (i.e. if T<T_sat – convective heat transfer cofficient is used, else evaporative heat transfer coefficient is used). Here T, is taken from a temperature sensor monitoring the wall temperature of the heat source, whilst T_sat is the saturation temperature of the liquid.
I also need the convective heat transfer coefficient to be a function of the heat input, hence the PS from heat flow rate sensor to the function block.
When this model is simulated, I get an discontinutity error. Is there a better way to do this. Any thoughts would be much appreciated?
Many thanks variable thermal resistance, simscape, simulink, heat transfer MATLAB Answers — New Questions
How to derive the moving average of a time series generated in simulink?
Hi,
I have a dynamics system under excitation and I want to compute the moving average of the quantity "POW" I defined. In my case, the moving window has length 100, the sampling time was 0.01. So I expect to have the moving average "POW" every second.
clear all
clc
m1=0.947; m2=m1; Cp=1.1;
J=0.1*0.15^2/2;
L1=0.125;L2=0.035;
g=9.8;FI0=pi/2;
Kem=0.48; Rc=3.74;Re=5;
Cem=Kem^2/(Rc+Re);
TT=500;dt=1E-2;
tt=[0:dt:TT]’;
fl=0.1;
Ag=9.8*0.4;fg=1;
accg=Ag*sin(2*pi*fg*tt);
sim("buffermovemean.slx")
However, if I run the "questiononbuffer.m", the error message is :
"Error using questiononbuffer
The signal at ‘Output Port 1’ of ‘buffermovemean/Moving Average2’ is a variable-size signal with a nondiscrete sample time. The
sample time for any variable-size signal must be discrete."
So I tried to use buffer to transform the time series "POW" with fixed frame length 100 by the block "signal from workspace" and then apply moving-average, but the error message appears as:
Error using questiononbuffer
Error evaluating parameter ‘X’ in ‘buffermovemean/Signal From Workspace’
Caused by:
Error using questiononbuffer
Unrecognized function or variable ‘POW’.
Error using questiononbuffer
Variable ‘POW’ does not exist.
Suggested Actions:
• Load a file into base workspace. – Fix
• Create a new variable. – Fix
So my question is if the time series is generated in real time in the simulink, how to derive its moving average for a fixed duration like in my case? PS, when I use matlab 2019b, I could directly connect the moving-average block after the time series to get its moving average. But in matlab 2023b, error reports. How to fix it?
@Walter RobersonHi,
I have a dynamics system under excitation and I want to compute the moving average of the quantity "POW" I defined. In my case, the moving window has length 100, the sampling time was 0.01. So I expect to have the moving average "POW" every second.
clear all
clc
m1=0.947; m2=m1; Cp=1.1;
J=0.1*0.15^2/2;
L1=0.125;L2=0.035;
g=9.8;FI0=pi/2;
Kem=0.48; Rc=3.74;Re=5;
Cem=Kem^2/(Rc+Re);
TT=500;dt=1E-2;
tt=[0:dt:TT]’;
fl=0.1;
Ag=9.8*0.4;fg=1;
accg=Ag*sin(2*pi*fg*tt);
sim("buffermovemean.slx")
However, if I run the "questiononbuffer.m", the error message is :
"Error using questiononbuffer
The signal at ‘Output Port 1’ of ‘buffermovemean/Moving Average2’ is a variable-size signal with a nondiscrete sample time. The
sample time for any variable-size signal must be discrete."
So I tried to use buffer to transform the time series "POW" with fixed frame length 100 by the block "signal from workspace" and then apply moving-average, but the error message appears as:
Error using questiononbuffer
Error evaluating parameter ‘X’ in ‘buffermovemean/Signal From Workspace’
Caused by:
Error using questiononbuffer
Unrecognized function or variable ‘POW’.
Error using questiononbuffer
Variable ‘POW’ does not exist.
Suggested Actions:
• Load a file into base workspace. – Fix
• Create a new variable. – Fix
So my question is if the time series is generated in real time in the simulink, how to derive its moving average for a fixed duration like in my case? PS, when I use matlab 2019b, I could directly connect the moving-average block after the time series to get its moving average. But in matlab 2023b, error reports. How to fix it?
@Walter Roberson Hi,
I have a dynamics system under excitation and I want to compute the moving average of the quantity "POW" I defined. In my case, the moving window has length 100, the sampling time was 0.01. So I expect to have the moving average "POW" every second.
clear all
clc
m1=0.947; m2=m1; Cp=1.1;
J=0.1*0.15^2/2;
L1=0.125;L2=0.035;
g=9.8;FI0=pi/2;
Kem=0.48; Rc=3.74;Re=5;
Cem=Kem^2/(Rc+Re);
TT=500;dt=1E-2;
tt=[0:dt:TT]’;
fl=0.1;
Ag=9.8*0.4;fg=1;
accg=Ag*sin(2*pi*fg*tt);
sim("buffermovemean.slx")
However, if I run the "questiononbuffer.m", the error message is :
"Error using questiononbuffer
The signal at ‘Output Port 1’ of ‘buffermovemean/Moving Average2’ is a variable-size signal with a nondiscrete sample time. The
sample time for any variable-size signal must be discrete."
So I tried to use buffer to transform the time series "POW" with fixed frame length 100 by the block "signal from workspace" and then apply moving-average, but the error message appears as:
Error using questiononbuffer
Error evaluating parameter ‘X’ in ‘buffermovemean/Signal From Workspace’
Caused by:
Error using questiononbuffer
Unrecognized function or variable ‘POW’.
Error using questiononbuffer
Variable ‘POW’ does not exist.
Suggested Actions:
• Load a file into base workspace. – Fix
• Create a new variable. – Fix
So my question is if the time series is generated in real time in the simulink, how to derive its moving average for a fixed duration like in my case? PS, when I use matlab 2019b, I could directly connect the moving-average block after the time series to get its moving average. But in matlab 2023b, error reports. How to fix it?
@Walter Roberson buffer moving-average MATLAB Answers — New Questions
How do I break from a loop on keyboard input without plugins?
I have been trying to figure out for a while how to accomplish the following, but I don’t want to use plugins. This is because the Psychtoolbox stopped working, and I don’t want to fix it:
while 1
% perform task
% poll keyboard, do not stop, just check if a button is pressed
if button is pressed
break;
end
end
The faster the polling happens, the better.I have been trying to figure out for a while how to accomplish the following, but I don’t want to use plugins. This is because the Psychtoolbox stopped working, and I don’t want to fix it:
while 1
% perform task
% poll keyboard, do not stop, just check if a button is pressed
if button is pressed
break;
end
end
The faster the polling happens, the better. I have been trying to figure out for a while how to accomplish the following, but I don’t want to use plugins. This is because the Psychtoolbox stopped working, and I don’t want to fix it:
while 1
% perform task
% poll keyboard, do not stop, just check if a button is pressed
if button is pressed
break;
end
end
The faster the polling happens, the better. psychtoolbox, keyboard, user input MATLAB Answers — New Questions
Why Spatial referencing information is missing or not readable directly from ENVI format data?
I have created ENVI formatted data along with its header file. I can open it in ENVI software and even extracted the data using shape file manually. However, when I tried to extract the data using same shape file from MATLAB code given below;
[img, R] = readgeoraster(img_file.name);
% Verify if R contains the necessary spatial referencing information
if isempty(R)
error(‘Spatial referencing information is missing or not readable directly.’);
end
It gives following error
Spatial referencing information is missing or not readable directly
I am attaching the ENVI header file and request you to please suggest me how to use it.
ChaharI have created ENVI formatted data along with its header file. I can open it in ENVI software and even extracted the data using shape file manually. However, when I tried to extract the data using same shape file from MATLAB code given below;
[img, R] = readgeoraster(img_file.name);
% Verify if R contains the necessary spatial referencing information
if isempty(R)
error(‘Spatial referencing information is missing or not readable directly.’);
end
It gives following error
Spatial referencing information is missing or not readable directly
I am attaching the ENVI header file and request you to please suggest me how to use it.
Chahar I have created ENVI formatted data along with its header file. I can open it in ENVI software and even extracted the data using shape file manually. However, when I tried to extract the data using same shape file from MATLAB code given below;
[img, R] = readgeoraster(img_file.name);
% Verify if R contains the necessary spatial referencing information
if isempty(R)
error(‘Spatial referencing information is missing or not readable directly.’);
end
It gives following error
Spatial referencing information is missing or not readable directly
I am attaching the ENVI header file and request you to please suggest me how to use it.
Chahar spatial referencing information is missing? MATLAB Answers — New Questions
Exporting MATLAB code to word file
I want to export my MATLAB code in word file. If I opt for print command directly, the code is getting printed, but the vertical lines that connect the start and end of a loop are not getting shown. For example,
for d=1:s
fraction(d)=vert(d)/add;
if(d==1)
cumulative(d)=fraction(d);
continue
end
cumulative(d)=cumulative(d-1)+fraction(d)
end
The vertical line connecting the For loop with its corresponding end is not appearing. Any suggestions how I can do that ?I want to export my MATLAB code in word file. If I opt for print command directly, the code is getting printed, but the vertical lines that connect the start and end of a loop are not getting shown. For example,
for d=1:s
fraction(d)=vert(d)/add;
if(d==1)
cumulative(d)=fraction(d);
continue
end
cumulative(d)=cumulative(d-1)+fraction(d)
end
The vertical line connecting the For loop with its corresponding end is not appearing. Any suggestions how I can do that ? I want to export my MATLAB code in word file. If I opt for print command directly, the code is getting printed, but the vertical lines that connect the start and end of a loop are not getting shown. For example,
for d=1:s
fraction(d)=vert(d)/add;
if(d==1)
cumulative(d)=fraction(d);
continue
end
cumulative(d)=cumulative(d-1)+fraction(d)
end
The vertical line connecting the For loop with its corresponding end is not appearing. Any suggestions how I can do that ? print MATLAB Answers — New Questions