Category: Matlab
Category Archives: Matlab
My datetimes do not give the right logical values
EventStartTimeEditField = "2023-07-20 09:00:02.798410112"
Event_start_time = datetime(EventStartTimeEditField,’InputFormat’,’yyyy-MM-dd HH:mm:ss.SSSSSSSSS’,’Format’,’yyyy-MM-dd HH:mm:ss.SSSSSSSSS’,’TimeZone’,’America/Halifax’)
find(acc_data.Time == Event_start_time)
The value of index 1793 of acc_data.Time is the following datetime: 2023-07-20 09:00:02.798410112
Despite these two values being identical, making a logical returns the wrong value for this index and the find function can not find the index at which the values are equal.
Does anyone have any ideas why this is and how to fix it?EventStartTimeEditField = "2023-07-20 09:00:02.798410112"
Event_start_time = datetime(EventStartTimeEditField,’InputFormat’,’yyyy-MM-dd HH:mm:ss.SSSSSSSSS’,’Format’,’yyyy-MM-dd HH:mm:ss.SSSSSSSSS’,’TimeZone’,’America/Halifax’)
find(acc_data.Time == Event_start_time)
The value of index 1793 of acc_data.Time is the following datetime: 2023-07-20 09:00:02.798410112
Despite these two values being identical, making a logical returns the wrong value for this index and the find function can not find the index at which the values are equal.
Does anyone have any ideas why this is and how to fix it? EventStartTimeEditField = "2023-07-20 09:00:02.798410112"
Event_start_time = datetime(EventStartTimeEditField,’InputFormat’,’yyyy-MM-dd HH:mm:ss.SSSSSSSSS’,’Format’,’yyyy-MM-dd HH:mm:ss.SSSSSSSSS’,’TimeZone’,’America/Halifax’)
find(acc_data.Time == Event_start_time)
The value of index 1793 of acc_data.Time is the following datetime: 2023-07-20 09:00:02.798410112
Despite these two values being identical, making a logical returns the wrong value for this index and the find function can not find the index at which the values are equal.
Does anyone have any ideas why this is and how to fix it? logical, datetime, find MATLAB Answers — New Questions
Bicubic Interpolation Algorithm of imrotate
Hello,
does anyone know the exact code for the bicubic interpolation algorithm used in imrotate()? I am currently rewriting a matlab script containing this function into a cuda mex file. My current implementation produces small differences between the matlab rotated images and the images I rotate. Is it the algorithm mentioned in this paper?
Thanks for your helpHello,
does anyone know the exact code for the bicubic interpolation algorithm used in imrotate()? I am currently rewriting a matlab script containing this function into a cuda mex file. My current implementation produces small differences between the matlab rotated images and the images I rotate. Is it the algorithm mentioned in this paper?
Thanks for your help Hello,
does anyone know the exact code for the bicubic interpolation algorithm used in imrotate()? I am currently rewriting a matlab script containing this function into a cuda mex file. My current implementation produces small differences between the matlab rotated images and the images I rotate. Is it the algorithm mentioned in this paper?
Thanks for your help bicubic interpolation, mex, cuda, imrotate, rotation algorithm MATLAB Answers — New Questions
Uniformly distributed random integers
The randi function in matlab generates uniformly distributed pseudo-random integers. If I want to generate uniformly distributed random values in the range of {0,0.05} and a step size of 0.01, how can I do it?The randi function in matlab generates uniformly distributed pseudo-random integers. If I want to generate uniformly distributed random values in the range of {0,0.05} and a step size of 0.01, how can I do it? The randi function in matlab generates uniformly distributed pseudo-random integers. If I want to generate uniformly distributed random values in the range of {0,0.05} and a step size of 0.01, how can I do it? rand MATLAB Answers — New Questions
how to obtain pathgains of winner2 channel
the channel is generated by the following code
BSAA = winner2.AntennaArray(‘UCA’, 1, 0.02); % UCA-8 array for BS
MSAA1 = winner2.AntennaArray(‘ULA’, 1, 0.01); % ULA-2 array for MS
MSIdx = [2];
BSIdx = {1};
numLinks = 2;
rndSeed = 5;
cfgLayout = winner2.layoutparset(MSIdx,BSIdx, numLinks,[BSAA,MSAA1],[],rndSeed);
cfgLayout.Pairing = [1 ; 2 ]; % Index in cfgLayout.Stations
cfgLayout.ScenarioVector = [6];
numBSSect = sum(cfgLayout.NofSect);
numMS = length(MSIdx);
cfgLayout.Stations(2).Velocity=[1.6;0;0];
cfgLayout.Stations(1).Pos(1:2) = [50, 150];
cfgLayout.Stations(2).Pos(1:2) = [10, 180]; % 8 meters away from BS
BSPos = cell2mat({cfgLayout.Stations(1:numBSSect).Pos});
MSPos = cell2mat({cfgLayout.Stations(numBSSect+1:end).Pos});
frameLen = 64; % Number of samples to be generated
cfgWim = winner2.wimparset;
cfgWim.NumTimeSamples = 80;
cfgWim.IntraClusterDsUsed = ‘yes’;
cfgWim.CenterFrequency = 2.76e9;
cfgWim.UniformTimeSampling = ‘yes’;
cfgWim.ShadowingModelUsed = ‘yes’;
cfgWim.PathLossModelUsed = ‘no’;
cfgWim.UseManualPropCondition = ‘yes’;
cfgWim.RandomSeed = 31415927;
cfgWim.NormalizeChannelOutputs=’false’;
downWINNERChan = comm.WINNER2Channel(cfgWim,cfgLayout);
and the input data is
sourceData = randi([0 1],(80,1);
then the pathgains and output are obainted
[ChanOut, pathGains] = downWINNERChan(sourceData);
pathGains1=squeeze(cell2mat(pathGains));
pathGains1=sum(pathGains)’;
rx_data=cell2mat(ChanOut);
tx_data_estimate=rx_data./pathGains;
I wonder why tx_data_estimate is different from sourceData?the channel is generated by the following code
BSAA = winner2.AntennaArray(‘UCA’, 1, 0.02); % UCA-8 array for BS
MSAA1 = winner2.AntennaArray(‘ULA’, 1, 0.01); % ULA-2 array for MS
MSIdx = [2];
BSIdx = {1};
numLinks = 2;
rndSeed = 5;
cfgLayout = winner2.layoutparset(MSIdx,BSIdx, numLinks,[BSAA,MSAA1],[],rndSeed);
cfgLayout.Pairing = [1 ; 2 ]; % Index in cfgLayout.Stations
cfgLayout.ScenarioVector = [6];
numBSSect = sum(cfgLayout.NofSect);
numMS = length(MSIdx);
cfgLayout.Stations(2).Velocity=[1.6;0;0];
cfgLayout.Stations(1).Pos(1:2) = [50, 150];
cfgLayout.Stations(2).Pos(1:2) = [10, 180]; % 8 meters away from BS
BSPos = cell2mat({cfgLayout.Stations(1:numBSSect).Pos});
MSPos = cell2mat({cfgLayout.Stations(numBSSect+1:end).Pos});
frameLen = 64; % Number of samples to be generated
cfgWim = winner2.wimparset;
cfgWim.NumTimeSamples = 80;
cfgWim.IntraClusterDsUsed = ‘yes’;
cfgWim.CenterFrequency = 2.76e9;
cfgWim.UniformTimeSampling = ‘yes’;
cfgWim.ShadowingModelUsed = ‘yes’;
cfgWim.PathLossModelUsed = ‘no’;
cfgWim.UseManualPropCondition = ‘yes’;
cfgWim.RandomSeed = 31415927;
cfgWim.NormalizeChannelOutputs=’false’;
downWINNERChan = comm.WINNER2Channel(cfgWim,cfgLayout);
and the input data is
sourceData = randi([0 1],(80,1);
then the pathgains and output are obainted
[ChanOut, pathGains] = downWINNERChan(sourceData);
pathGains1=squeeze(cell2mat(pathGains));
pathGains1=sum(pathGains)’;
rx_data=cell2mat(ChanOut);
tx_data_estimate=rx_data./pathGains;
I wonder why tx_data_estimate is different from sourceData? the channel is generated by the following code
BSAA = winner2.AntennaArray(‘UCA’, 1, 0.02); % UCA-8 array for BS
MSAA1 = winner2.AntennaArray(‘ULA’, 1, 0.01); % ULA-2 array for MS
MSIdx = [2];
BSIdx = {1};
numLinks = 2;
rndSeed = 5;
cfgLayout = winner2.layoutparset(MSIdx,BSIdx, numLinks,[BSAA,MSAA1],[],rndSeed);
cfgLayout.Pairing = [1 ; 2 ]; % Index in cfgLayout.Stations
cfgLayout.ScenarioVector = [6];
numBSSect = sum(cfgLayout.NofSect);
numMS = length(MSIdx);
cfgLayout.Stations(2).Velocity=[1.6;0;0];
cfgLayout.Stations(1).Pos(1:2) = [50, 150];
cfgLayout.Stations(2).Pos(1:2) = [10, 180]; % 8 meters away from BS
BSPos = cell2mat({cfgLayout.Stations(1:numBSSect).Pos});
MSPos = cell2mat({cfgLayout.Stations(numBSSect+1:end).Pos});
frameLen = 64; % Number of samples to be generated
cfgWim = winner2.wimparset;
cfgWim.NumTimeSamples = 80;
cfgWim.IntraClusterDsUsed = ‘yes’;
cfgWim.CenterFrequency = 2.76e9;
cfgWim.UniformTimeSampling = ‘yes’;
cfgWim.ShadowingModelUsed = ‘yes’;
cfgWim.PathLossModelUsed = ‘no’;
cfgWim.UseManualPropCondition = ‘yes’;
cfgWim.RandomSeed = 31415927;
cfgWim.NormalizeChannelOutputs=’false’;
downWINNERChan = comm.WINNER2Channel(cfgWim,cfgLayout);
and the input data is
sourceData = randi([0 1],(80,1);
then the pathgains and output are obainted
[ChanOut, pathGains] = downWINNERChan(sourceData);
pathGains1=squeeze(cell2mat(pathGains));
pathGains1=sum(pathGains)’;
rx_data=cell2mat(ChanOut);
tx_data_estimate=rx_data./pathGains;
I wonder why tx_data_estimate is different from sourceData? winner2channel, equalization MATLAB Answers — New Questions
How to convert class cell to vector?
wavelet = ‘db4’;
level = 6;
tt=0:(0.25*10^(-3)):(0.25*10^(-3))*ceil(N);
ref=cos(2*pi*50*tt);
[CR, LR] = wavedec(CurrentwindowR, level, wavelet);
[CY, LY] = wavedec(CurrentwindowY, level, wavelet);
[CB, LB] = wavedec(CurrentwindowB, level, wavelet);
[CRvolt, LRvolt] = wavedec(VoltagewindowR, level, wavelet);
[CYvolt, LYvolt] = wavedec(VoltagewindowY, level, wavelet);
[CBvolt, LBvolt] = wavedec(VoltagewindowB, level, wavelet);
[Cref, Lref] = wavedec(ref, level, wavelet);
coder.extrinsic(‘str2double’)
AppR=str2double(detcoef(CR,LR,level));
AppY=str2double(detcoef(CY,LY,level));
AppB=str2double(detcoef(CB,LB,level));
AppvoltR=str2double(detcoef(CRvolt,LRvolt,level));
AppvoltY=str2double(detcoef(CYvolt,LYvolt,level));
AppvoltB=str2double(detcoef(CBvolt,LBvolt,level));
Appref=str2double(detcoef(Cref,Lref,level));
thetaR= acosd((dot(Appref,AppR))/(norm(Appref)*norm(AppR)));
thetaY= acosd((dot(Appref,AppY))/(norm(Appref)*norm(AppY)));
thetaB= acosd((dot(Appref,AppB))/(norm(Appref)*norm(AppB)));
refR=cos(2*pi*50*tt+thetaR*pi/180);
refY=cos(2*pi*50*tt+thetaY*pi/180);
refB=cos(2*pi*50*tt+thetaB*pi/180);wavelet = ‘db4’;
level = 6;
tt=0:(0.25*10^(-3)):(0.25*10^(-3))*ceil(N);
ref=cos(2*pi*50*tt);
[CR, LR] = wavedec(CurrentwindowR, level, wavelet);
[CY, LY] = wavedec(CurrentwindowY, level, wavelet);
[CB, LB] = wavedec(CurrentwindowB, level, wavelet);
[CRvolt, LRvolt] = wavedec(VoltagewindowR, level, wavelet);
[CYvolt, LYvolt] = wavedec(VoltagewindowY, level, wavelet);
[CBvolt, LBvolt] = wavedec(VoltagewindowB, level, wavelet);
[Cref, Lref] = wavedec(ref, level, wavelet);
coder.extrinsic(‘str2double’)
AppR=str2double(detcoef(CR,LR,level));
AppY=str2double(detcoef(CY,LY,level));
AppB=str2double(detcoef(CB,LB,level));
AppvoltR=str2double(detcoef(CRvolt,LRvolt,level));
AppvoltY=str2double(detcoef(CYvolt,LYvolt,level));
AppvoltB=str2double(detcoef(CBvolt,LBvolt,level));
Appref=str2double(detcoef(Cref,Lref,level));
thetaR= acosd((dot(Appref,AppR))/(norm(Appref)*norm(AppR)));
thetaY= acosd((dot(Appref,AppY))/(norm(Appref)*norm(AppY)));
thetaB= acosd((dot(Appref,AppB))/(norm(Appref)*norm(AppB)));
refR=cos(2*pi*50*tt+thetaR*pi/180);
refY=cos(2*pi*50*tt+thetaY*pi/180);
refB=cos(2*pi*50*tt+thetaB*pi/180); wavelet = ‘db4’;
level = 6;
tt=0:(0.25*10^(-3)):(0.25*10^(-3))*ceil(N);
ref=cos(2*pi*50*tt);
[CR, LR] = wavedec(CurrentwindowR, level, wavelet);
[CY, LY] = wavedec(CurrentwindowY, level, wavelet);
[CB, LB] = wavedec(CurrentwindowB, level, wavelet);
[CRvolt, LRvolt] = wavedec(VoltagewindowR, level, wavelet);
[CYvolt, LYvolt] = wavedec(VoltagewindowY, level, wavelet);
[CBvolt, LBvolt] = wavedec(VoltagewindowB, level, wavelet);
[Cref, Lref] = wavedec(ref, level, wavelet);
coder.extrinsic(‘str2double’)
AppR=str2double(detcoef(CR,LR,level));
AppY=str2double(detcoef(CY,LY,level));
AppB=str2double(detcoef(CB,LB,level));
AppvoltR=str2double(detcoef(CRvolt,LRvolt,level));
AppvoltY=str2double(detcoef(CYvolt,LYvolt,level));
AppvoltB=str2double(detcoef(CBvolt,LBvolt,level));
Appref=str2double(detcoef(Cref,Lref,level));
thetaR= acosd((dot(Appref,AppR))/(norm(Appref)*norm(AppR)));
thetaY= acosd((dot(Appref,AppY))/(norm(Appref)*norm(AppY)));
thetaB= acosd((dot(Appref,AppB))/(norm(Appref)*norm(AppB)));
refR=cos(2*pi*50*tt+thetaR*pi/180);
refY=cos(2*pi*50*tt+thetaY*pi/180);
refB=cos(2*pi*50*tt+thetaB*pi/180); discrete wavelet, detcoef, cell to vector MATLAB Answers — New Questions
Map plot overlaying frame
Hi,
I am plotting a map, but the plot overlays the frame:
<</matlabcentral/answers/uploaded_files/95537/frame_issue.jpg>>
I have tried setting the ‘Layer’ property to both ‘top’ and ‘bottom’, but it does nothing. Any other ideas? I guess alternatively I could move the position of the plot within the frame to be more central, but I don’t know how to do this.
The code I am using to set up my map is:
fob = figure;
%mollweid eqacylin behrmann robinson
h=axesm(‘MapProjection’,’behrmann’,’MapLatLimit’,latlim,’MapLonLimit’,lonlim,’Frame’,’on’,’FLineWidth’,6,’Grid’,’off’,’MLineLocation’,2,’meridianlabel’,’on’,’PLineLocation’,2,’parallellabel’,’on’,’fontsize’,26);
set(gcf,’PaperOrientation’,’portrait’,’Color’,’w’,’Position’,get(0,’Screensize’),’PaperPositionMode’,’auto’,’Renderer’,’painters’)
set(gca,’box’,’off’,’Visible’,’off’,’Layer’,’top’);
Any advice would be gratefully received.
SallyHi,
I am plotting a map, but the plot overlays the frame:
<</matlabcentral/answers/uploaded_files/95537/frame_issue.jpg>>
I have tried setting the ‘Layer’ property to both ‘top’ and ‘bottom’, but it does nothing. Any other ideas? I guess alternatively I could move the position of the plot within the frame to be more central, but I don’t know how to do this.
The code I am using to set up my map is:
fob = figure;
%mollweid eqacylin behrmann robinson
h=axesm(‘MapProjection’,’behrmann’,’MapLatLimit’,latlim,’MapLonLimit’,lonlim,’Frame’,’on’,’FLineWidth’,6,’Grid’,’off’,’MLineLocation’,2,’meridianlabel’,’on’,’PLineLocation’,2,’parallellabel’,’on’,’fontsize’,26);
set(gcf,’PaperOrientation’,’portrait’,’Color’,’w’,’Position’,get(0,’Screensize’),’PaperPositionMode’,’auto’,’Renderer’,’painters’)
set(gca,’box’,’off’,’Visible’,’off’,’Layer’,’top’);
Any advice would be gratefully received.
Sally Hi,
I am plotting a map, but the plot overlays the frame:
<</matlabcentral/answers/uploaded_files/95537/frame_issue.jpg>>
I have tried setting the ‘Layer’ property to both ‘top’ and ‘bottom’, but it does nothing. Any other ideas? I guess alternatively I could move the position of the plot within the frame to be more central, but I don’t know how to do this.
The code I am using to set up my map is:
fob = figure;
%mollweid eqacylin behrmann robinson
h=axesm(‘MapProjection’,’behrmann’,’MapLatLimit’,latlim,’MapLonLimit’,lonlim,’Frame’,’on’,’FLineWidth’,6,’Grid’,’off’,’MLineLocation’,2,’meridianlabel’,’on’,’PLineLocation’,2,’parallellabel’,’on’,’fontsize’,26);
set(gcf,’PaperOrientation’,’portrait’,’Color’,’w’,’Position’,get(0,’Screensize’),’PaperPositionMode’,’auto’,’Renderer’,’painters’)
set(gca,’box’,’off’,’Visible’,’off’,’Layer’,’top’);
Any advice would be gratefully received.
Sally mapping toolbox, frame, plotting MATLAB Answers — New Questions
Matlab code to delete contents of a subfolders
I have multiple project folder and under each project folder I have a "Inputs" folder. I need to delete contents of the "Inputs" folder only by from all project folder,retaining the empty folder as is. Please can someone help me with the code.I have multiple project folder and under each project folder I have a "Inputs" folder. I need to delete contents of the "Inputs" folder only by from all project folder,retaining the empty folder as is. Please can someone help me with the code. I have multiple project folder and under each project folder I have a "Inputs" folder. I need to delete contents of the "Inputs" folder only by from all project folder,retaining the empty folder as is. Please can someone help me with the code. optimization MATLAB Answers — New Questions
I want to measure the size of each bubble in the image and average it at the end
I want to measure the size of each bubble in the image and average it at the end
It’s too hard. Help me.I want to measure the size of each bubble in the image and average it at the end
It’s too hard. Help me. I want to measure the size of each bubble in the image and average it at the end
It’s too hard. Help me. #length #width #bubble MATLAB Answers — New Questions
Adjusting Convex Hull Area
<</matlabcentral/answers/uploaded_files/1708331/image.png>>
I’m trying to use convhull to calculate the area of a shape and compare that to the number of pixels of said shape. Hypothetically, the convex hull should have a greater area but that doesn’t seem to be the case. Is there some way to adjust how convhull determines area?<</matlabcentral/answers/uploaded_files/1708331/image.png>>
I’m trying to use convhull to calculate the area of a shape and compare that to the number of pixels of said shape. Hypothetically, the convex hull should have a greater area but that doesn’t seem to be the case. Is there some way to adjust how convhull determines area? <</matlabcentral/answers/uploaded_files/1708331/image.png>>
I’m trying to use convhull to calculate the area of a shape and compare that to the number of pixels of said shape. Hypothetically, the convex hull should have a greater area but that doesn’t seem to be the case. Is there some way to adjust how convhull determines area? matlab MATLAB Answers — New Questions
Webwrite with .mlappinstall-file for artifactory-deployment
We want to deploy updates for our appdesigner-apps (.exe as well as .mlappinstall) on our artifactory.
At the moment this is done manually. However, my goal is a matlab-script that
compiles the app
uploads it to its destination-folder on the artifactory.
My URL and login-informations are correct, I am able to deploy simple data (tested with a simple struct containing doubles and strings).
My question is, how to convert or pack an .mlappinstall for it to be sendable by webwrite.
I have found this FileExchange-solution for uploading to Dropbox via webwrite.
There they seem to encode an arbitrary file as char-array to put into webwrite. This naive approach doesn’t work (it returns an empty char-array).
fid = fopen(‘myApp.mlappinstall’, ‘r’);
data = char(fread(fid)’);
Also, even if that would work, I would probably have difficulties to discern the correct MediaType and/or CharacterEncoding for the encoded .mlappinstall.
I would really appreciate suggestions for a proper workflow to do, what we want to achieve: compilation and artifactory-deployment of app-designer apps.
Also any help with encoding and sending apps or exe-files with webwrite would help us a lot.
Thank you.We want to deploy updates for our appdesigner-apps (.exe as well as .mlappinstall) on our artifactory.
At the moment this is done manually. However, my goal is a matlab-script that
compiles the app
uploads it to its destination-folder on the artifactory.
My URL and login-informations are correct, I am able to deploy simple data (tested with a simple struct containing doubles and strings).
My question is, how to convert or pack an .mlappinstall for it to be sendable by webwrite.
I have found this FileExchange-solution for uploading to Dropbox via webwrite.
There they seem to encode an arbitrary file as char-array to put into webwrite. This naive approach doesn’t work (it returns an empty char-array).
fid = fopen(‘myApp.mlappinstall’, ‘r’);
data = char(fread(fid)’);
Also, even if that would work, I would probably have difficulties to discern the correct MediaType and/or CharacterEncoding for the encoded .mlappinstall.
I would really appreciate suggestions for a proper workflow to do, what we want to achieve: compilation and artifactory-deployment of app-designer apps.
Also any help with encoding and sending apps or exe-files with webwrite would help us a lot.
Thank you. We want to deploy updates for our appdesigner-apps (.exe as well as .mlappinstall) on our artifactory.
At the moment this is done manually. However, my goal is a matlab-script that
compiles the app
uploads it to its destination-folder on the artifactory.
My URL and login-informations are correct, I am able to deploy simple data (tested with a simple struct containing doubles and strings).
My question is, how to convert or pack an .mlappinstall for it to be sendable by webwrite.
I have found this FileExchange-solution for uploading to Dropbox via webwrite.
There they seem to encode an arbitrary file as char-array to put into webwrite. This naive approach doesn’t work (it returns an empty char-array).
fid = fopen(‘myApp.mlappinstall’, ‘r’);
data = char(fread(fid)’);
Also, even if that would work, I would probably have difficulties to discern the correct MediaType and/or CharacterEncoding for the encoded .mlappinstall.
I would really appreciate suggestions for a proper workflow to do, what we want to achieve: compilation and artifactory-deployment of app-designer apps.
Also any help with encoding and sending apps or exe-files with webwrite would help us a lot.
Thank you. artifactory webwrite appdesigner mlappinstall MATLAB Answers — New Questions
How to fit polygon to irregular set of points with only vertical and horizontal edges?
Hi everyone,
I’ve been battling with this for a few days now, so hoping for some help on here. I have a set of points (actually quite a few sets, over 11k) that form a boundary around an area of interest. I’m trying to calculate the average value of pixels within each boundary. My issue is that the set of points is not ordered cw or ccw – it’s basically random. They are also not concave, and so I can’t use (or I can’t figure out) the polygon functions (polyshape, boundary, alphaShape, convhull, etc) as they do not draw the boundaries correctly, and hence can’t use inpolygon or poly2mask functions.
At the moment, the best I can get is by calculating the angle of each point from the centroid and then putting them in order following THIS answer, however this does not work for certain parts of the areas of interest – see the figures below. The markers represent the set of points, and the blue/orange is the best polygon I’ve been able to draw so far for each. The top right corner shows in a red line what the boundary should be.
Any ideas or suggestions for me to look at?
Thanks in advance!Hi everyone,
I’ve been battling with this for a few days now, so hoping for some help on here. I have a set of points (actually quite a few sets, over 11k) that form a boundary around an area of interest. I’m trying to calculate the average value of pixels within each boundary. My issue is that the set of points is not ordered cw or ccw – it’s basically random. They are also not concave, and so I can’t use (or I can’t figure out) the polygon functions (polyshape, boundary, alphaShape, convhull, etc) as they do not draw the boundaries correctly, and hence can’t use inpolygon or poly2mask functions.
At the moment, the best I can get is by calculating the angle of each point from the centroid and then putting them in order following THIS answer, however this does not work for certain parts of the areas of interest – see the figures below. The markers represent the set of points, and the blue/orange is the best polygon I’ve been able to draw so far for each. The top right corner shows in a red line what the boundary should be.
Any ideas or suggestions for me to look at?
Thanks in advance! Hi everyone,
I’ve been battling with this for a few days now, so hoping for some help on here. I have a set of points (actually quite a few sets, over 11k) that form a boundary around an area of interest. I’m trying to calculate the average value of pixels within each boundary. My issue is that the set of points is not ordered cw or ccw – it’s basically random. They are also not concave, and so I can’t use (or I can’t figure out) the polygon functions (polyshape, boundary, alphaShape, convhull, etc) as they do not draw the boundaries correctly, and hence can’t use inpolygon or poly2mask functions.
At the moment, the best I can get is by calculating the angle of each point from the centroid and then putting them in order following THIS answer, however this does not work for certain parts of the areas of interest – see the figures below. The markers represent the set of points, and the blue/orange is the best polygon I’ve been able to draw so far for each. The top right corner shows in a red line what the boundary should be.
Any ideas or suggestions for me to look at?
Thanks in advance! polygon, boundary, convhull, points MATLAB Answers — New Questions
Gaussian quadrature for arbitrary weight functions
Dear all,
there are several Matlab codes available to compute an integral of the form
with Gaussian quadrature, where is a "standard" weight function, e.g. .
I’m looking for a Gaussian quadrature that works for arbitrary weight functions. For instance, a code of the form
[Quadrature_weights,Quadrature_nodes] = CODE(weight_function)
that returns Gaussian quadrature weights and nodes for a given, but arbitrary weight function.
Thanks, StephanDear all,
there are several Matlab codes available to compute an integral of the form
with Gaussian quadrature, where is a "standard" weight function, e.g. .
I’m looking for a Gaussian quadrature that works for arbitrary weight functions. For instance, a code of the form
[Quadrature_weights,Quadrature_nodes] = CODE(weight_function)
that returns Gaussian quadrature weights and nodes for a given, but arbitrary weight function.
Thanks, Stephan Dear all,
there are several Matlab codes available to compute an integral of the form
with Gaussian quadrature, where is a "standard" weight function, e.g. .
I’m looking for a Gaussian quadrature that works for arbitrary weight functions. For instance, a code of the form
[Quadrature_weights,Quadrature_nodes] = CODE(weight_function)
that returns Gaussian quadrature weights and nodes for a given, but arbitrary weight function.
Thanks, Stephan integration, gaussian quadrature MATLAB Answers — New Questions
find the inflection point of a curve 3D (set of nodes) in matlab
How can I determine the inflection point of a set of nodes generating a curve in 3D space?
load curve_1.m
curve_x = curve_1;
figure
plot3(curve_x(:,1),curve_x(:,2),curve_x(:,3),’k.’,’Markersize’,10)
hold on
plot3(curve_x(:,1),curve_x(:,2),curve_x(:,3),’-r’,’LineWidth’,2)
hold off
grid off
axis equal
Before determining the inflection points, is it possible to make the curve ‘curve_x’ smoother (more like a curve) since the nodes are not placed at a certain distance from each other?How can I determine the inflection point of a set of nodes generating a curve in 3D space?
load curve_1.m
curve_x = curve_1;
figure
plot3(curve_x(:,1),curve_x(:,2),curve_x(:,3),’k.’,’Markersize’,10)
hold on
plot3(curve_x(:,1),curve_x(:,2),curve_x(:,3),’-r’,’LineWidth’,2)
hold off
grid off
axis equal
Before determining the inflection points, is it possible to make the curve ‘curve_x’ smoother (more like a curve) since the nodes are not placed at a certain distance from each other? How can I determine the inflection point of a set of nodes generating a curve in 3D space?
load curve_1.m
curve_x = curve_1;
figure
plot3(curve_x(:,1),curve_x(:,2),curve_x(:,3),’k.’,’Markersize’,10)
hold on
plot3(curve_x(:,1),curve_x(:,2),curve_x(:,3),’-r’,’LineWidth’,2)
hold off
grid off
axis equal
Before determining the inflection points, is it possible to make the curve ‘curve_x’ smoother (more like a curve) since the nodes are not placed at a certain distance from each other? inflection, nodes, points, curve fitting, curve, 3d MATLAB Answers — New Questions
Weibull does not seem to work gives error”Error using makedist Distribution name ‘Weibull’ is unrecognized.”
c = 8.1; % Scale factor
k = 2.03; % Shape factor
N = 1000; % Number of plot data points
pd = makedist(‘Weibull’,’a’,c,’b’,k) %Selection of Weibull
x = linspace(0,25,N);
y = pdf(pd,x); % Weibull output function
cd = 1 – exp(-(x/c).^k); % Cumulative distribution
yyaxis left
plot(x,100*y, ‘k’,’LineWidth’,2)
title({[‘Weibull and Cumulative Probability Distributions’], …
[‘k = ‘, num2str(k), ‘ and c = ‘, num2str(c)]});
xlabel(‘Wind Velocity (m/s)’);
ylabel(‘Probability (%)’, ‘Color’,’k’);
hold on
yyaxis right
plot(x,100*cd, ‘r’,’LineWidth’,2)
ylabel(‘Probability (%)’);
legend(‘Weibull’, ‘Cumulative’)
axis([0 25 0 120]);
grid on
grid minor
It gives the following error:
Error using makedist
Distribution name ‘Weibull’ is unrecognized.c = 8.1; % Scale factor
k = 2.03; % Shape factor
N = 1000; % Number of plot data points
pd = makedist(‘Weibull’,’a’,c,’b’,k) %Selection of Weibull
x = linspace(0,25,N);
y = pdf(pd,x); % Weibull output function
cd = 1 – exp(-(x/c).^k); % Cumulative distribution
yyaxis left
plot(x,100*y, ‘k’,’LineWidth’,2)
title({[‘Weibull and Cumulative Probability Distributions’], …
[‘k = ‘, num2str(k), ‘ and c = ‘, num2str(c)]});
xlabel(‘Wind Velocity (m/s)’);
ylabel(‘Probability (%)’, ‘Color’,’k’);
hold on
yyaxis right
plot(x,100*cd, ‘r’,’LineWidth’,2)
ylabel(‘Probability (%)’);
legend(‘Weibull’, ‘Cumulative’)
axis([0 25 0 120]);
grid on
grid minor
It gives the following error:
Error using makedist
Distribution name ‘Weibull’ is unrecognized. c = 8.1; % Scale factor
k = 2.03; % Shape factor
N = 1000; % Number of plot data points
pd = makedist(‘Weibull’,’a’,c,’b’,k) %Selection of Weibull
x = linspace(0,25,N);
y = pdf(pd,x); % Weibull output function
cd = 1 – exp(-(x/c).^k); % Cumulative distribution
yyaxis left
plot(x,100*y, ‘k’,’LineWidth’,2)
title({[‘Weibull and Cumulative Probability Distributions’], …
[‘k = ‘, num2str(k), ‘ and c = ‘, num2str(c)]});
xlabel(‘Wind Velocity (m/s)’);
ylabel(‘Probability (%)’, ‘Color’,’k’);
hold on
yyaxis right
plot(x,100*cd, ‘r’,’LineWidth’,2)
ylabel(‘Probability (%)’);
legend(‘Weibull’, ‘Cumulative’)
axis([0 25 0 120]);
grid on
grid minor
It gives the following error:
Error using makedist
Distribution name ‘Weibull’ is unrecognized. matlab MATLAB Answers — New Questions
How to insert dash-line in a matlab figure?
How can i add such horizontal dash-line in a matlab figure?How can i add such horizontal dash-line in a matlab figure? How can i add such horizontal dash-line in a matlab figure? matlab figure, matlab MATLAB Answers — New Questions
Calculate Mean of vector in more decimals
I want to calculate the mean of a vector in more than 4 decimals. The code
A = [0,1,9];
mean(A)
gives
ans = 3.3333
But I want 3.333333I want to calculate the mean of a vector in more than 4 decimals. The code
A = [0,1,9];
mean(A)
gives
ans = 3.3333
But I want 3.333333 I want to calculate the mean of a vector in more than 4 decimals. The code
A = [0,1,9];
mean(A)
gives
ans = 3.3333
But I want 3.333333 mean MATLAB Answers — New Questions
How to plot isosurfaces using 3 vector columns of data?
I have 4 columns. The first three are the x,y, and z coordinates while the last one is the iso level. How can I plot them in Matlab?. thanksI have 4 columns. The first three are the x,y, and z coordinates while the last one is the iso level. How can I plot them in Matlab?. thanks I have 4 columns. The first three are the x,y, and z coordinates while the last one is the iso level. How can I plot them in Matlab?. thanks isosurfaces isolevels MATLAB Answers — New Questions
How to using multi output in Neural network fitting app?
hi,
I want to develop a prediction model using Neural Network Fitting App in Matlab 2024a version.
I want to use two output data (A and B), but this app only produces one output.
Can’t I use more than 2 outputs?hi,
I want to develop a prediction model using Neural Network Fitting App in Matlab 2024a version.
I want to use two output data (A and B), but this app only produces one output.
Can’t I use more than 2 outputs? hi,
I want to develop a prediction model using Neural Network Fitting App in Matlab 2024a version.
I want to use two output data (A and B), but this app only produces one output.
Can’t I use more than 2 outputs? neural network fitting, artificial neural network MATLAB Answers — New Questions
Multivariate goodness-of-fit?
Does MatLab/MathWorks support procedure(s) to assess goodness-of-fit for simulation models producing outputs of multiple types?Does MatLab/MathWorks support procedure(s) to assess goodness-of-fit for simulation models producing outputs of multiple types? Does MatLab/MathWorks support procedure(s) to assess goodness-of-fit for simulation models producing outputs of multiple types? goodness of fit MATLAB Answers — New Questions
Chomp trajectories are in self collision
Hello,
I’ve been using the CHOMP algorithm for a while, but I’m encountering persistent self-collisions in some trajectories. Specifically, when simulating a UR5e robot, links 4 and 6 often collide during the trajectory. I verified these collisions using the checkCollision function.
I’ve tried adjusting these collision options, but the issue persists. For now I have not modified other solver/collision options.
chomp.CollisionOptions.IgnoreSelfCollision = false;
chomp.CollisionOptions.CollisionCostWeight = 10;
Any insights to avoid self collisions ? Because I think it should not be impossible for robot to not to follow that specific path where the link 6 touches the link 4 so I am kinda lost.Hello,
I’ve been using the CHOMP algorithm for a while, but I’m encountering persistent self-collisions in some trajectories. Specifically, when simulating a UR5e robot, links 4 and 6 often collide during the trajectory. I verified these collisions using the checkCollision function.
I’ve tried adjusting these collision options, but the issue persists. For now I have not modified other solver/collision options.
chomp.CollisionOptions.IgnoreSelfCollision = false;
chomp.CollisionOptions.CollisionCostWeight = 10;
Any insights to avoid self collisions ? Because I think it should not be impossible for robot to not to follow that specific path where the link 6 touches the link 4 so I am kinda lost. Hello,
I’ve been using the CHOMP algorithm for a while, but I’m encountering persistent self-collisions in some trajectories. Specifically, when simulating a UR5e robot, links 4 and 6 often collide during the trajectory. I verified these collisions using the checkCollision function.
I’ve tried adjusting these collision options, but the issue persists. For now I have not modified other solver/collision options.
chomp.CollisionOptions.IgnoreSelfCollision = false;
chomp.CollisionOptions.CollisionCostWeight = 10;
Any insights to avoid self collisions ? Because I think it should not be impossible for robot to not to follow that specific path where the link 6 touches the link 4 so I am kinda lost. matlab MATLAB Answers — New Questions