Category: Matlab
Category Archives: Matlab
Color input to comm.ConstellationDiagram object
I want to display the scatterplots of 2 different users in my simulation in real-time, for which I am using the comm.ConstellationDiagram object. I would like to use different colours for each user’s scatterplot to distinguish between them. However, comm.ConstellationDiagram does not take a color input.
Scatterplot function takes a color input, but I don’t want the plots on different figures each time I call it. I want the points plotted in real-time in the same figure (for each user), this is why I am using the comm.ConstellationDiagram object.
Here’s a snippet of how I am using it:
constDiag1 = comm.ConstellationDiagram(2, …
"ChannelNames",{‘Header’,’Data’}, …
"ReferenceConstellation",{refConstHeader,refConstData1}, …
"ShowLegend",true, …
"EnableMeasurements",true,…
"Title",’User 1 constellation’);
constDiag2 = comm.ConstellationDiagram(2, …
"ChannelNames",{‘Header’,’Data’}, …
"ReferenceConstellation",{refConstHeader,refConstData2}, …
"ShowLegend",true, …
"EnableMeasurements",true,…
"Title",’User 2 constellation’);
for frame=1:framenum
[rxHeader1,rxData1,rxHeader2,rxData2] = myfunction(captureData);
constDiag1(complex(rxHeader1(:)), …
complex(rxData1(:)));
constDiag2(complex(rxHeader2(:)), …
complex(rxData2(:)));
end
Is there a way to include a colour input to the configuration of the object?
If not, how can I go about making a custom function for obtaining scatterplots in real-time (similar to what comm.ConstellationDiagram does) where I can configure each object in a different color?
Thanks! Any help is appreciated!I want to display the scatterplots of 2 different users in my simulation in real-time, for which I am using the comm.ConstellationDiagram object. I would like to use different colours for each user’s scatterplot to distinguish between them. However, comm.ConstellationDiagram does not take a color input.
Scatterplot function takes a color input, but I don’t want the plots on different figures each time I call it. I want the points plotted in real-time in the same figure (for each user), this is why I am using the comm.ConstellationDiagram object.
Here’s a snippet of how I am using it:
constDiag1 = comm.ConstellationDiagram(2, …
"ChannelNames",{‘Header’,’Data’}, …
"ReferenceConstellation",{refConstHeader,refConstData1}, …
"ShowLegend",true, …
"EnableMeasurements",true,…
"Title",’User 1 constellation’);
constDiag2 = comm.ConstellationDiagram(2, …
"ChannelNames",{‘Header’,’Data’}, …
"ReferenceConstellation",{refConstHeader,refConstData2}, …
"ShowLegend",true, …
"EnableMeasurements",true,…
"Title",’User 2 constellation’);
for frame=1:framenum
[rxHeader1,rxData1,rxHeader2,rxData2] = myfunction(captureData);
constDiag1(complex(rxHeader1(:)), …
complex(rxData1(:)));
constDiag2(complex(rxHeader2(:)), …
complex(rxData2(:)));
end
Is there a way to include a colour input to the configuration of the object?
If not, how can I go about making a custom function for obtaining scatterplots in real-time (similar to what comm.ConstellationDiagram does) where I can configure each object in a different color?
Thanks! Any help is appreciated! I want to display the scatterplots of 2 different users in my simulation in real-time, for which I am using the comm.ConstellationDiagram object. I would like to use different colours for each user’s scatterplot to distinguish between them. However, comm.ConstellationDiagram does not take a color input.
Scatterplot function takes a color input, but I don’t want the plots on different figures each time I call it. I want the points plotted in real-time in the same figure (for each user), this is why I am using the comm.ConstellationDiagram object.
Here’s a snippet of how I am using it:
constDiag1 = comm.ConstellationDiagram(2, …
"ChannelNames",{‘Header’,’Data’}, …
"ReferenceConstellation",{refConstHeader,refConstData1}, …
"ShowLegend",true, …
"EnableMeasurements",true,…
"Title",’User 1 constellation’);
constDiag2 = comm.ConstellationDiagram(2, …
"ChannelNames",{‘Header’,’Data’}, …
"ReferenceConstellation",{refConstHeader,refConstData2}, …
"ShowLegend",true, …
"EnableMeasurements",true,…
"Title",’User 2 constellation’);
for frame=1:framenum
[rxHeader1,rxData1,rxHeader2,rxData2] = myfunction(captureData);
constDiag1(complex(rxHeader1(:)), …
complex(rxData1(:)));
constDiag2(complex(rxHeader2(:)), …
complex(rxData2(:)));
end
Is there a way to include a colour input to the configuration of the object?
If not, how can I go about making a custom function for obtaining scatterplots in real-time (similar to what comm.ConstellationDiagram does) where I can configure each object in a different color?
Thanks! Any help is appreciated! scatterplot, constellation diagram, plotting in real-time, scatterplot colour MATLAB Answers — New Questions
PMSM speed ramp input with V/f scalar control does not work
Hi,
I’m trying to implement a V/f scalar control for a PMSM, for speed step input there is no problem and the motor model works fine up until 2000 rpm more or less. But I want to set a reference speed that follows a ramp but somehow the motor becomes unstable way earlier than expected and the motor speed whas a different slope than the reference speed and I dont know why.
For instances this is the motor behavior under different speeds:
(also not sure why there are this huge speed drops at some step inputs)
And this is how it responds to a ramp input:
So, Why does the motor becomes unstable before thatn predicted when its subjected to a ramp input? Why does it have a different slope than the reference signal?
I have attached the simulink model along with the script that it is referenced to.Hi,
I’m trying to implement a V/f scalar control for a PMSM, for speed step input there is no problem and the motor model works fine up until 2000 rpm more or less. But I want to set a reference speed that follows a ramp but somehow the motor becomes unstable way earlier than expected and the motor speed whas a different slope than the reference speed and I dont know why.
For instances this is the motor behavior under different speeds:
(also not sure why there are this huge speed drops at some step inputs)
And this is how it responds to a ramp input:
So, Why does the motor becomes unstable before thatn predicted when its subjected to a ramp input? Why does it have a different slope than the reference signal?
I have attached the simulink model along with the script that it is referenced to. Hi,
I’m trying to implement a V/f scalar control for a PMSM, for speed step input there is no problem and the motor model works fine up until 2000 rpm more or less. But I want to set a reference speed that follows a ramp but somehow the motor becomes unstable way earlier than expected and the motor speed whas a different slope than the reference speed and I dont know why.
For instances this is the motor behavior under different speeds:
(also not sure why there are this huge speed drops at some step inputs)
And this is how it responds to a ramp input:
So, Why does the motor becomes unstable before thatn predicted when its subjected to a ramp input? Why does it have a different slope than the reference signal?
I have attached the simulink model along with the script that it is referenced to. pmsm scalar control, pmsm v/f control, pmsm speed response with scalar control, pmsm speed response with v/f control MATLAB Answers — New Questions
Gate Driver – How to incorporate bootstrap circuitry?
I am attempting to use two of the Gate Driver symbol in Simscape to model my selected half-bridge driver. I am using two Gate Driver symbols because it appears the Half-Bridge Driver symbol only accepts one input; in my system, there will be two discrete inputs to the driver.
I do not see from the connections available on the Gate Driver symbol how I would implement bootstrap circuitry to properly bias the upper MOSFET in my half-bridge.
Bootstrap circuitry referring to the highlighted elements shown below:
Thanks!
-MI am attempting to use two of the Gate Driver symbol in Simscape to model my selected half-bridge driver. I am using two Gate Driver symbols because it appears the Half-Bridge Driver symbol only accepts one input; in my system, there will be two discrete inputs to the driver.
I do not see from the connections available on the Gate Driver symbol how I would implement bootstrap circuitry to properly bias the upper MOSFET in my half-bridge.
Bootstrap circuitry referring to the highlighted elements shown below:
Thanks!
-M I am attempting to use two of the Gate Driver symbol in Simscape to model my selected half-bridge driver. I am using two Gate Driver symbols because it appears the Half-Bridge Driver symbol only accepts one input; in my system, there will be two discrete inputs to the driver.
I do not see from the connections available on the Gate Driver symbol how I would implement bootstrap circuitry to properly bias the upper MOSFET in my half-bridge.
Bootstrap circuitry referring to the highlighted elements shown below:
Thanks!
-M simscape, gate driver, half-bridge MATLAB Answers — New Questions
Is it possible to ‘interpolate’ in FFT data?
We kmow OTF and PSF are continuous, can be interpolate inside it (<cutoff freq ) even when we express them wIth matrix use integer row&col coordinate .
now I have a image, and get its FFT2, and find some feature like max or min only with row and col,
but I know true max or min not at that integer row and col exactly, It is really at a fraction position near that integer row and col in matrix.
How to get it if I know fraction or decimal position ?
In frequency domain, can exten matrix size with 0, but can not interpolate although we can interpolate at time domain.
How to do ?
Maybe I can do so like such method : in time domain , matrix .* with exp( – j ke), {ke is a decimal number part }, to realize freq shift effect, after that, FFT, now at that row&col coordinate really is a value corresponding to [ row&col + decimal ke ] position, so I get it .
Such idea is right ? I am not expert at FFT, who can tell me , Is it Right ?
or how to find the feature not exactly at discrete integer row&col coordinate ?
I need some value at real flot number row&col coordinate ?
—————————————————————————————————————–
I mean :
For simple example:
there are 512 data point with coordinate 1~512, transfer to freq domain with FFT, it is 512 mag and phase with coordinate -256~255 * 1/256 .
now if I specially add a cosine wave with freq 180.324 *1/512 to 512 data point (I used it as a special inner reference), then transfer to freq domain with FFT.
here , how to find mag and phase information of this added cosine wave in freq domain ?
freq 180.324 , is not a integer -256~255 coordinate, so how to find it ?
sample code:
% Time domain
t = linspace(1,512,512);
g = 2*sin(2*pi*t*16/512) + 0.5*sin(2*pi*t*64/512)+ 0.4*sin(2*pi*t*128/512);
gadd = g+0.2*cos(2*pi*t*180.327/512);
%gadd = g+5*sin(2*pi*t*180.327/512);
% now add 180.324 or any another not N/512
subplot(2,2,1);
plot(g);
title("Time domain 3 sin")
subplot(2,2,2);
plot(g);
title("Time domain, 3 sin + cos")
fco = linspace(-256,255,512);
F=fftshift(fft(g));
F1=fftshift(fft(gadd));
subplot(2,2,3);
stem (fco,real(F));
title("Freq domain, 3 sin")
subplot(2,2,4);
stem (fco,real(F1));
title("Freq domain, 3 sin + cos")
% how to find that 180.327 accuratly ?We kmow OTF and PSF are continuous, can be interpolate inside it (<cutoff freq ) even when we express them wIth matrix use integer row&col coordinate .
now I have a image, and get its FFT2, and find some feature like max or min only with row and col,
but I know true max or min not at that integer row and col exactly, It is really at a fraction position near that integer row and col in matrix.
How to get it if I know fraction or decimal position ?
In frequency domain, can exten matrix size with 0, but can not interpolate although we can interpolate at time domain.
How to do ?
Maybe I can do so like such method : in time domain , matrix .* with exp( – j ke), {ke is a decimal number part }, to realize freq shift effect, after that, FFT, now at that row&col coordinate really is a value corresponding to [ row&col + decimal ke ] position, so I get it .
Such idea is right ? I am not expert at FFT, who can tell me , Is it Right ?
or how to find the feature not exactly at discrete integer row&col coordinate ?
I need some value at real flot number row&col coordinate ?
—————————————————————————————————————–
I mean :
For simple example:
there are 512 data point with coordinate 1~512, transfer to freq domain with FFT, it is 512 mag and phase with coordinate -256~255 * 1/256 .
now if I specially add a cosine wave with freq 180.324 *1/512 to 512 data point (I used it as a special inner reference), then transfer to freq domain with FFT.
here , how to find mag and phase information of this added cosine wave in freq domain ?
freq 180.324 , is not a integer -256~255 coordinate, so how to find it ?
sample code:
% Time domain
t = linspace(1,512,512);
g = 2*sin(2*pi*t*16/512) + 0.5*sin(2*pi*t*64/512)+ 0.4*sin(2*pi*t*128/512);
gadd = g+0.2*cos(2*pi*t*180.327/512);
%gadd = g+5*sin(2*pi*t*180.327/512);
% now add 180.324 or any another not N/512
subplot(2,2,1);
plot(g);
title("Time domain 3 sin")
subplot(2,2,2);
plot(g);
title("Time domain, 3 sin + cos")
fco = linspace(-256,255,512);
F=fftshift(fft(g));
F1=fftshift(fft(gadd));
subplot(2,2,3);
stem (fco,real(F));
title("Freq domain, 3 sin")
subplot(2,2,4);
stem (fco,real(F1));
title("Freq domain, 3 sin + cos")
% how to find that 180.327 accuratly ? We kmow OTF and PSF are continuous, can be interpolate inside it (<cutoff freq ) even when we express them wIth matrix use integer row&col coordinate .
now I have a image, and get its FFT2, and find some feature like max or min only with row and col,
but I know true max or min not at that integer row and col exactly, It is really at a fraction position near that integer row and col in matrix.
How to get it if I know fraction or decimal position ?
In frequency domain, can exten matrix size with 0, but can not interpolate although we can interpolate at time domain.
How to do ?
Maybe I can do so like such method : in time domain , matrix .* with exp( – j ke), {ke is a decimal number part }, to realize freq shift effect, after that, FFT, now at that row&col coordinate really is a value corresponding to [ row&col + decimal ke ] position, so I get it .
Such idea is right ? I am not expert at FFT, who can tell me , Is it Right ?
or how to find the feature not exactly at discrete integer row&col coordinate ?
I need some value at real flot number row&col coordinate ?
—————————————————————————————————————–
I mean :
For simple example:
there are 512 data point with coordinate 1~512, transfer to freq domain with FFT, it is 512 mag and phase with coordinate -256~255 * 1/256 .
now if I specially add a cosine wave with freq 180.324 *1/512 to 512 data point (I used it as a special inner reference), then transfer to freq domain with FFT.
here , how to find mag and phase information of this added cosine wave in freq domain ?
freq 180.324 , is not a integer -256~255 coordinate, so how to find it ?
sample code:
% Time domain
t = linspace(1,512,512);
g = 2*sin(2*pi*t*16/512) + 0.5*sin(2*pi*t*64/512)+ 0.4*sin(2*pi*t*128/512);
gadd = g+0.2*cos(2*pi*t*180.327/512);
%gadd = g+5*sin(2*pi*t*180.327/512);
% now add 180.324 or any another not N/512
subplot(2,2,1);
plot(g);
title("Time domain 3 sin")
subplot(2,2,2);
plot(g);
title("Time domain, 3 sin + cos")
fco = linspace(-256,255,512);
F=fftshift(fft(g));
F1=fftshift(fft(gadd));
subplot(2,2,3);
stem (fco,real(F));
title("Freq domain, 3 sin")
subplot(2,2,4);
stem (fco,real(F1));
title("Freq domain, 3 sin + cos")
% how to find that 180.327 accuratly ? fft, interpolate, discrete, continuous MATLAB Answers — New Questions
how to have a matlab script give you a choice to automatically open other scripts
Hi, I want to have a starting script where it allows me to open a different script. For example I want the main script to ask me, do you wish to follow procedure A? and then if I select yes, then automatically the matlab will open script A. If the main script asks, do you wish procedure B? then Matlab opens automatically script B and so on. Then once in the secondary script, I will enter the parameters needed to perform the calculation. Thank you.Hi, I want to have a starting script where it allows me to open a different script. For example I want the main script to ask me, do you wish to follow procedure A? and then if I select yes, then automatically the matlab will open script A. If the main script asks, do you wish procedure B? then Matlab opens automatically script B and so on. Then once in the secondary script, I will enter the parameters needed to perform the calculation. Thank you. Hi, I want to have a starting script where it allows me to open a different script. For example I want the main script to ask me, do you wish to follow procedure A? and then if I select yes, then automatically the matlab will open script A. If the main script asks, do you wish procedure B? then Matlab opens automatically script B and so on. Then once in the secondary script, I will enter the parameters needed to perform the calculation. Thank you. script MATLAB Answers — New Questions
Combine several matrix with NaNs
I need to combine several matrixes of 500×500 elements that contains NaN. The matrixes must be combined in the way they keep their size but replace NaN by the elements of the other matrix.
I can easily do it for two matrixes:
% Cx is a strucutre that I use to store these matrixes. Cx has several matrixes e.g Cx(1).Z Cx(2).Z …
or=Cx(1).Z; %I want to add the elements to the first matrix (or)
nr=Cx(2).Z; % this is the second matrix
xn=isnan(or); %I select the NaN’s
or(xn)=nr(xn); %I can get now combined elements between Cx(1).Z and Cx(2).Z, it works good until here
%I need to do the same now for all the other matrixes in my structure (Cx),so the combination will be cummulative, I mean use the resulting matrix from merging Cx(1).Z and Cx(2).Z to merge with Cx(3).Z, and then use this output to merge with Cx(4).Z …. and so on
I tough that a loop would be usefull
or=Cx(1).Z;
xn=isnan(or);
for i=1:numel(Cx)
nr=Cx(i).Z;
or(xn)=nr(xn);
end
but the output or is constantly overwrited and I can get a combination of the matrixes
any suggestion?
thanks in advanceI need to combine several matrixes of 500×500 elements that contains NaN. The matrixes must be combined in the way they keep their size but replace NaN by the elements of the other matrix.
I can easily do it for two matrixes:
% Cx is a strucutre that I use to store these matrixes. Cx has several matrixes e.g Cx(1).Z Cx(2).Z …
or=Cx(1).Z; %I want to add the elements to the first matrix (or)
nr=Cx(2).Z; % this is the second matrix
xn=isnan(or); %I select the NaN’s
or(xn)=nr(xn); %I can get now combined elements between Cx(1).Z and Cx(2).Z, it works good until here
%I need to do the same now for all the other matrixes in my structure (Cx),so the combination will be cummulative, I mean use the resulting matrix from merging Cx(1).Z and Cx(2).Z to merge with Cx(3).Z, and then use this output to merge with Cx(4).Z …. and so on
I tough that a loop would be usefull
or=Cx(1).Z;
xn=isnan(or);
for i=1:numel(Cx)
nr=Cx(i).Z;
or(xn)=nr(xn);
end
but the output or is constantly overwrited and I can get a combination of the matrixes
any suggestion?
thanks in advance I need to combine several matrixes of 500×500 elements that contains NaN. The matrixes must be combined in the way they keep their size but replace NaN by the elements of the other matrix.
I can easily do it for two matrixes:
% Cx is a strucutre that I use to store these matrixes. Cx has several matrixes e.g Cx(1).Z Cx(2).Z …
or=Cx(1).Z; %I want to add the elements to the first matrix (or)
nr=Cx(2).Z; % this is the second matrix
xn=isnan(or); %I select the NaN’s
or(xn)=nr(xn); %I can get now combined elements between Cx(1).Z and Cx(2).Z, it works good until here
%I need to do the same now for all the other matrixes in my structure (Cx),so the combination will be cummulative, I mean use the resulting matrix from merging Cx(1).Z and Cx(2).Z to merge with Cx(3).Z, and then use this output to merge with Cx(4).Z …. and so on
I tough that a loop would be usefull
or=Cx(1).Z;
xn=isnan(or);
for i=1:numel(Cx)
nr=Cx(i).Z;
or(xn)=nr(xn);
end
but the output or is constantly overwrited and I can get a combination of the matrixes
any suggestion?
thanks in advance matlab, matrix, nan, for loop MATLAB Answers — New Questions
How can I access the comp.soft-sys.matlab newsgroup without Usenet newsgroup access?
Is there any site which carries up to date news for the comp.soft-sys.matlab Usenet newsgroup which I can access even if my site does not support NNTP access?Is there any site which carries up to date news for the comp.soft-sys.matlab Usenet newsgroup which I can access even if my site does not support NNTP access? Is there any site which carries up to date news for the comp.soft-sys.matlab Usenet newsgroup which I can access even if my site does not support NNTP access? comp.soft-sys.matlab, without, usenet, newsgroup, access, cssm MATLAB Answers — New Questions
Measurement of open circuit voltage of PV panel in simulink
When I try to measure open circuit voltage between + and – on simulink PV panel, I always get Nan. How can I measure the open circuit voltage ?When I try to measure open circuit voltage between + and – on simulink PV panel, I always get Nan. How can I measure the open circuit voltage ? When I try to measure open circuit voltage between + and – on simulink PV panel, I always get Nan. How can I measure the open circuit voltage ? pv panel MATLAB Answers — New Questions
NARX DNN: hidden layers and activation function
Hi there, can you please tell me how to set the number of hidden layers and the activation function of the output layer in a NARX network? It seems that I can only use one hidden layer and the linear function in the output layer.Hi there, can you please tell me how to set the number of hidden layers and the activation function of the output layer in a NARX network? It seems that I can only use one hidden layer and the linear function in the output layer. Hi there, can you please tell me how to set the number of hidden layers and the activation function of the output layer in a NARX network? It seems that I can only use one hidden layer and the linear function in the output layer. narnet, autorregressive, narx MATLAB Answers — New Questions
GPS Signal Transmission, Acquisition and Tracking Using PlutoSDR
Will this example work as a GPS Spoofer (GPS Signal Transmission, Acquisition and Tracking Using PlutoSDR) ??Will this example work as a GPS Spoofer (GPS Signal Transmission, Acquisition and Tracking Using PlutoSDR) ?? Will this example work as a GPS Spoofer (GPS Signal Transmission, Acquisition and Tracking Using PlutoSDR) ?? gps spoofer, gps MATLAB Answers — New Questions
How do you indicate a line between a user and a GPS satellite?
The distance between the satellite and the user was obtained, but it was obtained with the ECEF coordinate system.
If you use ecef2enu, a function that changes the distance to the ENU coordinate system, errors continue to occur. I am curious about the solution, and furthermore, I want to use the unit vector to reduce the distance and then visualize the satellite-user distance.
receiverLat = 37.498759;
receiverLon = 127.027487;
receiverAlt = 0;
t = datetime(‘now’, ‘TimeZone’, ‘Local’);
[satPos, ~] = gnssconstellation(t);
wgs84 = wgs84Ellipsoid(‘meters’);
[recX, recY, recZ] = geodetic2ecef(wgs84, receiverLat, receiverLon, receiverAlt);
distances = zeros(size(satPos, 1), 1);
for i = 1:size(satPos, 1)
satX = satPos(i, 1);
satY = satPos(i, 2);
satZ = satPos(i, 3);
distances(i) = sqrt((satX – recX)^2 + (satY – recY)^2 + (satZ – recZ)^2);
end
disp(‘Satellite location:’);
disp(satPos);
disp(‘Receiver location:’);
disp([recX, recY, recZ]);
disp(‘Satellite-Receiver distances:’);
disp(distances);The distance between the satellite and the user was obtained, but it was obtained with the ECEF coordinate system.
If you use ecef2enu, a function that changes the distance to the ENU coordinate system, errors continue to occur. I am curious about the solution, and furthermore, I want to use the unit vector to reduce the distance and then visualize the satellite-user distance.
receiverLat = 37.498759;
receiverLon = 127.027487;
receiverAlt = 0;
t = datetime(‘now’, ‘TimeZone’, ‘Local’);
[satPos, ~] = gnssconstellation(t);
wgs84 = wgs84Ellipsoid(‘meters’);
[recX, recY, recZ] = geodetic2ecef(wgs84, receiverLat, receiverLon, receiverAlt);
distances = zeros(size(satPos, 1), 1);
for i = 1:size(satPos, 1)
satX = satPos(i, 1);
satY = satPos(i, 2);
satZ = satPos(i, 3);
distances(i) = sqrt((satX – recX)^2 + (satY – recY)^2 + (satZ – recZ)^2);
end
disp(‘Satellite location:’);
disp(satPos);
disp(‘Receiver location:’);
disp([recX, recY, recZ]);
disp(‘Satellite-Receiver distances:’);
disp(distances); The distance between the satellite and the user was obtained, but it was obtained with the ECEF coordinate system.
If you use ecef2enu, a function that changes the distance to the ENU coordinate system, errors continue to occur. I am curious about the solution, and furthermore, I want to use the unit vector to reduce the distance and then visualize the satellite-user distance.
receiverLat = 37.498759;
receiverLon = 127.027487;
receiverAlt = 0;
t = datetime(‘now’, ‘TimeZone’, ‘Local’);
[satPos, ~] = gnssconstellation(t);
wgs84 = wgs84Ellipsoid(‘meters’);
[recX, recY, recZ] = geodetic2ecef(wgs84, receiverLat, receiverLon, receiverAlt);
distances = zeros(size(satPos, 1), 1);
for i = 1:size(satPos, 1)
satX = satPos(i, 1);
satY = satPos(i, 2);
satZ = satPos(i, 3);
distances(i) = sqrt((satX – recX)^2 + (satY – recY)^2 + (satZ – recZ)^2);
end
disp(‘Satellite location:’);
disp(satPos);
disp(‘Receiver location:’);
disp([recX, recY, recZ]);
disp(‘Satellite-Receiver distances:’);
disp(distances); gps, gnss, unit vector, ecef, enu MATLAB Answers — New Questions
How to change resolution of an image ?
What is the command/keyword for changing resolution(ppi) of image in matlab? How we can use that command? Please kindly give an exampleWhat is the command/keyword for changing resolution(ppi) of image in matlab? How we can use that command? Please kindly give an example What is the command/keyword for changing resolution(ppi) of image in matlab? How we can use that command? Please kindly give an example image processing, digital image processing MATLAB Answers — New Questions
Detection of disconnected server when using tcpclient() and write()
I am using the tcpclient() function to establish a connection to a server I built and I would like to be able to detect when the server disconnects. My current understanding is that the way to do that is to attempt a write and if the write fails, the connection can be considered as disconnected.
% I start the server before the first matlab command
t= tcpclient("192.168.10.188", 65434); %connects to server
msg = uint8([1,2,3]); % basic message with 3 bytes
write(t,msg); % sends message to server. Server receives the data.
write(t,msg); % sends message to server. Server receives the data.
write(t,msg); % sends message to server. Server receives the data.
write(t,msg); % sends message to server. Server receives the data.
The above code works fine as expected.
Next, I run the same code, but I disconnect the server after the connection is established but before the write is sent.
% I start the server before the first matlab command
t= tcpclient("192.168.10.188", 65434);
% I disconnect the server before attempting the first write
msg = uint8([1,2,3]); % basic message with 3 bytes
write(t,msg); % sends message to disconnected server. No error raised.
write(t,msg); % sends message to disconnected server. "Error using asyncio.MessageHandler/onError" is shown in command window
write(t,msg); % sends message to disconnected server. "An established connection was terminated. Please create a new TCPCLIENT." is shown in command window
write(t,msg); % sends message to disconnected server. "Invalid or deleted object." is shown in command window.
I can handle the last 2 errors using a try/catch, but I am not able to handle the "Error using asyncio.MessageHandler/onError" error with a try/catch.
I think this is because the error is raised asynchronously. I would like to be able to catch this error to avoid error messages in the final application.
According to the tcpclient page, there is a callback property called ErrorOccurredFcn that seems to be built to handle that.
However, even with the following code, I still get the same "Error using asyncio.MessageHandler/onError" error and my error handler function is not executed.
function error_handler()
disp("Asynchronous error handled"); % never executed
end
% I start the server before the first matlab command
t= tcpclient("192.168.10.188", 65434);
t.ErrorOccurredFcn = @error_handler;
% I disconnect the server before attempting the first write
msg = uint8([1,2,3]); % basic message with 3 bytes
write(t,msg); % sends message to disconnected server. No error raised.
write(t,msg); % sends message to disconnected server. "Error using asyncio.MessageHandler/onError" is shown in command window
So, I still get an error in the command window after using the ErrorOccurredFcn callback property.
The read() command does not seem to raise an exception whenever the server is disconnected.
So, what is the proper way to detect if the server is disconnected without getting an error in the command window?I am using the tcpclient() function to establish a connection to a server I built and I would like to be able to detect when the server disconnects. My current understanding is that the way to do that is to attempt a write and if the write fails, the connection can be considered as disconnected.
% I start the server before the first matlab command
t= tcpclient("192.168.10.188", 65434); %connects to server
msg = uint8([1,2,3]); % basic message with 3 bytes
write(t,msg); % sends message to server. Server receives the data.
write(t,msg); % sends message to server. Server receives the data.
write(t,msg); % sends message to server. Server receives the data.
write(t,msg); % sends message to server. Server receives the data.
The above code works fine as expected.
Next, I run the same code, but I disconnect the server after the connection is established but before the write is sent.
% I start the server before the first matlab command
t= tcpclient("192.168.10.188", 65434);
% I disconnect the server before attempting the first write
msg = uint8([1,2,3]); % basic message with 3 bytes
write(t,msg); % sends message to disconnected server. No error raised.
write(t,msg); % sends message to disconnected server. "Error using asyncio.MessageHandler/onError" is shown in command window
write(t,msg); % sends message to disconnected server. "An established connection was terminated. Please create a new TCPCLIENT." is shown in command window
write(t,msg); % sends message to disconnected server. "Invalid or deleted object." is shown in command window.
I can handle the last 2 errors using a try/catch, but I am not able to handle the "Error using asyncio.MessageHandler/onError" error with a try/catch.
I think this is because the error is raised asynchronously. I would like to be able to catch this error to avoid error messages in the final application.
According to the tcpclient page, there is a callback property called ErrorOccurredFcn that seems to be built to handle that.
However, even with the following code, I still get the same "Error using asyncio.MessageHandler/onError" error and my error handler function is not executed.
function error_handler()
disp("Asynchronous error handled"); % never executed
end
% I start the server before the first matlab command
t= tcpclient("192.168.10.188", 65434);
t.ErrorOccurredFcn = @error_handler;
% I disconnect the server before attempting the first write
msg = uint8([1,2,3]); % basic message with 3 bytes
write(t,msg); % sends message to disconnected server. No error raised.
write(t,msg); % sends message to disconnected server. "Error using asyncio.MessageHandler/onError" is shown in command window
So, I still get an error in the command window after using the ErrorOccurredFcn callback property.
The read() command does not seem to raise an exception whenever the server is disconnected.
So, what is the proper way to detect if the server is disconnected without getting an error in the command window? I am using the tcpclient() function to establish a connection to a server I built and I would like to be able to detect when the server disconnects. My current understanding is that the way to do that is to attempt a write and if the write fails, the connection can be considered as disconnected.
% I start the server before the first matlab command
t= tcpclient("192.168.10.188", 65434); %connects to server
msg = uint8([1,2,3]); % basic message with 3 bytes
write(t,msg); % sends message to server. Server receives the data.
write(t,msg); % sends message to server. Server receives the data.
write(t,msg); % sends message to server. Server receives the data.
write(t,msg); % sends message to server. Server receives the data.
The above code works fine as expected.
Next, I run the same code, but I disconnect the server after the connection is established but before the write is sent.
% I start the server before the first matlab command
t= tcpclient("192.168.10.188", 65434);
% I disconnect the server before attempting the first write
msg = uint8([1,2,3]); % basic message with 3 bytes
write(t,msg); % sends message to disconnected server. No error raised.
write(t,msg); % sends message to disconnected server. "Error using asyncio.MessageHandler/onError" is shown in command window
write(t,msg); % sends message to disconnected server. "An established connection was terminated. Please create a new TCPCLIENT." is shown in command window
write(t,msg); % sends message to disconnected server. "Invalid or deleted object." is shown in command window.
I can handle the last 2 errors using a try/catch, but I am not able to handle the "Error using asyncio.MessageHandler/onError" error with a try/catch.
I think this is because the error is raised asynchronously. I would like to be able to catch this error to avoid error messages in the final application.
According to the tcpclient page, there is a callback property called ErrorOccurredFcn that seems to be built to handle that.
However, even with the following code, I still get the same "Error using asyncio.MessageHandler/onError" error and my error handler function is not executed.
function error_handler()
disp("Asynchronous error handled"); % never executed
end
% I start the server before the first matlab command
t= tcpclient("192.168.10.188", 65434);
t.ErrorOccurredFcn = @error_handler;
% I disconnect the server before attempting the first write
msg = uint8([1,2,3]); % basic message with 3 bytes
write(t,msg); % sends message to disconnected server. No error raised.
write(t,msg); % sends message to disconnected server. "Error using asyncio.MessageHandler/onError" is shown in command window
So, I still get an error in the command window after using the ErrorOccurredFcn callback property.
The read() command does not seem to raise an exception whenever the server is disconnected.
So, what is the proper way to detect if the server is disconnected without getting an error in the command window? tcpclient, erroroccurredfcn, write, disconnect, disconnection MATLAB Answers — New Questions
can someone help me? when I want to insert the plaintext and also the matrix to the hill cipher, syntax out: Error using hillspasi (line 2) Not enough input arguments. is there something wrong in my code?
function hillspasi(x,k)
[r,c]=size(k);
if r~=c %jika jumlah baris tidak sama dengan jumlah kolom
disp(‘Kunci harus matrik bujur sangkar’)
else
data=upper(x);
if ismember(‘ ‘,data)==1 %cek inputan mengandung spasi
spasi=find(data==’ ‘);
km=size(spasi,2);
else
spasi=0;
end;
n=size(data,2);
xx=[];
a=0;
for i=1:n %menghilangkan spasi pada input jika ada
if data(i)~=’ ‘
a=a+1;
xx=[xx data(i)];
end;
end;
s=mod(a,r);
if s~=0
ss=r-s;
sss=[];
for i=1:ss
sss=[sss ‘X’ ];
end;
xx=[xx sss];
a=a+ss;
else
ss=0;
end;
i=1;
h=[];
while i<=a
m=[];
for j=i:(i-1+r)
m=[m xx(j)];
end;
m=double(m)-65;
c=mod(k*m’,26);
c=(c+65)’;
h=[h char(c)];
i=i+r;
end;
if spasi~=0
hx=[];j=1;kk=0;
sj=spasi(j);
for i=1:n+ss
if i==sj
hx=[hx ‘ ‘];
j=j+1;
if j<=km
sj=spasi(j);
end;
else
kk=kk+1;
if kk<=a
d=h(kk);
hx=[hx d];
end;
end;
end;
else
hx=h;
end;
hh=[];
for i=1:n
hh=[hh hx(i)];
end;
disp(‘CIPHER : ‘)
disp(‘~~~~~~~~’)
disp(hx)
if ~isequal(hx,hh)
disp(‘ ‘)
disp(‘CIPHER DENGAN MENGHILANGKAN KARAKTER TAMBAHAN :’)
disp(‘~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~’)
disp(hh)
end;
end;function hillspasi(x,k)
[r,c]=size(k);
if r~=c %jika jumlah baris tidak sama dengan jumlah kolom
disp(‘Kunci harus matrik bujur sangkar’)
else
data=upper(x);
if ismember(‘ ‘,data)==1 %cek inputan mengandung spasi
spasi=find(data==’ ‘);
km=size(spasi,2);
else
spasi=0;
end;
n=size(data,2);
xx=[];
a=0;
for i=1:n %menghilangkan spasi pada input jika ada
if data(i)~=’ ‘
a=a+1;
xx=[xx data(i)];
end;
end;
s=mod(a,r);
if s~=0
ss=r-s;
sss=[];
for i=1:ss
sss=[sss ‘X’ ];
end;
xx=[xx sss];
a=a+ss;
else
ss=0;
end;
i=1;
h=[];
while i<=a
m=[];
for j=i:(i-1+r)
m=[m xx(j)];
end;
m=double(m)-65;
c=mod(k*m’,26);
c=(c+65)’;
h=[h char(c)];
i=i+r;
end;
if spasi~=0
hx=[];j=1;kk=0;
sj=spasi(j);
for i=1:n+ss
if i==sj
hx=[hx ‘ ‘];
j=j+1;
if j<=km
sj=spasi(j);
end;
else
kk=kk+1;
if kk<=a
d=h(kk);
hx=[hx d];
end;
end;
end;
else
hx=h;
end;
hh=[];
for i=1:n
hh=[hh hx(i)];
end;
disp(‘CIPHER : ‘)
disp(‘~~~~~~~~’)
disp(hx)
if ~isequal(hx,hh)
disp(‘ ‘)
disp(‘CIPHER DENGAN MENGHILANGKAN KARAKTER TAMBAHAN :’)
disp(‘~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~’)
disp(hh)
end;
end; function hillspasi(x,k)
[r,c]=size(k);
if r~=c %jika jumlah baris tidak sama dengan jumlah kolom
disp(‘Kunci harus matrik bujur sangkar’)
else
data=upper(x);
if ismember(‘ ‘,data)==1 %cek inputan mengandung spasi
spasi=find(data==’ ‘);
km=size(spasi,2);
else
spasi=0;
end;
n=size(data,2);
xx=[];
a=0;
for i=1:n %menghilangkan spasi pada input jika ada
if data(i)~=’ ‘
a=a+1;
xx=[xx data(i)];
end;
end;
s=mod(a,r);
if s~=0
ss=r-s;
sss=[];
for i=1:ss
sss=[sss ‘X’ ];
end;
xx=[xx sss];
a=a+ss;
else
ss=0;
end;
i=1;
h=[];
while i<=a
m=[];
for j=i:(i-1+r)
m=[m xx(j)];
end;
m=double(m)-65;
c=mod(k*m’,26);
c=(c+65)’;
h=[h char(c)];
i=i+r;
end;
if spasi~=0
hx=[];j=1;kk=0;
sj=spasi(j);
for i=1:n+ss
if i==sj
hx=[hx ‘ ‘];
j=j+1;
if j<=km
sj=spasi(j);
end;
else
kk=kk+1;
if kk<=a
d=h(kk);
hx=[hx d];
end;
end;
end;
else
hx=h;
end;
hh=[];
for i=1:n
hh=[hh hx(i)];
end;
disp(‘CIPHER : ‘)
disp(‘~~~~~~~~’)
disp(hx)
if ~isequal(hx,hh)
disp(‘ ‘)
disp(‘CIPHER DENGAN MENGHILANGKAN KARAKTER TAMBAHAN :’)
disp(‘~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~’)
disp(hh)
end;
end; function, hill cipher MATLAB Answers — New Questions
Issue with dispaly of 3D images created from multiple 2D slices
Hi,
I have multiple 2D grayscale image slices (all of them are of same dimensions). I need to stack them to dispaly 3D image. I tried cat function and then implay. But this just plays video, I am not able to see 3D image.
I came across many threads relevant to this. But I am not sure which one will serve the purpose.
I have attached few 2D grayscale slices here. Could someone please suggest the possible method to get 3D reconstruction from these images?Hi,
I have multiple 2D grayscale image slices (all of them are of same dimensions). I need to stack them to dispaly 3D image. I tried cat function and then implay. But this just plays video, I am not able to see 3D image.
I came across many threads relevant to this. But I am not sure which one will serve the purpose.
I have attached few 2D grayscale slices here. Could someone please suggest the possible method to get 3D reconstruction from these images? Hi,
I have multiple 2D grayscale image slices (all of them are of same dimensions). I need to stack them to dispaly 3D image. I tried cat function and then implay. But this just plays video, I am not able to see 3D image.
I came across many threads relevant to this. But I am not sure which one will serve the purpose.
I have attached few 2D grayscale slices here. Could someone please suggest the possible method to get 3D reconstruction from these images? 3d image, focalstacks, ct images, image3d, vol3d, image analysis MATLAB Answers — New Questions
Remove NaNs from uitable Matlab App
Is there any way to remove NaNs from the uitable? When i read in the table and there is empty cells, the uitable will present this as NaNs. Is there any way to change this to just show empty cells?
Cheers.Is there any way to remove NaNs from the uitable? When i read in the table and there is empty cells, the uitable will present this as NaNs. Is there any way to change this to just show empty cells?
Cheers. Is there any way to remove NaNs from the uitable? When i read in the table and there is empty cells, the uitable will present this as NaNs. Is there any way to change this to just show empty cells?
Cheers. uitable, table, nans, nan MATLAB Answers — New Questions
Issue with TimeControls getting stuck
I have these TCs running every day. However yesterday I noted it seems the TC execution got stuck for 2 of them? Below screenshot is from today, so it is weird these do not show the correct future time, also note the 1 min difference bw. Last Ran & Run At …
I now modifed and saved both and it seems they got "restarted" and now show the future date correctly. Hopefully that did not destroy the evidence 🙂 but you have below screenshot anyway.
Hope someone can figure out what made these get "stuck"?I have these TCs running every day. However yesterday I noted it seems the TC execution got stuck for 2 of them? Below screenshot is from today, so it is weird these do not show the correct future time, also note the 1 min difference bw. Last Ran & Run At …
I now modifed and saved both and it seems they got "restarted" and now show the future date correctly. Hopefully that did not destroy the evidence 🙂 but you have below screenshot anyway.
Hope someone can figure out what made these get "stuck"? I have these TCs running every day. However yesterday I noted it seems the TC execution got stuck for 2 of them? Below screenshot is from today, so it is weird these do not show the correct future time, also note the 1 min difference bw. Last Ran & Run At …
I now modifed and saved both and it seems they got "restarted" and now show the future date correctly. Hopefully that did not destroy the evidence 🙂 but you have below screenshot anyway.
Hope someone can figure out what made these get "stuck"? thingspeak MATLAB Answers — New Questions
Error using Table with New Installation of 2022a
When I run these simple commands, I get the following error. I’m not sure where to look to address this.
xmin=1; xmax=2; ymin=3; ymax=5;
tst = table(xmin,xmax,ymin,ymax);
Error using table
The specified superclass ‘matlab.mixin.indexing.RedefinesDot’ contains a parse error, cannot be
found on MATLAB’s search path, or is shadowed by another file with the same name.
I have been using version 2021a previously and 2022a was just installed.When I run these simple commands, I get the following error. I’m not sure where to look to address this.
xmin=1; xmax=2; ymin=3; ymax=5;
tst = table(xmin,xmax,ymin,ymax);
Error using table
The specified superclass ‘matlab.mixin.indexing.RedefinesDot’ contains a parse error, cannot be
found on MATLAB’s search path, or is shadowed by another file with the same name.
I have been using version 2021a previously and 2022a was just installed. When I run these simple commands, I get the following error. I’m not sure where to look to address this.
xmin=1; xmax=2; ymin=3; ymax=5;
tst = table(xmin,xmax,ymin,ymax);
Error using table
The specified superclass ‘matlab.mixin.indexing.RedefinesDot’ contains a parse error, cannot be
found on MATLAB’s search path, or is shadowed by another file with the same name.
I have been using version 2021a previously and 2022a was just installed. table MATLAB Answers — New Questions
Real-Time Interface between App in AppDesigner and Simulink using parsim
I would like to optimize my progress bar in my Matlab app, which I am building in AppDesigner. I am currently using the app to start my Simulink model with parsim and simulate several simulation runs. However, I do not get any feedback on the progress of the individual simulations. I got the Listener option as a tip. I have implemented this. The specially created updategui.m file works. My question is, how can I combine parsim and the call of the updategui.m file? As soon as the parsim command is executed, I can no longer execute anything else. However, according to the instructions, I have to execute the updategui.m file as soon as the simulation is running. Otherwise exec_event_listener does not work.
Thank you.I would like to optimize my progress bar in my Matlab app, which I am building in AppDesigner. I am currently using the app to start my Simulink model with parsim and simulate several simulation runs. However, I do not get any feedback on the progress of the individual simulations. I got the Listener option as a tip. I have implemented this. The specially created updategui.m file works. My question is, how can I combine parsim and the call of the updategui.m file? As soon as the parsim command is executed, I can no longer execute anything else. However, according to the instructions, I have to execute the updategui.m file as soon as the simulation is running. Otherwise exec_event_listener does not work.
Thank you. I would like to optimize my progress bar in my Matlab app, which I am building in AppDesigner. I am currently using the app to start my Simulink model with parsim and simulate several simulation runs. However, I do not get any feedback on the progress of the individual simulations. I got the Listener option as a tip. I have implemented this. The specially created updategui.m file works. My question is, how can I combine parsim and the call of the updategui.m file? As soon as the parsim command is executed, I can no longer execute anything else. However, according to the instructions, I have to execute the updategui.m file as soon as the simulation is running. Otherwise exec_event_listener does not work.
Thank you. parsim, exec_event_listener, appdesigner, simulink MATLAB Answers — New Questions
matrix auto creation problem
If I want to make a matrix that inserts M as the order and it directly create a matrix with numbers from 1-M*M in that matrix. How should I like complete it
m=input(‘insert the degree of matrix’)
for i=1:m
for j=1:m
a(i,j)=
endfor
endforIf I want to make a matrix that inserts M as the order and it directly create a matrix with numbers from 1-M*M in that matrix. How should I like complete it
m=input(‘insert the degree of matrix’)
for i=1:m
for j=1:m
a(i,j)=
endfor
endfor If I want to make a matrix that inserts M as the order and it directly create a matrix with numbers from 1-M*M in that matrix. How should I like complete it
m=input(‘insert the degree of matrix’)
for i=1:m
for j=1:m
a(i,j)=
endfor
endfor matrix, matrix manipulation, matrix array MATLAB Answers — New Questions