Tag Archives: matlab
Fourier Series,Spectral Analysys
I am trying to implement the spectral analysys for the signal represented in Fig.8. Im trying to do this by using the Fourier Series to generate the signal(it doesnt have to be perfect like in Fig.8) however I am very lost at this point and I dont think thats how the spectral analysys should be looking,i kept trying but I am not able to do it.
Thank you very much for your time.
Sorry for the words not being in english
% Parametrii semnalului dreptunghiular
t1 = 0.2; % Momentul de pornire al creșterii
t2 = 0.8; % Momentul de sfârșit al creșterii
A = 1; % Amplitudinea semnalului dreptunghiular
% Perioada semnalului dreptunghiular (este 1 secundă în acest caz)
T = 1;
% Numărul de armonici pentru seria Fourier (poți ajusta acest număr pentru o aproximare mai bună)
N = 10; % Vom folosi 10 termeni (5 perechi de cosinus și sinus)
% Vectorul de timp
t = linspace(0, T, 1000); % 1000 de puncte între 0 și T pentru o reprezentare mai precisă
% Inițializare semnal dreptunghiular aproximativ
f = zeros(size(t));
% Calcul coeficienți Fourier
a0 = 1; % Coeficientul mediei (pentru semnalul dreptunghiular cu amplitudinea 1)
for n = 1:N
freq = 2*n – 1; % Frecvența armonicului (doar frecvențele impare)
an = (2*A/T) * (1/(pi*freq)) * (sin(2*pi*freq*t2/T) – sin(2*pi*freq*t1/T)); % Coeficientul an
bn = 0; % Pentru semnalul dreptunghiular, coeficientul bn este 0 (nu există termeni sinusoidal)
% Adăugare termen în sumă
f = f + an * cos(2*pi*freq*t);
end
% Adăugare termenul de medie
f = f + a0/2;
% Plotare semnal dreptunghiular aproximativ
figure;
plot(t, f, ‘b’, ‘LineWidth’, 2);
xlabel(‘Timp [secunde]’);
ylabel(‘Amplitudine’);
title(‘Semnal Dreptunghiular Aproximat prin Seria Fourier’);
grid on;
%Analiza spectrala
Y=fft(f);
Pyy=Y.*conj(Y);
s=length(Pyy);
f=20000*(0:s/2-1)/s;
figure;
plot(f,abs(Pyy(1:s/2)));
xlabel(‘Frecventa [Hz]’);
ylabel(‘Spectru’);I am trying to implement the spectral analysys for the signal represented in Fig.8. Im trying to do this by using the Fourier Series to generate the signal(it doesnt have to be perfect like in Fig.8) however I am very lost at this point and I dont think thats how the spectral analysys should be looking,i kept trying but I am not able to do it.
Thank you very much for your time.
Sorry for the words not being in english
% Parametrii semnalului dreptunghiular
t1 = 0.2; % Momentul de pornire al creșterii
t2 = 0.8; % Momentul de sfârșit al creșterii
A = 1; % Amplitudinea semnalului dreptunghiular
% Perioada semnalului dreptunghiular (este 1 secundă în acest caz)
T = 1;
% Numărul de armonici pentru seria Fourier (poți ajusta acest număr pentru o aproximare mai bună)
N = 10; % Vom folosi 10 termeni (5 perechi de cosinus și sinus)
% Vectorul de timp
t = linspace(0, T, 1000); % 1000 de puncte între 0 și T pentru o reprezentare mai precisă
% Inițializare semnal dreptunghiular aproximativ
f = zeros(size(t));
% Calcul coeficienți Fourier
a0 = 1; % Coeficientul mediei (pentru semnalul dreptunghiular cu amplitudinea 1)
for n = 1:N
freq = 2*n – 1; % Frecvența armonicului (doar frecvențele impare)
an = (2*A/T) * (1/(pi*freq)) * (sin(2*pi*freq*t2/T) – sin(2*pi*freq*t1/T)); % Coeficientul an
bn = 0; % Pentru semnalul dreptunghiular, coeficientul bn este 0 (nu există termeni sinusoidal)
% Adăugare termen în sumă
f = f + an * cos(2*pi*freq*t);
end
% Adăugare termenul de medie
f = f + a0/2;
% Plotare semnal dreptunghiular aproximativ
figure;
plot(t, f, ‘b’, ‘LineWidth’, 2);
xlabel(‘Timp [secunde]’);
ylabel(‘Amplitudine’);
title(‘Semnal Dreptunghiular Aproximat prin Seria Fourier’);
grid on;
%Analiza spectrala
Y=fft(f);
Pyy=Y.*conj(Y);
s=length(Pyy);
f=20000*(0:s/2-1)/s;
figure;
plot(f,abs(Pyy(1:s/2)));
xlabel(‘Frecventa [Hz]’);
ylabel(‘Spectru’); I am trying to implement the spectral analysys for the signal represented in Fig.8. Im trying to do this by using the Fourier Series to generate the signal(it doesnt have to be perfect like in Fig.8) however I am very lost at this point and I dont think thats how the spectral analysys should be looking,i kept trying but I am not able to do it.
Thank you very much for your time.
Sorry for the words not being in english
% Parametrii semnalului dreptunghiular
t1 = 0.2; % Momentul de pornire al creșterii
t2 = 0.8; % Momentul de sfârșit al creșterii
A = 1; % Amplitudinea semnalului dreptunghiular
% Perioada semnalului dreptunghiular (este 1 secundă în acest caz)
T = 1;
% Numărul de armonici pentru seria Fourier (poți ajusta acest număr pentru o aproximare mai bună)
N = 10; % Vom folosi 10 termeni (5 perechi de cosinus și sinus)
% Vectorul de timp
t = linspace(0, T, 1000); % 1000 de puncte între 0 și T pentru o reprezentare mai precisă
% Inițializare semnal dreptunghiular aproximativ
f = zeros(size(t));
% Calcul coeficienți Fourier
a0 = 1; % Coeficientul mediei (pentru semnalul dreptunghiular cu amplitudinea 1)
for n = 1:N
freq = 2*n – 1; % Frecvența armonicului (doar frecvențele impare)
an = (2*A/T) * (1/(pi*freq)) * (sin(2*pi*freq*t2/T) – sin(2*pi*freq*t1/T)); % Coeficientul an
bn = 0; % Pentru semnalul dreptunghiular, coeficientul bn este 0 (nu există termeni sinusoidal)
% Adăugare termen în sumă
f = f + an * cos(2*pi*freq*t);
end
% Adăugare termenul de medie
f = f + a0/2;
% Plotare semnal dreptunghiular aproximativ
figure;
plot(t, f, ‘b’, ‘LineWidth’, 2);
xlabel(‘Timp [secunde]’);
ylabel(‘Amplitudine’);
title(‘Semnal Dreptunghiular Aproximat prin Seria Fourier’);
grid on;
%Analiza spectrala
Y=fft(f);
Pyy=Y.*conj(Y);
s=length(Pyy);
f=20000*(0:s/2-1)/s;
figure;
plot(f,abs(Pyy(1:s/2)));
xlabel(‘Frecventa [Hz]’);
ylabel(‘Spectru’); matlab MATLAB Answers — New Questions
Name of Component in Simulink (out.e, out.r)
Does anyone know the component name for out.e, out.r, out.u? I can’t find the component in simulink library.
Thank you.Does anyone know the component name for out.e, out.r, out.u? I can’t find the component in simulink library.
Thank you. Does anyone know the component name for out.e, out.r, out.u? I can’t find the component in simulink library.
Thank you. simulink MATLAB Answers — New Questions
shifting axis on both ends so graph does not have points on extreme end
I have the following attached graph and I need to shift the axis so that I do not have my starting point on the y axis and the last point on the extream end.I have the following attached graph and I need to shift the axis so that I do not have my starting point on the y axis and the last point on the extream end. I have the following attached graph and I need to shift the axis so that I do not have my starting point on the y axis and the last point on the extream end. shifting axis away MATLAB Answers — New Questions
calculate the normal of a 3D plane
Hi! I have a circular plane, whose coordinates of the points of the circumference are:
P = importdata("node_plane.mat");
plot3(P(:,1),P(:,2),P(:,3))
I would like to know if it is correct to calculate the normal of this plane in the following way:
N = cross(P(1,:) – P(2,:), P(3,:) – P(2,:));
N = N/norm(N);Hi! I have a circular plane, whose coordinates of the points of the circumference are:
P = importdata("node_plane.mat");
plot3(P(:,1),P(:,2),P(:,3))
I would like to know if it is correct to calculate the normal of this plane in the following way:
N = cross(P(1,:) – P(2,:), P(3,:) – P(2,:));
N = N/norm(N); Hi! I have a circular plane, whose coordinates of the points of the circumference are:
P = importdata("node_plane.mat");
plot3(P(:,1),P(:,2),P(:,3))
I would like to know if it is correct to calculate the normal of this plane in the following way:
N = cross(P(1,:) – P(2,:), P(3,:) – P(2,:));
N = N/norm(N); normal, plane, 3d MATLAB Answers — New Questions
signature feature extraction matlab code help me
plz helpplz help plz help signature feature extraction matlab code MATLAB Answers — New Questions
Detection of storms from precipitation data
I have 5 min intervals of precipitation data that I am trying to sum into separate storm events.
6 hours of no precipitation (or 72 zero values) signify the end of the storm event.
I’m trying to create a code that
a) Give me the array of matrices (diifferent names e.g M1,M2 etc) of the storm events which lies between 6 hours of no precipitaion.
b) Sums the precip values until the 6 hours of no rainfall and then starts summing the following storm event. The output will be an array with individual storm event depths of the time series.
Kindly help.I have 5 min intervals of precipitation data that I am trying to sum into separate storm events.
6 hours of no precipitation (or 72 zero values) signify the end of the storm event.
I’m trying to create a code that
a) Give me the array of matrices (diifferent names e.g M1,M2 etc) of the storm events which lies between 6 hours of no precipitaion.
b) Sums the precip values until the 6 hours of no rainfall and then starts summing the following storm event. The output will be an array with individual storm event depths of the time series.
Kindly help. I have 5 min intervals of precipitation data that I am trying to sum into separate storm events.
6 hours of no precipitation (or 72 zero values) signify the end of the storm event.
I’m trying to create a code that
a) Give me the array of matrices (diifferent names e.g M1,M2 etc) of the storm events which lies between 6 hours of no precipitaion.
b) Sums the precip values until the 6 hours of no rainfall and then starts summing the following storm event. The output will be an array with individual storm event depths of the time series.
Kindly help. precipitation, storm, matrix, matrix array MATLAB Answers — New Questions
syntax for call to java library function with byte[] (reference) parameter?
Sockets, again.
Where I am:
I have cast & typecast to make my data look like uint8.
I have socket & getInputStream & BufferedInputStream.
I have seen references to using java.nio.channels.Channels.newChannel(stream) instead & socket inputstreams.
I can get individual bytes from any of these with byteReturn = thing.read(). They are the uint version of my data sent. So connectivity & such are ok.
.
Issue:
Clearly I’d like to move to the more efficient looking
thing.read(byte[]) forms.
methodsview(‘java.io.InputStream’) ==> read(byte[]) & read(byte[],int,int)
K>> methodsview(‘java.net.SocketInputStream’) ==> read(… the same
.
javaByteArray = javaArray(‘java.lang.Byte’,classStrLen);
count = configS.in.read(javaByteArray);
No method ‘read’ with matching signature …blah, blah
javaNioByteBuffer = java.nio.ByteBuffer.allocate(1024);
count = configS.channel.read(javaNioByteBuffer,0,classStrLen);
No method ‘read’ with matching signature found in class …blah, blah
I’ve combed the Matlab help (clearly inadequately) & not found it.
Can anyone enlighten me to the syntax for a call to a java library file with a reference parameter? ie make int = read(byte[]) work or other information that will make it viable?
Or how to get data out of a java.nio.ByteBuffer if it does arrive?
I’m guessing that I can just write a java function that returns the array & call it, but it feels as if it should be possible with just a few library calls.
Thanks in anticipation.
.
PS: pnet, yes I know: 2 days wasted trying to get SDK to install & failed, so no compiler. (Also pnet docs seemed so much more complicated than typecast & write() –> read(byte[]) …)Sockets, again.
Where I am:
I have cast & typecast to make my data look like uint8.
I have socket & getInputStream & BufferedInputStream.
I have seen references to using java.nio.channels.Channels.newChannel(stream) instead & socket inputstreams.
I can get individual bytes from any of these with byteReturn = thing.read(). They are the uint version of my data sent. So connectivity & such are ok.
.
Issue:
Clearly I’d like to move to the more efficient looking
thing.read(byte[]) forms.
methodsview(‘java.io.InputStream’) ==> read(byte[]) & read(byte[],int,int)
K>> methodsview(‘java.net.SocketInputStream’) ==> read(… the same
.
javaByteArray = javaArray(‘java.lang.Byte’,classStrLen);
count = configS.in.read(javaByteArray);
No method ‘read’ with matching signature …blah, blah
javaNioByteBuffer = java.nio.ByteBuffer.allocate(1024);
count = configS.channel.read(javaNioByteBuffer,0,classStrLen);
No method ‘read’ with matching signature found in class …blah, blah
I’ve combed the Matlab help (clearly inadequately) & not found it.
Can anyone enlighten me to the syntax for a call to a java library file with a reference parameter? ie make int = read(byte[]) work or other information that will make it viable?
Or how to get data out of a java.nio.ByteBuffer if it does arrive?
I’m guessing that I can just write a java function that returns the array & call it, but it feels as if it should be possible with just a few library calls.
Thanks in anticipation.
.
PS: pnet, yes I know: 2 days wasted trying to get SDK to install & failed, so no compiler. (Also pnet docs seemed so much more complicated than typecast & write() –> read(byte[]) …) Sockets, again.
Where I am:
I have cast & typecast to make my data look like uint8.
I have socket & getInputStream & BufferedInputStream.
I have seen references to using java.nio.channels.Channels.newChannel(stream) instead & socket inputstreams.
I can get individual bytes from any of these with byteReturn = thing.read(). They are the uint version of my data sent. So connectivity & such are ok.
.
Issue:
Clearly I’d like to move to the more efficient looking
thing.read(byte[]) forms.
methodsview(‘java.io.InputStream’) ==> read(byte[]) & read(byte[],int,int)
K>> methodsview(‘java.net.SocketInputStream’) ==> read(… the same
.
javaByteArray = javaArray(‘java.lang.Byte’,classStrLen);
count = configS.in.read(javaByteArray);
No method ‘read’ with matching signature …blah, blah
javaNioByteBuffer = java.nio.ByteBuffer.allocate(1024);
count = configS.channel.read(javaNioByteBuffer,0,classStrLen);
No method ‘read’ with matching signature found in class …blah, blah
I’ve combed the Matlab help (clearly inadequately) & not found it.
Can anyone enlighten me to the syntax for a call to a java library file with a reference parameter? ie make int = read(byte[]) work or other information that will make it viable?
Or how to get data out of a java.nio.ByteBuffer if it does arrive?
I’m guessing that I can just write a java function that returns the array & call it, but it feels as if it should be possible with just a few library calls.
Thanks in anticipation.
.
PS: pnet, yes I know: 2 days wasted trying to get SDK to install & failed, so no compiler. (Also pnet docs seemed so much more complicated than typecast & write() –> read(byte[]) …) matlab java sockets "java array reference parameter" java.socketinputstream.read MATLAB Answers — New Questions
Why am I getting “double” datatype automatically for every simulink block?
Upon making minor changes in the simulink model, the simulink blocks are automatically being assigned with the datatype double. Since all the blocks having this datatype, the "DatatypeOverride = Off" option as well as locking the output datatype option are not working. Is it possibly because of the introduction of switch-case block or something else? Kindly help me out.
Thank you.Upon making minor changes in the simulink model, the simulink blocks are automatically being assigned with the datatype double. Since all the blocks having this datatype, the "DatatypeOverride = Off" option as well as locking the output datatype option are not working. Is it possibly because of the introduction of switch-case block or something else? Kindly help me out.
Thank you. Upon making minor changes in the simulink model, the simulink blocks are automatically being assigned with the datatype double. Since all the blocks having this datatype, the "DatatypeOverride = Off" option as well as locking the output datatype option are not working. Is it possibly because of the introduction of switch-case block or something else? Kindly help me out.
Thank you. datatype, datatypeoverride MATLAB Answers — New Questions
Error in code, “Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses. “
clear
clc
m1=1;
m2=0.5;
m3=0.2;
rp=87;
R1=rp-r1;
R2=rp-r2;
R3=r3-rp;
l=2.27;
r2=[58.7 27.8 20 59 30 31.2 68.5 67 34 60 39 50.3 50 45.3 45]’;
r3=[12.89 20.65 226 120 217 193.1 91.6 110 197.5 166 158.3 142.1 150 176.5 122]’;
Rb=(((1/2).1)-rp);
x=R2
y=R3
G=x;
G(:,2) = ones(length(x), 1);
delta = G y
slope=delta(1,1)
intercept=delta(2,1)
m_b = m2./Rb.*slope-(m1./Rb).*R1
sigma = sqrt(sum((y-x).^2)./(length(x)-1));
se1 = sigma.*sqrt(1./((length(x)+mean(y)^2/((length(x)-1)*std(x)^2))));
se2 = sigma.*sqrt(1./((length (x)-1)*std(x)^2));
Ci1=tinv(.975,length(x)-1).*se1;
Ci2=tinv(.975,length(x)-1).*se2;
% creating a line of best fit
X = [min(x);1e-3;max(x)]’;
Y = delta(1,1) + delta(2,1).*X;
SE=sigma.*sqrt(1/length(x)+(X-mean(x)).^2./((length(x)-1)*std(x).^2));
Ci=tinv(.975,length(x)-1).*SE;
figure(1)
clf
plot(m1, m2, ‘ob’)
hold on
% plotting the conidence intervals
plot (X, Y, ‘R’)
plot(X,Y+Ci,’g–‘)
plot(X,Y-Ci,’g–‘)
hold off
xlabel(‘$$-$$’,’interpreter’,’latex’)
ylabel(‘$$-)$$’,’interpreter’,’latex’)
print(figure(1), ‘-dpng’, ‘figure1’)clear
clc
m1=1;
m2=0.5;
m3=0.2;
rp=87;
R1=rp-r1;
R2=rp-r2;
R3=r3-rp;
l=2.27;
r2=[58.7 27.8 20 59 30 31.2 68.5 67 34 60 39 50.3 50 45.3 45]’;
r3=[12.89 20.65 226 120 217 193.1 91.6 110 197.5 166 158.3 142.1 150 176.5 122]’;
Rb=(((1/2).1)-rp);
x=R2
y=R3
G=x;
G(:,2) = ones(length(x), 1);
delta = G y
slope=delta(1,1)
intercept=delta(2,1)
m_b = m2./Rb.*slope-(m1./Rb).*R1
sigma = sqrt(sum((y-x).^2)./(length(x)-1));
se1 = sigma.*sqrt(1./((length(x)+mean(y)^2/((length(x)-1)*std(x)^2))));
se2 = sigma.*sqrt(1./((length (x)-1)*std(x)^2));
Ci1=tinv(.975,length(x)-1).*se1;
Ci2=tinv(.975,length(x)-1).*se2;
% creating a line of best fit
X = [min(x);1e-3;max(x)]’;
Y = delta(1,1) + delta(2,1).*X;
SE=sigma.*sqrt(1/length(x)+(X-mean(x)).^2./((length(x)-1)*std(x).^2));
Ci=tinv(.975,length(x)-1).*SE;
figure(1)
clf
plot(m1, m2, ‘ob’)
hold on
% plotting the conidence intervals
plot (X, Y, ‘R’)
plot(X,Y+Ci,’g–‘)
plot(X,Y-Ci,’g–‘)
hold off
xlabel(‘$$-$$’,’interpreter’,’latex’)
ylabel(‘$$-)$$’,’interpreter’,’latex’)
print(figure(1), ‘-dpng’, ‘figure1’) clear
clc
m1=1;
m2=0.5;
m3=0.2;
rp=87;
R1=rp-r1;
R2=rp-r2;
R3=r3-rp;
l=2.27;
r2=[58.7 27.8 20 59 30 31.2 68.5 67 34 60 39 50.3 50 45.3 45]’;
r3=[12.89 20.65 226 120 217 193.1 91.6 110 197.5 166 158.3 142.1 150 176.5 122]’;
Rb=(((1/2).1)-rp);
x=R2
y=R3
G=x;
G(:,2) = ones(length(x), 1);
delta = G y
slope=delta(1,1)
intercept=delta(2,1)
m_b = m2./Rb.*slope-(m1./Rb).*R1
sigma = sqrt(sum((y-x).^2)./(length(x)-1));
se1 = sigma.*sqrt(1./((length(x)+mean(y)^2/((length(x)-1)*std(x)^2))));
se2 = sigma.*sqrt(1./((length (x)-1)*std(x)^2));
Ci1=tinv(.975,length(x)-1).*se1;
Ci2=tinv(.975,length(x)-1).*se2;
% creating a line of best fit
X = [min(x);1e-3;max(x)]’;
Y = delta(1,1) + delta(2,1).*X;
SE=sigma.*sqrt(1/length(x)+(X-mean(x)).^2./((length(x)-1)*std(x).^2));
Ci=tinv(.975,length(x)-1).*SE;
figure(1)
clf
plot(m1, m2, ‘ob’)
hold on
% plotting the conidence intervals
plot (X, Y, ‘R’)
plot(X,Y+Ci,’g–‘)
plot(X,Y-Ci,’g–‘)
hold off
xlabel(‘$$-$$’,’interpreter’,’latex’)
ylabel(‘$$-)$$’,’interpreter’,’latex’)
print(figure(1), ‘-dpng’, ‘figure1’) error, data, equation, invalid expression MATLAB Answers — New Questions
Make histogram for array of datetimes
I have a datetime array:
trigDatetime =
1273×1 datetime array
2024-04-30 01:15:34
2024-04-30 01:19:27
2024-04-30 02:20:49
2024-04-30 03:48:50
2024-04-30 03:49:49
How can I calculate the frequency of occurence between two dates for a bin width of an integer number of hours (1, 2, 3, 4, 6 or 12)?I have a datetime array:
trigDatetime =
1273×1 datetime array
2024-04-30 01:15:34
2024-04-30 01:19:27
2024-04-30 02:20:49
2024-04-30 03:48:50
2024-04-30 03:49:49
How can I calculate the frequency of occurence between two dates for a bin width of an integer number of hours (1, 2, 3, 4, 6 or 12)? I have a datetime array:
trigDatetime =
1273×1 datetime array
2024-04-30 01:15:34
2024-04-30 01:19:27
2024-04-30 02:20:49
2024-04-30 03:48:50
2024-04-30 03:49:49
How can I calculate the frequency of occurence between two dates for a bin width of an integer number of hours (1, 2, 3, 4, 6 or 12)? histogram, datetime MATLAB Answers — New Questions
Replacing Simscape’s gimbal joint’s Spring Stiffnes with External Torque
Hello,
I tried to understand how gimbal joint’s Spring Stiffnes work, so I tried to replace the Spring stiffness with external torque and the results are not equal.
Here is what I tried:
This is a 3D pendulum with gimbal joint. The upper gimbal joint has 3 spring with stiffnes k for all the coordinates (x,y,z). The lower gimbal joint’s spring stiffnesses are zero but there is an External torque with the value of -k*coordinate acting on the following body (this I thought would replicate the springs in the gimbal joint) as shown in the following figure.
When I simulate the pendulum such that it rotates only around one axis it works perfectly and there is 0 error between the upper and lower model. However, when I try to simulate a general motion then there is error between upper and lower model. I tried to set the external torque resolution frame both to World and Attached Frame but I just couldn’t figure out how to replicate the springs with external torque.
Do you have any idea or link to how the Springs in the gimbal joint works ? Thank you, Ondrej.Hello,
I tried to understand how gimbal joint’s Spring Stiffnes work, so I tried to replace the Spring stiffness with external torque and the results are not equal.
Here is what I tried:
This is a 3D pendulum with gimbal joint. The upper gimbal joint has 3 spring with stiffnes k for all the coordinates (x,y,z). The lower gimbal joint’s spring stiffnesses are zero but there is an External torque with the value of -k*coordinate acting on the following body (this I thought would replicate the springs in the gimbal joint) as shown in the following figure.
When I simulate the pendulum such that it rotates only around one axis it works perfectly and there is 0 error between the upper and lower model. However, when I try to simulate a general motion then there is error between upper and lower model. I tried to set the external torque resolution frame both to World and Attached Frame but I just couldn’t figure out how to replicate the springs with external torque.
Do you have any idea or link to how the Springs in the gimbal joint works ? Thank you, Ondrej. Hello,
I tried to understand how gimbal joint’s Spring Stiffnes work, so I tried to replace the Spring stiffness with external torque and the results are not equal.
Here is what I tried:
This is a 3D pendulum with gimbal joint. The upper gimbal joint has 3 spring with stiffnes k for all the coordinates (x,y,z). The lower gimbal joint’s spring stiffnesses are zero but there is an External torque with the value of -k*coordinate acting on the following body (this I thought would replicate the springs in the gimbal joint) as shown in the following figure.
When I simulate the pendulum such that it rotates only around one axis it works perfectly and there is 0 error between the upper and lower model. However, when I try to simulate a general motion then there is error between upper and lower model. I tried to set the external torque resolution frame both to World and Attached Frame but I just couldn’t figure out how to replicate the springs with external torque.
Do you have any idea or link to how the Springs in the gimbal joint works ? Thank you, Ondrej. gimbal joint, simscape, external torque and force MATLAB Answers — New Questions
Programmatically close App Designer app after running it for a unit test
I need to run mlapp myApp for a unit test, but after the test I want the app window to be closed. The only way I know to do this is to search for the app UI Figure in all graphics objects, but I feel there should be a more elegant way.
In my example there is a function appStartup that is called by myApp when the app is started, and appStartup should throw an error if the app can’t be run. My code looks like:
function testAppNotRunnable(testCase)
% code here to make sure the app can’t run
verifyError(testCase, @() myApp, "appStartup:cantRunApp") % appStartup errors when called by myApp
% close open app windows
h = findall(groot, ‘Tag’, ‘my app tag’);
close(h)
This works, but seems inelegant.I need to run mlapp myApp for a unit test, but after the test I want the app window to be closed. The only way I know to do this is to search for the app UI Figure in all graphics objects, but I feel there should be a more elegant way.
In my example there is a function appStartup that is called by myApp when the app is started, and appStartup should throw an error if the app can’t be run. My code looks like:
function testAppNotRunnable(testCase)
% code here to make sure the app can’t run
verifyError(testCase, @() myApp, "appStartup:cantRunApp") % appStartup errors when called by myApp
% close open app windows
h = findall(groot, ‘Tag’, ‘my app tag’);
close(h)
This works, but seems inelegant. I need to run mlapp myApp for a unit test, but after the test I want the app window to be closed. The only way I know to do this is to search for the app UI Figure in all graphics objects, but I feel there should be a more elegant way.
In my example there is a function appStartup that is called by myApp when the app is started, and appStartup should throw an error if the app can’t be run. My code looks like:
function testAppNotRunnable(testCase)
% code here to make sure the app can’t run
verifyError(testCase, @() myApp, "appStartup:cantRunApp") % appStartup errors when called by myApp
% close open app windows
h = findall(groot, ‘Tag’, ‘my app tag’);
close(h)
This works, but seems inelegant. appdesigner, testing MATLAB Answers — New Questions
Logitech G29 with Simulink desktop simulation
Hi
I have a logitech G29 driving wheel and pedals on PS3 mode and the simulink realtime library block for Logitech G29. Do you have any idea how can I record steering signals?
I keep on getting error though all the modules and drivers are installed in Matlab.Hi
I have a logitech G29 driving wheel and pedals on PS3 mode and the simulink realtime library block for Logitech G29. Do you have any idea how can I record steering signals?
I keep on getting error though all the modules and drivers are installed in Matlab. Hi
I have a logitech G29 driving wheel and pedals on PS3 mode and the simulink realtime library block for Logitech G29. Do you have any idea how can I record steering signals?
I keep on getting error though all the modules and drivers are installed in Matlab. logitech MATLAB Answers — New Questions
How to write this function in Matlab having inner product
Here,
inner product is defined as <u,v>=
Is this is correct?
function F_val = F(wi, ci, Li, K, e, sigma, zi)
% Compute the first term: K <e sum from i to N ci Li, e sum from i to N ci Li>
term1 = K * e^2 * sum(exp(sum(ci .* Li)) .* exp(sum(ci .* Li)));
% Compute the second term: K <e sum from i to N ci Li, -2 sigma>
term2 = K * e * sum(exp(sum(ci .* Li)) * (-2 * sigma));
% Compute the third term: summation i to N e ci <e^wi, wi>
term3 = e * sum(zi .* ci .* exp(wi));
% Compute the final result: F(w) = term1 + term2 + term3
F_val = term1 + term2 + term3;
endHere,
inner product is defined as <u,v>=
Is this is correct?
function F_val = F(wi, ci, Li, K, e, sigma, zi)
% Compute the first term: K <e sum from i to N ci Li, e sum from i to N ci Li>
term1 = K * e^2 * sum(exp(sum(ci .* Li)) .* exp(sum(ci .* Li)));
% Compute the second term: K <e sum from i to N ci Li, -2 sigma>
term2 = K * e * sum(exp(sum(ci .* Li)) * (-2 * sigma));
% Compute the third term: summation i to N e ci <e^wi, wi>
term3 = e * sum(zi .* ci .* exp(wi));
% Compute the final result: F(w) = term1 + term2 + term3
F_val = term1 + term2 + term3;
end Here,
inner product is defined as <u,v>=
Is this is correct?
function F_val = F(wi, ci, Li, K, e, sigma, zi)
% Compute the first term: K <e sum from i to N ci Li, e sum from i to N ci Li>
term1 = K * e^2 * sum(exp(sum(ci .* Li)) .* exp(sum(ci .* Li)));
% Compute the second term: K <e sum from i to N ci Li, -2 sigma>
term2 = K * e * sum(exp(sum(ci .* Li)) * (-2 * sigma));
% Compute the third term: summation i to N e ci <e^wi, wi>
term3 = e * sum(zi .* ci .* exp(wi));
% Compute the final result: F(w) = term1 + term2 + term3
F_val = term1 + term2 + term3;
end write function with inner product MATLAB Answers — New Questions
how to count a sequence of data arrays with cut off?
i have 5 data in one array. For example, the data array [2.33 2.00 1.60 1.59 1.99]. If the cutoff is 1.50, it means the amount of data is 4 (pay attention to the order of the data). the number 1.99 in the 5th index is not counted.
This is my code
cnr_all=[2.33 2.00 1.60 1.59 1.99];
cut_off=1.50;
N=zeros(size(cnr_all));
for i=1:numel(cnr_all)
if cnr_all[i] >= cut_off;
N=N+1;
break;
end
end
disp(N)i have 5 data in one array. For example, the data array [2.33 2.00 1.60 1.59 1.99]. If the cutoff is 1.50, it means the amount of data is 4 (pay attention to the order of the data). the number 1.99 in the 5th index is not counted.
This is my code
cnr_all=[2.33 2.00 1.60 1.59 1.99];
cut_off=1.50;
N=zeros(size(cnr_all));
for i=1:numel(cnr_all)
if cnr_all[i] >= cut_off;
N=N+1;
break;
end
end
disp(N) i have 5 data in one array. For example, the data array [2.33 2.00 1.60 1.59 1.99]. If the cutoff is 1.50, it means the amount of data is 4 (pay attention to the order of the data). the number 1.99 in the 5th index is not counted.
This is my code
cnr_all=[2.33 2.00 1.60 1.59 1.99];
cut_off=1.50;
N=zeros(size(cnr_all));
for i=1:numel(cnr_all)
if cnr_all[i] >= cut_off;
N=N+1;
break;
end
end
disp(N) loop, if statement, break MATLAB Answers — New Questions
Blank plot on my computer
This is my code and I was wondering why is my figure 6 empty:
https://dontpad.com/labpdsmikiThis is my code and I was wondering why is my figure 6 empty:
https://dontpad.com/labpdsmiki This is my code and I was wondering why is my figure 6 empty:
https://dontpad.com/labpdsmiki graphics MATLAB Answers — New Questions
Problem with StopRecording button
I’m using this code to record my voice, but when the recording is less than 5 seconds, the file played by the function sound is the file recorded before the last one.
This function records the voice when i push the ‘StartRecording’ button:
function StartRecording_Callback(hObject, eventdata, handles)
RecordStatus = get(hObject,’Value’);
runstr=get(hObject,’string’);
if RecordStatus == 1
% start recording
fs = 44100;
obj = audiorecorder(fs, 16, 1);
recordblocking(obj, 5);
y = getaudiodata(obj);
clear obj
save recording.mat y
else
% stop recording
StopRecording(handles);
end
This function is the callback for the function StopRecording:
function StopButton_Callback(hObject, eventdata, handles)
StopRecording(guidata(hObject));
This function saves, plays and plots the audio file:
function StopRecording(handles)
fs = 44100;
load recording y;
[filename, pathname] = uiputfile(‘*.wav’, ‘Save file name’);
cd (pathname);
audiowrite(filename, y, fs);
sound(y,fs);
handles.x = y;
handles.fs = fs;
axes(handles.axes1);
time = 0:1/fs:(length(handles.x)-1)/fs;
plot(time,handles.x);
title(‘Original Signal’);
axes(handles.axes2);
specgram(handles.x, 1024, handles.fs);
title(‘Encrypted Signal’);
I want to record, play and plot the file just created.I’m using this code to record my voice, but when the recording is less than 5 seconds, the file played by the function sound is the file recorded before the last one.
This function records the voice when i push the ‘StartRecording’ button:
function StartRecording_Callback(hObject, eventdata, handles)
RecordStatus = get(hObject,’Value’);
runstr=get(hObject,’string’);
if RecordStatus == 1
% start recording
fs = 44100;
obj = audiorecorder(fs, 16, 1);
recordblocking(obj, 5);
y = getaudiodata(obj);
clear obj
save recording.mat y
else
% stop recording
StopRecording(handles);
end
This function is the callback for the function StopRecording:
function StopButton_Callback(hObject, eventdata, handles)
StopRecording(guidata(hObject));
This function saves, plays and plots the audio file:
function StopRecording(handles)
fs = 44100;
load recording y;
[filename, pathname] = uiputfile(‘*.wav’, ‘Save file name’);
cd (pathname);
audiowrite(filename, y, fs);
sound(y,fs);
handles.x = y;
handles.fs = fs;
axes(handles.axes1);
time = 0:1/fs:(length(handles.x)-1)/fs;
plot(time,handles.x);
title(‘Original Signal’);
axes(handles.axes2);
specgram(handles.x, 1024, handles.fs);
title(‘Encrypted Signal’);
I want to record, play and plot the file just created. I’m using this code to record my voice, but when the recording is less than 5 seconds, the file played by the function sound is the file recorded before the last one.
This function records the voice when i push the ‘StartRecording’ button:
function StartRecording_Callback(hObject, eventdata, handles)
RecordStatus = get(hObject,’Value’);
runstr=get(hObject,’string’);
if RecordStatus == 1
% start recording
fs = 44100;
obj = audiorecorder(fs, 16, 1);
recordblocking(obj, 5);
y = getaudiodata(obj);
clear obj
save recording.mat y
else
% stop recording
StopRecording(handles);
end
This function is the callback for the function StopRecording:
function StopButton_Callback(hObject, eventdata, handles)
StopRecording(guidata(hObject));
This function saves, plays and plots the audio file:
function StopRecording(handles)
fs = 44100;
load recording y;
[filename, pathname] = uiputfile(‘*.wav’, ‘Save file name’);
cd (pathname);
audiowrite(filename, y, fs);
sound(y,fs);
handles.x = y;
handles.fs = fs;
axes(handles.axes1);
time = 0:1/fs:(length(handles.x)-1)/fs;
plot(time,handles.x);
title(‘Original Signal’);
axes(handles.axes2);
specgram(handles.x, 1024, handles.fs);
title(‘Encrypted Signal’);
I want to record, play and plot the file just created. sound, audiowrite, audiorecorder MATLAB Answers — New Questions
Why is my script not detecting changes in UI?
Hi all! I am relatively new to app design in Matlab and I’m trying to design an app for an automated recording set-up. The idea is that users can define metadata in the UI (animal ID, duration of trial, etc.) before starting the session, then start and pause the session as needed, and then monitor the recording from the app while the automation is controlled in a separate matlab script (i.e. the automation is not running on the callbacks). I can get my app to pass information back to the base script using assignin for basic inputs and pass data back to the UI for monitoring like a timer and temperature. However, I can’t figure out how to execute my code only when the user starts the trial. To start with something simple, I have written an UpdateTimer function that updates the timer when called in the main script (I had originally written a timer into the callback but then nothing else can run so now the user will see the timer update everytime something runs in the automation to approximate the time since starting) and I have some dummy temperature data. When the user clicks Start on the UI, I would like the timer and temperature to update every 10 seconds. However, no matter what I try, the script can’t tell when the button has changed. Can anyone help me??
Main Script:
clear all;
close all;
b1_State = ‘NotStarted’; %Initial state of start button
Box1 = TestApp; %Calling UI
%pause(15); %I can pause is for 15seconds and quickly enter everything and then hit start and the following will work, but I don’t want the user to be on a time limit before starting the session
switch b1_State %This was the last thing I tried, I’ve also tried while and if loops with no success either
case ‘Recording’
test = 5;
Box1.Timer_EditField.Value = UpdateTimer(b1_StartTime, b1_PauseTime, b1_Duration, Box1);
Box1.TemperatureCEditField.Value = num2str(25);
pause(10)
Box1.Timer_EditField.Value = UpdateTimer(b1_StartTime, b1_PauseTime, b1_Duration, Box1);
Box1.TemperatureCEditField.Value = num2str(35);
end % Eventually I will specify what happens when the script is paused, but I just wanted to get one case working first
UpdateTimer Script (Note I’m still working on what happens if the user pauses and then continues the recording):
function update = UpdateTimer(StartTime, PauseTime, Duration, Box)
Now = datestr(now, "HH:MM:SS.FFF");
Now_H = str2double(Now(1:2));
Now_M = str2double(Now(4:5));
Now_S = str2double(Now(7:12)) + Now_M*60 + Now_H*3600;
Start_H = str2double(StartTime(1:2));
Start_M = str2double(StartTime(4:5));
Start_S = str2double(StartTime(7:12)) + Start_M*60 + Start_H*3600;
Update_S = Now_S – Start_S;
if Update_S < Duration*60
A(1) = floor(Update_S/3600);
A(2) = floor((Update_S – A(1)*3600)/60);
A(3) = Update_S – A(1)*3600 – A(2)*60;
update = sprintf(‘%02.0f:%02.0f:%02.3f’, A(1), A(2), A(3));
else
Box.Timer_EditField.Value = ‘Session Over’;
Box.PAUSEButton.Text = ‘END’;
Box.PAUSEButton.BackgroundColor = ‘Red’;
Box.LampColor = ‘#9aa0a2’;
Box.STARTButton.Text = ‘START’;
end
UI Script Attached if needed!
Thank you SO much in advance for any guidance!!Hi all! I am relatively new to app design in Matlab and I’m trying to design an app for an automated recording set-up. The idea is that users can define metadata in the UI (animal ID, duration of trial, etc.) before starting the session, then start and pause the session as needed, and then monitor the recording from the app while the automation is controlled in a separate matlab script (i.e. the automation is not running on the callbacks). I can get my app to pass information back to the base script using assignin for basic inputs and pass data back to the UI for monitoring like a timer and temperature. However, I can’t figure out how to execute my code only when the user starts the trial. To start with something simple, I have written an UpdateTimer function that updates the timer when called in the main script (I had originally written a timer into the callback but then nothing else can run so now the user will see the timer update everytime something runs in the automation to approximate the time since starting) and I have some dummy temperature data. When the user clicks Start on the UI, I would like the timer and temperature to update every 10 seconds. However, no matter what I try, the script can’t tell when the button has changed. Can anyone help me??
Main Script:
clear all;
close all;
b1_State = ‘NotStarted’; %Initial state of start button
Box1 = TestApp; %Calling UI
%pause(15); %I can pause is for 15seconds and quickly enter everything and then hit start and the following will work, but I don’t want the user to be on a time limit before starting the session
switch b1_State %This was the last thing I tried, I’ve also tried while and if loops with no success either
case ‘Recording’
test = 5;
Box1.Timer_EditField.Value = UpdateTimer(b1_StartTime, b1_PauseTime, b1_Duration, Box1);
Box1.TemperatureCEditField.Value = num2str(25);
pause(10)
Box1.Timer_EditField.Value = UpdateTimer(b1_StartTime, b1_PauseTime, b1_Duration, Box1);
Box1.TemperatureCEditField.Value = num2str(35);
end % Eventually I will specify what happens when the script is paused, but I just wanted to get one case working first
UpdateTimer Script (Note I’m still working on what happens if the user pauses and then continues the recording):
function update = UpdateTimer(StartTime, PauseTime, Duration, Box)
Now = datestr(now, "HH:MM:SS.FFF");
Now_H = str2double(Now(1:2));
Now_M = str2double(Now(4:5));
Now_S = str2double(Now(7:12)) + Now_M*60 + Now_H*3600;
Start_H = str2double(StartTime(1:2));
Start_M = str2double(StartTime(4:5));
Start_S = str2double(StartTime(7:12)) + Start_M*60 + Start_H*3600;
Update_S = Now_S – Start_S;
if Update_S < Duration*60
A(1) = floor(Update_S/3600);
A(2) = floor((Update_S – A(1)*3600)/60);
A(3) = Update_S – A(1)*3600 – A(2)*60;
update = sprintf(‘%02.0f:%02.0f:%02.3f’, A(1), A(2), A(3));
else
Box.Timer_EditField.Value = ‘Session Over’;
Box.PAUSEButton.Text = ‘END’;
Box.PAUSEButton.BackgroundColor = ‘Red’;
Box.LampColor = ‘#9aa0a2’;
Box.STARTButton.Text = ‘START’;
end
UI Script Attached if needed!
Thank you SO much in advance for any guidance!! Hi all! I am relatively new to app design in Matlab and I’m trying to design an app for an automated recording set-up. The idea is that users can define metadata in the UI (animal ID, duration of trial, etc.) before starting the session, then start and pause the session as needed, and then monitor the recording from the app while the automation is controlled in a separate matlab script (i.e. the automation is not running on the callbacks). I can get my app to pass information back to the base script using assignin for basic inputs and pass data back to the UI for monitoring like a timer and temperature. However, I can’t figure out how to execute my code only when the user starts the trial. To start with something simple, I have written an UpdateTimer function that updates the timer when called in the main script (I had originally written a timer into the callback but then nothing else can run so now the user will see the timer update everytime something runs in the automation to approximate the time since starting) and I have some dummy temperature data. When the user clicks Start on the UI, I would like the timer and temperature to update every 10 seconds. However, no matter what I try, the script can’t tell when the button has changed. Can anyone help me??
Main Script:
clear all;
close all;
b1_State = ‘NotStarted’; %Initial state of start button
Box1 = TestApp; %Calling UI
%pause(15); %I can pause is for 15seconds and quickly enter everything and then hit start and the following will work, but I don’t want the user to be on a time limit before starting the session
switch b1_State %This was the last thing I tried, I’ve also tried while and if loops with no success either
case ‘Recording’
test = 5;
Box1.Timer_EditField.Value = UpdateTimer(b1_StartTime, b1_PauseTime, b1_Duration, Box1);
Box1.TemperatureCEditField.Value = num2str(25);
pause(10)
Box1.Timer_EditField.Value = UpdateTimer(b1_StartTime, b1_PauseTime, b1_Duration, Box1);
Box1.TemperatureCEditField.Value = num2str(35);
end % Eventually I will specify what happens when the script is paused, but I just wanted to get one case working first
UpdateTimer Script (Note I’m still working on what happens if the user pauses and then continues the recording):
function update = UpdateTimer(StartTime, PauseTime, Duration, Box)
Now = datestr(now, "HH:MM:SS.FFF");
Now_H = str2double(Now(1:2));
Now_M = str2double(Now(4:5));
Now_S = str2double(Now(7:12)) + Now_M*60 + Now_H*3600;
Start_H = str2double(StartTime(1:2));
Start_M = str2double(StartTime(4:5));
Start_S = str2double(StartTime(7:12)) + Start_M*60 + Start_H*3600;
Update_S = Now_S – Start_S;
if Update_S < Duration*60
A(1) = floor(Update_S/3600);
A(2) = floor((Update_S – A(1)*3600)/60);
A(3) = Update_S – A(1)*3600 – A(2)*60;
update = sprintf(‘%02.0f:%02.0f:%02.3f’, A(1), A(2), A(3));
else
Box.Timer_EditField.Value = ‘Session Over’;
Box.PAUSEButton.Text = ‘END’;
Box.PAUSEButton.BackgroundColor = ‘Red’;
Box.LampColor = ‘#9aa0a2’;
Box.STARTButton.Text = ‘START’;
end
UI Script Attached if needed!
Thank you SO much in advance for any guidance!! appdesigner, userinterface MATLAB Answers — New Questions
How do I make this code a global one, which works for different pictures associated with skin wounds?
clear all
close all
[Im,map] = imread("rana2.jpg");
imshow(Im,map)
ImBgnd = rgb2gray(Im)
ImBgnd = double(ImBgnd)/255
[ImH,ImS,ImV] = ConversieHSV(Im);
%Conversie HSV
imshow(ImH/360)
imshow(ImS/100)
imshow(ImV/100)
ImBinarHS = Filtrare(ImH,350,5);
ImBinarHSf = imfill(ImBinarHS,"holes");
imshow(ImBinarHSf)
Imfinal = Im.*uint8(ImBinarHSf);
imshow(Imfinal)
ImBinarVS = Filtrare(ImS,70,35);
ImBinarVS = ~ImBinarVS;
ImBinarVSf = imfill(ImBinarVS,"holes");
imshow(ImBinarVS)
Imfinal = Im.*uint8(ImBinarVSf);
imshow(Imfinal)
ImfinS = ImBinarHSf&ImBinarVSf;
Imfinal = Im.*uint8(~ImfinS);
imshow(Imfinal)
[ImH,ImS,ImV] = ConversieHSV(Im);
imshow(ImH/360)
imshow(ImS/100)
imshow(ImV/100)
ImBinarHI = Filtrare(ImH,10,1);
ImBinarHIf = imfill(ImBinarHI,"holes");
imshow(ImBinarHIf)
Label = bwlabel(ImBinarHIf)
Label(Label~=1) = 0;
Label = ~Label
Imfinal = Im.*uint8(ImBinarHIf);
imshow(Imfinal)
ImBinarVI = Filtrare(ImS,70,35);
ImBinarVI = ~ImBinarVI;
ImBinarVIf = imfill(ImBinarVI,"holes");
imshow(ImBinarVI)
Imfinal = Im.*uint8(ImBinarVIf);
imshow(Imfinal)
ImfinI = ImBinarHIf&ImBinarVIf&Label;
ImfinI = ImfinI-ImfinS;
ImfinI = imclearborder(ImfinI);
Imfinal = Im.*uint8(~ImfinI);
imshow(Imfinal);
ImfinalIS = ImfinI|ImfinS;
ImfinalP = ~ImfinalIS;
ImFinalI(:,:,1) = ImBgnd.*(ImfinI*255)/255;
ImFinalI(:,:,2) = ImBgnd.*(ImfinI*0)/255;
ImFinalI(:,:,3) = ImBgnd.*(ImfinI*0)/255;
ImFinalS(:,:,1) = ImBgnd.*(ImfinS*100)/255;
ImFinalS(:,:,2) = ImBgnd.*(ImfinS*100)/255;
ImFinalS(:,:,3) = ImBgnd.*(ImfinS*100)/255;
ImFinalP(:,:,1) = ImBgnd.*(ImfinalP*0)/255;
ImFinalP(:,:,2) = ImBgnd.*(ImfinalP*255)/255;
ImFinalP(:,:,3) = ImBgnd.*(ImfinalP*0)/255;
ImfinalIS = Im.*uint8(~ImfinalIS);
Imfinal = ImFinalP+ImFinalI+ImFinalS
imshow(Imfinal)
imshowpair(Im,Imfinal,"montage")
%this is what i did wrong, this is not global
%
%and this is what i realised for this photo, this was the original photo, for this i made the code
%
%i need to help me if you can, i need to do this code global for mode photoes for my graduation, but i dont know how to continue, thank you guys!clear all
close all
[Im,map] = imread("rana2.jpg");
imshow(Im,map)
ImBgnd = rgb2gray(Im)
ImBgnd = double(ImBgnd)/255
[ImH,ImS,ImV] = ConversieHSV(Im);
%Conversie HSV
imshow(ImH/360)
imshow(ImS/100)
imshow(ImV/100)
ImBinarHS = Filtrare(ImH,350,5);
ImBinarHSf = imfill(ImBinarHS,"holes");
imshow(ImBinarHSf)
Imfinal = Im.*uint8(ImBinarHSf);
imshow(Imfinal)
ImBinarVS = Filtrare(ImS,70,35);
ImBinarVS = ~ImBinarVS;
ImBinarVSf = imfill(ImBinarVS,"holes");
imshow(ImBinarVS)
Imfinal = Im.*uint8(ImBinarVSf);
imshow(Imfinal)
ImfinS = ImBinarHSf&ImBinarVSf;
Imfinal = Im.*uint8(~ImfinS);
imshow(Imfinal)
[ImH,ImS,ImV] = ConversieHSV(Im);
imshow(ImH/360)
imshow(ImS/100)
imshow(ImV/100)
ImBinarHI = Filtrare(ImH,10,1);
ImBinarHIf = imfill(ImBinarHI,"holes");
imshow(ImBinarHIf)
Label = bwlabel(ImBinarHIf)
Label(Label~=1) = 0;
Label = ~Label
Imfinal = Im.*uint8(ImBinarHIf);
imshow(Imfinal)
ImBinarVI = Filtrare(ImS,70,35);
ImBinarVI = ~ImBinarVI;
ImBinarVIf = imfill(ImBinarVI,"holes");
imshow(ImBinarVI)
Imfinal = Im.*uint8(ImBinarVIf);
imshow(Imfinal)
ImfinI = ImBinarHIf&ImBinarVIf&Label;
ImfinI = ImfinI-ImfinS;
ImfinI = imclearborder(ImfinI);
Imfinal = Im.*uint8(~ImfinI);
imshow(Imfinal);
ImfinalIS = ImfinI|ImfinS;
ImfinalP = ~ImfinalIS;
ImFinalI(:,:,1) = ImBgnd.*(ImfinI*255)/255;
ImFinalI(:,:,2) = ImBgnd.*(ImfinI*0)/255;
ImFinalI(:,:,3) = ImBgnd.*(ImfinI*0)/255;
ImFinalS(:,:,1) = ImBgnd.*(ImfinS*100)/255;
ImFinalS(:,:,2) = ImBgnd.*(ImfinS*100)/255;
ImFinalS(:,:,3) = ImBgnd.*(ImfinS*100)/255;
ImFinalP(:,:,1) = ImBgnd.*(ImfinalP*0)/255;
ImFinalP(:,:,2) = ImBgnd.*(ImfinalP*255)/255;
ImFinalP(:,:,3) = ImBgnd.*(ImfinalP*0)/255;
ImfinalIS = Im.*uint8(~ImfinalIS);
Imfinal = ImFinalP+ImFinalI+ImFinalS
imshow(Imfinal)
imshowpair(Im,Imfinal,"montage")
%this is what i did wrong, this is not global
%
%and this is what i realised for this photo, this was the original photo, for this i made the code
%
%i need to help me if you can, i need to do this code global for mode photoes for my graduation, but i dont know how to continue, thank you guys! clear all
close all
[Im,map] = imread("rana2.jpg");
imshow(Im,map)
ImBgnd = rgb2gray(Im)
ImBgnd = double(ImBgnd)/255
[ImH,ImS,ImV] = ConversieHSV(Im);
%Conversie HSV
imshow(ImH/360)
imshow(ImS/100)
imshow(ImV/100)
ImBinarHS = Filtrare(ImH,350,5);
ImBinarHSf = imfill(ImBinarHS,"holes");
imshow(ImBinarHSf)
Imfinal = Im.*uint8(ImBinarHSf);
imshow(Imfinal)
ImBinarVS = Filtrare(ImS,70,35);
ImBinarVS = ~ImBinarVS;
ImBinarVSf = imfill(ImBinarVS,"holes");
imshow(ImBinarVS)
Imfinal = Im.*uint8(ImBinarVSf);
imshow(Imfinal)
ImfinS = ImBinarHSf&ImBinarVSf;
Imfinal = Im.*uint8(~ImfinS);
imshow(Imfinal)
[ImH,ImS,ImV] = ConversieHSV(Im);
imshow(ImH/360)
imshow(ImS/100)
imshow(ImV/100)
ImBinarHI = Filtrare(ImH,10,1);
ImBinarHIf = imfill(ImBinarHI,"holes");
imshow(ImBinarHIf)
Label = bwlabel(ImBinarHIf)
Label(Label~=1) = 0;
Label = ~Label
Imfinal = Im.*uint8(ImBinarHIf);
imshow(Imfinal)
ImBinarVI = Filtrare(ImS,70,35);
ImBinarVI = ~ImBinarVI;
ImBinarVIf = imfill(ImBinarVI,"holes");
imshow(ImBinarVI)
Imfinal = Im.*uint8(ImBinarVIf);
imshow(Imfinal)
ImfinI = ImBinarHIf&ImBinarVIf&Label;
ImfinI = ImfinI-ImfinS;
ImfinI = imclearborder(ImfinI);
Imfinal = Im.*uint8(~ImfinI);
imshow(Imfinal);
ImfinalIS = ImfinI|ImfinS;
ImfinalP = ~ImfinalIS;
ImFinalI(:,:,1) = ImBgnd.*(ImfinI*255)/255;
ImFinalI(:,:,2) = ImBgnd.*(ImfinI*0)/255;
ImFinalI(:,:,3) = ImBgnd.*(ImfinI*0)/255;
ImFinalS(:,:,1) = ImBgnd.*(ImfinS*100)/255;
ImFinalS(:,:,2) = ImBgnd.*(ImfinS*100)/255;
ImFinalS(:,:,3) = ImBgnd.*(ImfinS*100)/255;
ImFinalP(:,:,1) = ImBgnd.*(ImfinalP*0)/255;
ImFinalP(:,:,2) = ImBgnd.*(ImfinalP*255)/255;
ImFinalP(:,:,3) = ImBgnd.*(ImfinalP*0)/255;
ImfinalIS = Im.*uint8(~ImfinalIS);
Imfinal = ImFinalP+ImFinalI+ImFinalS
imshow(Imfinal)
imshowpair(Im,Imfinal,"montage")
%this is what i did wrong, this is not global
%
%and this is what i realised for this photo, this was the original photo, for this i made the code
%
%i need to help me if you can, i need to do this code global for mode photoes for my graduation, but i dont know how to continue, thank you guys! image processing, filter, choose file to process MATLAB Answers — New Questions
Changing a Drop Down component items via a string.
Hi all,
I am making a GUI for my XML files. The problem is related to a Drop Down component. As shown in the picture:
In the last column (option) and second row, a 1×6 string exist. Here is ther problem. When I manually define a 1×6 string array using the code bellow:
B = ["Red","Yellow","Blue","Green"];
I can change component’s items. But, when I use the bellow opcode:
inStruct.input.group.group(1).param(2).option
An error emerges!
Anyway, my question is how it is possible to change my drop down menu items by the items included in the second row and last column?
TNX.Hi all,
I am making a GUI for my XML files. The problem is related to a Drop Down component. As shown in the picture:
In the last column (option) and second row, a 1×6 string exist. Here is ther problem. When I manually define a 1×6 string array using the code bellow:
B = ["Red","Yellow","Blue","Green"];
I can change component’s items. But, when I use the bellow opcode:
inStruct.input.group.group(1).param(2).option
An error emerges!
Anyway, my question is how it is possible to change my drop down menu items by the items included in the second row and last column?
TNX. Hi all,
I am making a GUI for my XML files. The problem is related to a Drop Down component. As shown in the picture:
In the last column (option) and second row, a 1×6 string exist. Here is ther problem. When I manually define a 1×6 string array using the code bellow:
B = ["Red","Yellow","Blue","Green"];
I can change component’s items. But, when I use the bellow opcode:
inStruct.input.group.group(1).param(2).option
An error emerges!
Anyway, my question is how it is possible to change my drop down menu items by the items included in the second row and last column?
TNX. xml, gui MATLAB Answers — New Questions