https://de.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2019-07-17T13:49:12Ztag:de.mathworks.com,2005:Question/4001802018-05-10T21:37:20Z2019-07-17T13:48:25Zextract features from raw vibration signals using sparse filteringI am trying to implement a way to use sparse filtering or another similiar algorithm to extract features *directly* from raw vibration signals.
I tried the algorithm:
sparsefilt
But the results were not great. Maybe because this algortihm doesnt like to take raw signals as input (but wants already features?)
Also I have to mention that I am aware of this method:
<https://de.mathworks.com/help/predmaint/examples/Rolling-Element-Bearing-Fault-Diagnosis.html>
But my task is to find a way to exract features more automatic.
Can somebody help me to find the right algorithm to extract features from raw vibration signals?
Best regards
Artem Bykanovhttps://de.mathworks.com/matlabcentral/profile/authors/4709985-artem-bykanovtag:de.mathworks.com,2005:Question/4721552019-07-17T12:39:02Z2019-07-17T13:49:12ZIntegrate a 2D griddedInterpolant wrt one variableHello,
I would like to know how to integrate a 2D griddedInterpolant with respect to one variable.
I include an example:
[x,y] = ndgrid(-5:0.8:5);
z = x.^2 + y.^2;
F = griddedInterpolant(x,y,z);
integral(@(x) F(x,1),0,1)
The actual interpolant is from data and not availbe in a closed analytical form.
This produces an error. Is there a simple alternative?Anna Thuenenhttps://de.mathworks.com/matlabcentral/profile/authors/10438842-anna-thuenentag:de.mathworks.com,2005:Question/4721642019-07-17T04:00:00Z2019-07-17T13:46:04ZWhy am I unable to install MATLAB R2015a - R2017a on Windows 10?Why am I unable to install MATLAB R2015a - R2017a on Windows 10?
MathWorks Support Teamhttps://de.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:de.mathworks.com,2005:Question/4721632019-07-17T13:45:17Z2019-07-17T13:45:17ZSave Excel cell range as image with activeXHi! I have a nice formatted table in excel and would like to save this table (meaning a cell range) as jpg file using activeX with Matlab. Is that possible?
I do already have the following code
exl = actxserver('excel.application');
exlWkbk = exl.Workbooks;
exlFile = exlWkbk.Open('myFile.xlsx');
exlSheet1 = exlFile.Sheets.Item('Sheet1');
dat_range = 'A1:F19';
rngObj = exlSheet1.Range(dat_range);
Now I would nee something like rngObj.export('myExport.jpg') but I couldn't find anything....Sven Schömerhttps://de.mathworks.com/matlabcentral/profile/authors/8432848-sven-schoemertag:de.mathworks.com,2005:Question/4721352019-07-17T10:58:35Z2019-07-17T13:41:56ZReal Time Data Store in Inf ArrayI have MPU6050 sensor. I had codes and I store in a 1x1 double array. But now I wanna filter it but I cant do it for real time. Because my filter needs at least 3 sample for filtering. And you know, in real time you need filter all datas 1 by 1.
After all I need to store my datas in zeros array. How can store real time "Acc_Mag" datas in "accmag = zeros (1,10000);" array?
Can Burak Kavuncuogluhttps://de.mathworks.com/matlabcentral/profile/authors/15749395-can-burak-kavuncuoglutag:de.mathworks.com,2005:Question/4721622019-07-17T13:39:00Z2019-07-17T13:39:00ZLocating points on the figure that correspond to a specific number on the colormapI've opened a .m figure that was generated earlier.
openfig('MapSurface.fig')
Next, I would like to know the xy position of the points on the figure that exactly match with 100 on the colorbar.
This could either be a pixel or list of pixels (as per their xy position) that correspond to 100, or, a marked region on the figure that highlights all points corresponding to 100.
Note: I'm doing this as my final aim is to calculate the area of the spot size by knowing the location of its boundaries. In other cases the spot size is bigger or an arbitary shape. I've taken the simplest case for this question.
Thank you.NNhttps://de.mathworks.com/matlabcentral/profile/authors/13114140-nntag:de.mathworks.com,2005:Question/4721392019-07-17T11:14:16Z2019-07-17T13:38:53Zimage plot after is calculating hilbert spectrumI have used th matlab function [hs,f,t,imfinsf,imfinse] = hht(imf,fs); to do hilbert haung transform.
The hilbert spectrum (hs) is a sparse matrix. How could this be plotted as an image plot? I tried to convert this to a double matrix using full(hs). But this doesn't give a hilbert spectrum. Its just blank. How to resolve this?Ramya Ramanhttps://de.mathworks.com/matlabcentral/profile/authors/12556865-ramya-ramantag:de.mathworks.com,2005:Question/4721202019-07-17T09:46:54Z2019-07-17T13:36:59Zsigma deletes the axis gridHi All,
my code is below
myFigure=figure; % create a figure
ax1 = subplot(231, 'Parent', myFigure,'UserData','my_stuff','nextplot', 'add','XGrid','on','YGrid','on'); % create axix and set grid on in x and y
sigma(ax1,mySystem); % plot
The 2nd line create an axis with grid on, but then with the 3rd line the grid disappears
I can reset the grid back on with a 4th line as
grid(ax1,'on')
however, I was wondering why "sigma" ignore my initial statement in subplot ('XGrid','on','YGrid','on')
Is there a setting in sigma/subplot that I can use?
Thanks
GGiuseppe Nasellihttps://de.mathworks.com/matlabcentral/profile/authors/3696496-giuseppe-nasellitag:de.mathworks.com,2005:Question/4508752019-03-19T05:24:31Z2019-07-17T13:36:34ZNot able to connect zynq7010 to MATLABHello, I'm using zybo z710 series zynq hardware for my project, and I'm trying to connect MATLAB 2018b to my zynq harware. My operating system is Windows 10.
I followed the first 10 steps exactly as given in the workflow below,
https://in.mathworks.com/help/hdlcoder/examples/define-and-register-custom-board-and-reference-design-for-zynq-workflow.html
When I tried running it, I'm getting the following error,
"Error using codertarget.zynq.internal.LinuxShell/setupZynqHardwarecodertarget.zynq.internal.LinuxShell/setupZynqHardware (line 543)
Cannot connect to "Zynq hardware". Details: Could not connect to the hardware over Serial Port.
Check that USB cable is plugged into 'USB-to-UART' port of the hardware and the power switch is turned on.
If this error persists, switch off the hardware, wait for 10 seconds, switch on the hardware and then repeat this step.
Error in codertarget.zynq.internal.LinuxShell (line 207)
obj.setupZynqHardware(username,password,remotedir);
Error in zynq (line 113)
h = codertarget.zynq.internal.LinuxShell('ZC702', varargin{:});"
Is there anyway to debug this?TARIQ ABDUL RAHMANhttps://de.mathworks.com/matlabcentral/profile/authors/14496900-tariq-abdul-rahmantag:de.mathworks.com,2005:Question/4719612019-07-16T14:05:18Z2019-07-17T13:36:08ZHaving Trouble Using For-Loop Over Distributed Range with ODE45Hi all,
So I'm trying to solve an ODE where the values for two of my inputs change over time.
For the first half of my tspan, delta1 should equal 1, and delta0 should equal 0. Then, in the second half, this gets reversed (i.e., delta1=0 and delta0=1). However, the way I've written my code, it only takes the second set of values. That is, it's solving the ODE as is delta1=0 and delta0=0 for the entire time - and I'm not sure why?
Here is my code:
% assign number of parameter sets and create parameters vector
n = 1000;
parameters = zeros(n,6);
% initialize parameters
for k=1:n
alpha0=rand;psa0=29.00;gamma=rand;psi=0.00;beta=rand;mse=0;
tspan=[0 2272];
parameters(k,:) = [alpha0,psa0,gamma,psi*gamma,beta,mse];
end
% solve ODE
for k = 1:size(parameters,1)
options=odeset('RelTol', 1e-8, 'AbsTol', 1e-8);
tspan=[0 2272];
for t=drange(0:1200)
delta1=1;delta0=0;
end
for t=drange(1201:2272)
delta1=0;delta0=1;
end
ODE = @(t,x,delta1,delta0,gamma,psi,beta) [delta1*-gamma*x(1) + delta0*psi*x(1); beta*x(2) - delta1* x(1)*x(2)];
sol = ode45(@(t,x) ODE(t,x,delta1,delta0,parameters(k,3),parameters(k,4),parameters(k,5)), tspan, [parameters(k,1) parameters(k,2)], options);
% calculate MSE and update parameters matrix
a = deval(sol,patientdata1(:,1));
a = a';
cost = (a(:,2)-patientdata1(:,2))./patientdata1(:,2);
mse = cost'*cost;
if min(a(:,2))<= 0.3
mse = mse * 100;
end
parameters(k,6) = mse;
end
Any help would be appreciated. Thanks in advance!Thomas Veithhttps://de.mathworks.com/matlabcentral/profile/authors/13550529-thomas-veithtag:de.mathworks.com,2005:Question/4701112019-07-03T16:30:31Z2019-07-17T13:34:36ZMATLAB Answers Wish-list #5 (and bug reports)This is the 5th installment of the wish-list and bug report thread.
This topic is the follow on to the first Wish-list for MATLAB Answer sections and second MATLAB Answers Wish-list #2 (and bug reports). The third started out as New design of the forum - grey on white and the fourth MATLAB Answers Wish-list #4 (and bug reports) is also growing so large it is slow to load and navigate.
Same idea as the previous ones: one wish (or bug report) per answer, so that people can vote their wishes.Rikhttps://de.mathworks.com/matlabcentral/profile/authors/3073010-riktag:de.mathworks.com,2005:Question/4697312019-07-01T16:29:07Z2019-07-17T13:32:43ZHow can I do graph matching?Hi,
I have image which has genes in it. These images are refreshed in every 5 minutes. In this 5 minutes the gene can grow/shrink, move & rotate. A new gene can also pop in the image. Is there any way to graph match between same genes after 5 minutes?
I can't do it becuase the gene changes it size and moves too.
Anyone suggesting function which I can use would be very helpful.
Rishi Kiran Shankarhttps://de.mathworks.com/matlabcentral/profile/authors/14489109-rishi-kiran-shankartag:de.mathworks.com,2005:Question/4721612019-07-17T13:16:06Z2019-07-17T13:31:26ZHow can I fix miscalculation of mean command?When I try to enter the command below , the mean of elements are not equal to 65
A=[64,64.5,65,65.5,66];
>> mean(A)
ans =
29.0706Emre Alamurhttps://de.mathworks.com/matlabcentral/profile/authors/15683204-emre-alamurtag:de.mathworks.com,2005:Question/4721092019-07-17T08:38:09Z2019-07-17T13:30:39ZDelete table from GUI app variableHi all,
I have a GUI designed in Matlab called app. In app there is a table table that a certain point I want to delete to save memory, how can I do it? clear app.table does not work
ThanksFederico Fhttps://de.mathworks.com/matlabcentral/profile/authors/14597349-federico-ftag:de.mathworks.com,2005:Question/4719282019-07-16T11:51:11Z2019-07-17T13:30:32ZRemoving unrecognised characters and superfluous data from a stringI have a set of data I have imported as a string, however when it is imported it fills in blank rows with arrow characters, as shown below:
NC(N)=N→59.0717→C→"5N3→-1.71840001642704→0.022000011056661606→75.89000129699707"→→→→→→→→→→→→"
"→→→→→→→→→→→→→"
"OC(=O)CCC(O)=O→118.08764→C4→"6O4→-0.6665999889373779→-0.4739999994635582→74.5999984741211"→→→→→→→→→→→→"
"→→→→→→→→→→→→→"
"CC(=O)NC1=CC=C(O)C=C1→151.16446→C8→"9NO2→1.0175999999046325→-1.6619999147951603→49.32999897003174"→→→→→→→→→→→→"
"→→→→→→→→→→→→→"
"NC(N)=N→59.0717→C→"5N3→-1.71840001642704→0.022000011056661606→75.89000129699707"→→→→→→→→→→→→"
"→→→→→→→→→→→→→"
I can't remove these by the method I would normally use below:
Data(Data == "→→→→→→→→→→→→→") = []
In the original file they appear to be blank lines, in between the actual lines of text.
Is there a way to remove these?Duncanhttps://de.mathworks.com/matlabcentral/profile/authors/15453015-duncantag:de.mathworks.com,2005:Question/3387502017-05-04T17:52:11Z2019-07-17T13:29:23ZImport a thousand of AscII files, combine them in one XYZ text file and export them again as one text file? HI,
I have a thousands of ASCII files which start with the name "CDR_19830101z.asc" and end with the name "CDR_20160101z.asc". I am trying to call them all in Matlab, and export them as one combined XYZ text or excel file.
These files are averages rainfall per day, of a specific area. The X and Y value are the same of all the files. The only value which changes is the Z value which consider the the average rainfall per day. So I am trying to build a graph between the time and rainfall of each square within this study area.
The file CDR_19830101z.asc format is:
ncols 6
nrows 4
xllcorner 41.500
yllcorner 35.500
cellsize 0.25
NODATA_value -99
0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00
The last file "CDR_20160101z.asc" format:
ncols 6
nrows 4
xllcorner 41.500
yllcorner 35.500
cellsize 0.25
NODATA_value -99
1.19 2.14 0.89 2.86 3.18 5.77
1.24 4.41 1.39 2.42 2.87 4.51
1.27 1.82 1.29 1.60 1.24 2.88
1.37 2.43 3.26 2.44 2.80 2.13
I appreciate your help and time.
Thanks,
Majid
...[cleaned up/formatted data--dpb. NB: Use the {}Code button to format such lines in future]...Majid Mohamodhttps://de.mathworks.com/matlabcentral/profile/authors/7160991-majid-mohamodtag:de.mathworks.com,2005:Question/4720722019-07-17T04:13:42Z2019-07-17T13:28:11ZPreserve precision when writing array to csv?Hi, I have a simple script that converts geographic data in polar cylindrical coordinates to decimal degrees. The output is a very large 3 columns by ~1.5 million rows array to 4 decimals precision. This inconvenient format is necessary because of the software (ArcMap) the output csv needs to be imported into.
First I tried this:
format long g
csvwrite(fileout,data);
fclose('all')
The result imports perfectly, but the longitude values (the first array column) are truncated to 2 decimal places.
Then I tried this, referencing the question here:
dlmwrite(fileout, data, 'delimiter', ',', 'precision', 7);
fclose('all')
The output looks perfect in both matlab and excel, but is missing the second column upon import into the other software. Because of the large number of rows, I can't edit or resave in excel to try to fix whatever this problem is.
Finally I tried simply
writematrix(data, fileout)
fclose('all')
but the lines run, proceeds to completion very quickly without error, and does not write a file.
I'm out of ideas. Am I missing an alternative here, or is there something in my dlmwrite line that might have caused problems?
Thanks!Jeff Leeburnhttps://de.mathworks.com/matlabcentral/profile/authors/14676274-jeff-leeburntag:de.mathworks.com,2005:Question/4702912019-07-04T16:45:42Z2019-07-17T13:27:41ZPlotting semilogy on two axes covering the same range, one side is log the other is not.I'm trying to make a figure with two vertical log axes, and the horizontal x axis still be linear. I need to compare plots who cover different ranges, so I made a new range that considers the floor(min()) of all values and the ceil(max()) of all values since in this case they're all negative. However, when I try to create both semi logy plots, the right axis still looks linear even though it covers the same range as the left axis which looks logarithmic. In other questions people have suggested that variables cannot be represented well on a logarithmic plot, but I don't think that is the case here since some of the values look fine in logarithmic.
Here is my code.
x = [3,5,7,9]';
A = [-5.3448 -9.2574 -5.3448 -9.2574;
-3.3636 -9.7099 -3.5704 -10.3067;
-2.6247 -10.6076 -2.6176 -10.5788;
-2.0660 -10.7350 -2.1397 -11.1182];
Y_range = [floor(min(A,[],'all')),ceil(max(A,[],'all'))];
figure
yyaxis left
semilogy(x,A(:,1),...
'LineStyle','-')
hold on
semilogy(x,A(:,3),...
'LineStyle','--')
ylim(Y_range)
yyaxis right
semilogy(x,A(:,2),...
'LineStyle','-')
hold on
semilogy(x,A(:,4),...
'LineStyle','--')
ylim(Y_range)
I confirmed my suspicions by creating a new figure before the yyaxis right.
I've attached PDFs showing the difference.
Together
Separate
Left
Right
As you can see, both data sets have no trouble plotting on log from the two separate figures, but only when they are on the same figures.Nathaniel H Wernerhttps://de.mathworks.com/matlabcentral/profile/authors/9280119-nathaniel-h-wernertag:de.mathworks.com,2005:Question/4721522019-07-17T12:30:53Z2019-07-17T13:27:05ZPlot of dspesific rows and columnsI have a txt file that I would like open, and plot the values from row 39 column 2 (x-axis) vs row 39 column 4 (y-axis) for about 8000 rows. It is also desirable to only plot every 10th row to make the script go faster.
Cathrinehttps://de.mathworks.com/matlabcentral/profile/authors/15822090-cathrinetag:de.mathworks.com,2005:Question/4379662019-01-02T05:00:00Z2019-07-17T13:26:22ZWhy MATLAB or Simulink is suddenly very slow after a crash (Windows)?Why MATLAB or Simulink is suddenly very slow after a crash (Windows)?
MathWorks Support Teamhttps://de.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:de.mathworks.com,2005:Question/4721372019-07-17T11:03:07Z2019-07-17T13:23:42ZHow to control graph layoutI want to know if there is a way to change the layout of the graph to represent what I want.
for now I connection of the nodes are correct but the node placment are not.
I wish to get some thing like this : (where the nodes are ordered from left to right and top to bottom)
what I get is the following:
Nora Khaledhttps://de.mathworks.com/matlabcentral/profile/authors/9705545-nora-khaledtag:de.mathworks.com,2005:Question/4717752019-07-15T14:20:54Z2019-07-17T13:23:40ZHow to extract specific values from a tableDear All
I'm aiming to measure the distance between all points in one frame and all points in the next frame. So I want to
Create a table (let’s call this “table i”)which only contains points in frame i (where “i" is the index of that frame) Create another table (“table i+1”), which only contains points in frame i+1 Create a 2D distance matrix (width equal to the number of points in frame i and height equal to the number of points in frame i+1) where each element is the Pythagoras distance between two points.
How can I implement this as a code ? Thank youkarishma koshyhttps://de.mathworks.com/matlabcentral/profile/authors/14279628-karishma-koshytag:de.mathworks.com,2005:Question/4720332019-07-16T21:40:43Z2019-07-17T13:23:30ZConfigurate PID in simulinkHi.. my answer may not be clear because I am not familiar to work on simulink.
I want to associate 4 PI in one block but I need to configure two of them to appear as 'zeros' as in the picture belew.
thanks for reviewing my questionzakaria debihhttps://de.mathworks.com/matlabcentral/profile/authors/10133723-zakaria-debihtag:de.mathworks.com,2005:Question/2792452016-04-15T04:00:00Z2019-07-17T13:21:02ZWhy do I receive License Manager Error -68?I receive the error below when trying to start MATLAB:
ERROR: License Manager Error -68: license borrow not enabled.
MathWorks Support Teamhttps://de.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:de.mathworks.com,2005:Question/4720352019-07-16T21:45:10Z2019-07-17T13:19:48ZM-script error while run itAfter I made the mathematical equation by the simulink as see in attached photo, then i saved it , I made new script to identify the constants to the simulink then i wrote the sim order with the same name of the simulink project sim('project3test') as u see in attached photo and saved it in the same folder of simulink save file.
when i click run there is an error message in the command window appear as u see in attached photo, while the simulink project is run normally.
What is the probelm for this error and how can i fix it ?
Thanks in advance Ahmed Samirhttps://de.mathworks.com/matlabcentral/profile/authors/14767407-ahmed-samirtag:de.mathworks.com,2005:Question/4721442019-07-17T12:01:56Z2019-07-17T13:19:02ZExport Cell-Data to .xlsx [Saves less data]Hello Everyone,
I am using following code to export Cell-data to .xlsx file.
filename='(AutoCheck7000).xlsx';
output = [header; Dataset];
xlswrite(filename,output); % Write to the new excel file.
Where as;
header is cell with 1*13 size
dataset is cell with 189*13 size
I have concentrated them using a variable output but xlswrite is only writing 2 header names instead of all names.
For instance;
the result is:
Whereas, the output-variable is as follows, so .xlsx should show all header names as well:
Any help would be appreciated :-)
Best regard,s
Waqar Ali MemonWaqar Ali Memonhttps://de.mathworks.com/matlabcentral/profile/authors/11370978-waqar-ali-memontag:de.mathworks.com,2005:Question/980922010-05-06T13:13:00Z2019-07-17T13:14:08ZWhy do I receive License Manager Error -15?Why do I receive "License Manager Error -15"?
On the client system, the error appears as:
ERROR: License checkout failed. Cannot connect to license server. License Manager Error -15.
On the license server, the error appears as:
ERROR: FlexNet Licensing error: -15,10. System Error: 10061 "WinSock: Connection refused"
MathWorks Support Teamhttps://de.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:de.mathworks.com,2005:Question/4721602019-07-17T13:13:23Z2019-07-17T13:13:23ZSimulink embedded coder: How to generate C code from model and use already previously generated code of subsystems inside?Lets say that I want to generate C code from a simulink model called A, then include the model A in another model called ABC as a subsystem (or linked library) and then generate code again from model ABC while ensuring that the generated C code of ABC just calls the already generated code from A. Is it even possible?
One of sufficient outcomes would be to ensure that the generated C files from ABC would contain some files that are exactly the same as all the C files generated from model A.
In general, generated .c files from ABC should look someting like this:
A.c:
#defines...
#include "A.h"
#include "A_private.h"
...input/output structure definitions
void A_step(void){
...math of the simulink blocks inside subsystem A. Names of the inputs and outputs corresponds to those in subsystem A.
}
ABC.c:
#defines...
#include "A.h"
#include "ABC.h"
#include "ABC_private.h"
...input/output structure definitions
void ABC_step(void){
A_step();
...some other calls or math. Names of the inputs and outputs corresponds to those in model ABC.
}
So far after many settings tweaks I managed to get to something like this:
A.c:
#defines...
#include "A.h"
/* Include model header file for global data */
#include "ABC.h"
#include "ABC_private.h"
...input/output structure definitions
void ABC_A(void){
...math of the simulink blocks inside subsystem A. Names of the inputs and outputs corresponds to those in model ABC.
}
ABC.c:
#defines...
#include "ABC.h"
#include "ABC_private.h"
...input/output structure definitions
void ABC_step(void){
ABC_A();
...some other calls or math. Names of the inputs and outputs corresponds to those in model ABC.
}
As you can see, in my case, its kind of other way around. The child (subsystem A) includes ABC. I need it to by like in the first example.
Also, the 'step function' of model A in my case is not the same as the desired one. It uses input/output structure from ABC model. I need it to use its own input/ouput structure (as if it was generated just from model A).
Things I have done:
Set the subsystem and model to be treated as atomic unit
Tried all the function packaging settings (nonreusable, reusable, etc.)
Function with separate data on/off
Function interface: void_void
System target: ert.tlc
Tried all sorts of things in Code Generation->Interface section in simulink settings
I know it should be possible somehow, because I have seen a generated source files like this. I dont really understands how the TLC templates work, so maybe that is the way to go? Any answer or suggestion will be much appreciated.Ondrej Slámahttps://de.mathworks.com/matlabcentral/profile/authors/7004975-ondrej-slamatag:de.mathworks.com,2005:Question/4717942019-07-15T16:40:04Z2019-07-17T13:12:30ZHow can i keep my variables after running the function?I have written a function that does some data anlayising on a table and then I have another function that uses that analysed data and does further analyses on it. The two functions used to be one but I have separated them. Is it possible to keep the variables once a function has run as currently all the variables in the function are cleared after running it.
Many thanks,
NimaNiloufar Hojathttps://de.mathworks.com/matlabcentral/profile/authors/13987987-niloufar-hojattag:de.mathworks.com,2005:Question/4721592019-07-17T13:10:18Z2019-07-17T13:10:18ZCross sections of 3D surface (stl)Dear Matlab community,
I am working towards a project and one of my tasks is to generate 0.3mm increment cross-sections of an STL file (attached). The delicate part of the process is that I generated cross-sections to similar STL files using a different software (VMTK) but due to the limitations of that software i now need to refer to matlab.
My Question:
Is there a way where I can generate a script which enables me to get cross sections of my STL in 0.3mm increments AND using a pre-determined cutting plane? In other words, I would like to use the same cutting plane as used in VMTK to generate these new cross-sections using MATLAB (for consistency).
Please provide me with some help or guiadance.
I thank you for your time,
-Dev.Devrim Tugberkhttps://de.mathworks.com/matlabcentral/profile/authors/13461396-devrim-tugberktag:de.mathworks.com,2005:Question/4721582019-07-17T13:10:18Z2019-07-17T13:10:18ZTurn single click into triple clickWhen you embed a table as data into a uitable, you need to triple click in a given cell replace the existing contents with what you type. Otherwise it just appends what you type to the existing data. Is there any way to take a single click and turn it into a triple click?Jeremyhttps://de.mathworks.com/matlabcentral/profile/authors/8517276-jeremytag:de.mathworks.com,2005:Question/4719862019-07-16T15:51:20Z2019-07-17T13:10:02ZChange the format of x axis in a Kernel density plot.
Hi all,
I made this plot using a Kernel density function
x = [B];
[f,xi] = ksdensity(x,'bandwidth', bw);
plot(xi,f, 'g');
What i would like to do is to change the x-axis labels into 10 base power. For example, instead of having 0 i would like to have 10^2 and so on. The final result shold be something similar to this figure:
Thank youalberto caracciolohttps://de.mathworks.com/matlabcentral/profile/authors/8312329-alberto-caracciolotag:de.mathworks.com,2005:Question/4714022019-07-12T06:24:25Z2019-07-17T13:09:47ZHi, can I compile c files drom simulink project from a command line in Linux? (Don't want to open/run Matlab!)Hi,
I want to set up an automatic build process on a linux machine for my simulink project. Therefore, I want to compile my project using the bash script. I know that I can compile the project using rtwbuild('MyProject') in the matlab command line. Can I run this command from a bash script as well, without opening matlab or even without having matlab installed?
Best,
JojoJoachim Fischerhttps://de.mathworks.com/matlabcentral/profile/authors/14517877-joachim-fischertag:de.mathworks.com,2005:Question/4721462019-07-17T12:15:37Z2019-07-17T13:08:04ZLoad particular data in a .m file from another .m file from different folder.Hi,
I have two folders in the drive as D:/data/folder1, D:/data/folder2.
In folder1, I created a 'M1.m' file which loads different data of different TYPES and length as A, B, C....
Now I want to use data 'A' in my 'M2.m' file in folder2 and I am trying this
load('D:/data/folder1/M1.m') in M2.m but it gives me an error.
Can you help me to know, How can I access data 'A' in M2.m?
Thanks
Vikram Rathorehttps://de.mathworks.com/matlabcentral/profile/authors/13555738-vikram-rathoretag:de.mathworks.com,2005:Question/4721542019-07-17T12:37:57Z2019-07-17T13:07:57ZK-Means: Indices of C in idxHello, I'm using the built-in kmeans function but I don't understand a thing. After I've applied the function, I have two output parameters: idx and C. The first one is a matrix containing, for each observation, the cluster's index where it has been classified. The second one is the matrix containing all the centroids location. Well, is there a way to know which are the indices of the centroids C inside the matrix idx? For example, I would like to know the index inside idx of C(:,1), etc.
Thank you very much.Maurizio Ciminohttps://de.mathworks.com/matlabcentral/profile/authors/12466363-maurizio-ciminotag:de.mathworks.com,2005:Question/4627332019-05-17T04:00:00Z2019-07-17T13:06:20ZWhy do I get the "java.net.SocketTimeoutException: Read timed out" error in my installation log?Why do I get the following error in my installation log?
ERROR: java.net.SocketTimeoutException: Read timed out
MathWorks Support Teamhttps://de.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:de.mathworks.com,2005:Question/4721502019-07-17T12:24:56Z2019-07-17T13:04:06ZHow to find the area of a segmented image in matlab?I need to find the total area of the segmented image(attached below) in Matlab. However i am not able to get that if i use regionprops('Area') command. It gives me total pixel size which is 2048*2048 but i need to find the area of only the segmented region(Black)? Please tell me how to do it.
Ramanathan Anandarama Krishnanhttps://de.mathworks.com/matlabcentral/profile/authors/11234494-ramanathan-anandarama-krishnantag:de.mathworks.com,2005:Question/999612010-04-28T18:32:00Z2019-07-17T13:03:12ZHow do I migrate my MATLAB clients to a new license server when the license server changes?I need to change the machine where my license server is located. Once I install the new license server, I would like to move the clients to the new server. How do I point MATLAB to the new license server?
MathWorks Support Teamhttps://de.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:de.mathworks.com,2005:Question/4721532019-07-17T12:33:10Z2019-07-17T13:02:30Zhelp for fprintf my code function [out] = slope(t,G)
k1=10;k2=20;m1=2;m2=4;
v1=G(1); x1=G(2);v2=G(3);x2=G(4);
out(1)=(-k1*x1+k2*(x2-x1))/m1;
out(2)=v1;
out(3)=-k2*(x2-x1)/m2;
out(4)=v2;
end
and
clc;clear;
tf=10;
n=1;
dt=0.1;
t(n)=0.1;
m(n,:)=[1 0 -1 0];
while t(n)<tf
t(n+1)=t(n)+dt;
m(n+1,:)=m(n,:)+slope(t(n),m(n,:))*dt;
n=n+1;
end
t
m
I would like make fprintf to show me t and m as colums. how?
note : m has 4 colums.
Thank youMurad Alzahranihttps://de.mathworks.com/matlabcentral/profile/authors/10766895-murad-alzahranitag:de.mathworks.com,2005:Question/4721572019-07-17T13:01:32Z2019-07-17T13:01:32ZI want to detect licence plate by recognizing text region. After running the code I have got other regions along with the plate region. Can anyone tell how can I get only the plate region?
Here is my code
close all;
clear all;
foredet = vision.ForegroundDetector('NumGaussians', 3, ...
'NumTrainingFrames', 50);
videoread = vision.VideoFileReader('C:\Users\HP\Downloads\trimmed2.mp4');
for i = 1:23
frame = step(videoread); % read the next video frame
foreground = step(foredet, frame);
end
figure; imshow(frame); title('Video Frame');
%figure; imshow(foreground); title('Foreground');
se = strel('square', 2);
filteredForeground = imopen(foreground, se);
%figure; imshow(filteredForeground); title('Clean Foreground');
I=uint8(filteredForeground*255);
I=im2double(I);
[mserregion] = detectMSERFeatures(I, ...
'RegionAreaRange',[200 8000],'ThresholdDelta',4);
% First, convert the x,y pixel location data within mserregions into linear
% indices as required by regionprops.
sz = size(I);
pixelIdxList = cellfun(@(xy)sub2ind(sz, xy(:,2), xy(:,1)), ...
mserregion.PixelList, 'UniformOutput', false);
% Next, pack the data into a connected component struct.
mserConnComp.Connectivity = 8;
mserConnComp.ImageSize = sz;
mserConnComp.NumObjects = mserregion.Count;
mserConnComp.PixelIdxList = pixelIdxList;
% Use regionprops to measure MSER properties
mserStats = regionprops(mserConnComp, 'BoundingBox', 'Eccentricity', ...
'Solidity', 'Extent', 'Euler', 'Image');
% Compute the aspect ratio using bounding box data.
bbox = vertcat(mserStats.BoundingBox);
w = bbox(:,1);
h = bbox(:,1);
aspectRatio = w./h;
% Get bounding boxes for all the regions
bboxes = vertcat(mserStats.BoundingBox);
% Convert from the [x y width height] bounding box format to the [xmin ymin
% xmax ymax] format for convenience.
xmin = bboxes(:,1);
ymin = bboxes(:,2);
xmax = xmin + bboxes(:,3) - 1;
ymax = ymin + bboxes(:,4) - 1;
% Expand the bounding boxes by a small amount.
expansionAmount = 0.02;
xmin = (1-expansionAmount) * xmin;
ymin = (1-expansionAmount) * ymin;
xmax = (1+expansionAmount) * xmax;
ymax = (1+expansionAmount) * ymax;
% Clip the bounding boxes to be within the image bounds
xmin = max(xmin, 1);
ymin = max(ymin, 1);
xmax = min(xmax, size(I,2));
ymax = min(ymax, size(I,1));
% Show the expanded bounding boxes
expandedBBoxes = [xmin ymin xmax-xmin+1 ymax-ymin+1];
IExpandedBBoxes = insertShape(I,'Rectangle',expandedBBoxes,'LineWidth',1);
figure
imshow(IExpandedBBoxes)
title('Expanded Bounding Boxes Text')
% Compute the overlap ratio
overlapRatio = bboxOverlapRatio(expandedBBoxes, expandedBBoxes);
% Set the overlap ratio between a bounding box and itself to zero to
% simplify the graph representation.
n = size(overlapRatio,1);
overlapRatio(1:n+1:n^2) = 0;
% Create the graph
g = graph(overlapRatio);
% Find the connected text regions within the graph
componentIndices = conncomp(g);
% Merge the boxes based on the minimum and maximum dimensions.
xmin = accumarray(componentIndices', xmin, [], @min);
ymin = accumarray(componentIndices', ymin, [], @min);
xmax = accumarray(componentIndices', xmax, [], @max);
ymax = accumarray(componentIndices', ymax, [], @max);
% Compose the merged bounding boxes using the [x y width height] format.
textBBoxes = [xmin ymin xmax-xmin+1 ymax-ymin+1];
% Remove bounding boxes that only contain one text region
numRegionsInGroup = histcounts(componentIndices);
textBBoxes(numRegionsInGroup == 1, :) = [];
% Show the final text detection result.
ITextRegion = insertShape(I, 'Rectangle', textBBoxes,'LineWidth',3);
figure
imshow(ITextRegion)
title('Detected Text')
Md. Ashraf Ali Anikhttps://de.mathworks.com/matlabcentral/profile/authors/10469557-md-ashraf-ali-aniktag:de.mathworks.com,2005:Question/4707792019-07-08T21:29:20Z2019-07-17T13:01:07ZHow can I count the number of circles with particular radius and center which overlap, without a loop? (I need to speed it up)The section of code below works to count how many times a particular grid point (with grid points much smaller than the circles themselves) is contained within a circle (i.e. how many circles overlap at each grid point) by making a mask for each individual circle and then adding the total to a matrix "cnts". My problem is that I need to do this for potentially hundreds of thousands of circles. Is there a way to speed up the masking/counting process without using the for loop (which I'm assuming is taking most of the time)? Thanks for any suggestions!
---------------------------------------------------------------------
%% loop over each circle to create a mask and count how many circles hit each grid point
cnts = zeros(size(xx));
for i = 1:length(xc)
xc = x_centers(i); % find the center point of circle #i
yc = y_centers(i);
mask = ((xx-xc).^2 + (yy-yc).^2)<(beam_diameter/2)^2; %create a mask for that circle
% add counts to a grid to determine how many circles hit each grid point
cnts = cnts+mask;
end
Christine Zhttps://de.mathworks.com/matlabcentral/profile/authors/11079528-christine-ztag:de.mathworks.com,2005:Question/4721252019-07-17T10:16:21Z2019-07-17T12:59:26ZCode to Extract Value from A Specific Cell during SimulationHi guys,
I have issues extracting my power output value during simulation. I have this code and the table of Pold from workspace. How do I extract only one value from one of the cells in workspace to be included in my array which I declared as [0;0;0;0]. If I have this many value so I dont know how to assign a value into my array which I need to use for the later part of my code.
if T<=0.05
D = DPold(1);
if T>0.045
Pold(1) = P;
end
elseif T>0.05 && T<=0.1
D = DPold(2);
if T>0.095
Pold(2) = P;
end
elseif T>0.1 && T<=0.15
D = DPold(3);
if T>0.145
Pold(3) = P;
end
elseif T>0.15 && T<=0.2
D = DPold(4);
if T>0.195
Pold(4) = P;
endYoon Tjun Hunghttps://de.mathworks.com/matlabcentral/profile/authors/13059670-yoon-tjun-hungtag:de.mathworks.com,2005:Question/4721512019-07-17T12:28:14Z2019-07-17T12:58:30ZControl value range in matlab UI spinnerHello
I have a function that enables you to add numbers through spinner on the app designer
how do I control the value range from ( 0.1 to 1)
find the function below
function EnumSpinnerValueChanged(app, event)
value = app.EnumSpinner.Value;
end
end
Thanks in advance
TinoTinohttps://de.mathworks.com/matlabcentral/profile/authors/14719592-tinotag:de.mathworks.com,2005:Question/4721562019-07-17T12:53:10Z2019-07-17T12:53:10ZI have a binary image after doing ForegroundDetection and want to fill the vehicle region. I have used imfill but i does not fill the whole vehicle. Does anyone know how to do it?
Here is my code
foredet = vision.ForegroundDetector('NumGaussians', 3, ...
'NumTrainingFrames', 50);
videoread = vision.VideoFileReader('C:\Users\HP\Downloads\trimmed2.mp4');
for i = 1:23
frame = step(videoread); % read the next video frame
foreground = step(foredet, frame);
end
figure; imshow(frame); title('Video Frame');
%figure; imshow(foreground); title('Foreground');
se = strel('square', 2);
filterfor= imopen(foreground, se);
figure; imshow(filterfor); title('Clean Foreground');
Md. Ashraf Ali Anikhttps://de.mathworks.com/matlabcentral/profile/authors/10469557-md-ashraf-ali-aniktag:de.mathworks.com,2005:Question/4716752019-07-14T19:59:10Z2019-07-17T12:50:42ZTable embedded in uitable ignores ColumnFormat PropertyAny idea why a table embedded into a uitable control ignores the ColumnFormat property? In the example below, if I feed a cell array (data1 variable) to my uitable, I get the second column right-aligned, as desired. If I try the same thing with feeding a table to uitable as data (data2 variable), it obeys all of the other property commands except for ColumnFormat. Thoughts?
f = uifigure;
A = {'Test 1'; 'Test 2'};
B = {'1'; '2'};
data1 = [A, B];
data2 = table(A, B);
t = uitable(f);
% t.Data = data1;
t.Data = data2;
t.ColumnName = {'Coefficient'; 'Value'};
t.ColumnWidth = {99 99};
t.RowName = {};
t.RowStriping = 'off';
t.ColumnEditable = [false true];
t.ColumnFormat = {[] ['numeric']};Jeremyhttps://de.mathworks.com/matlabcentral/profile/authors/8517276-jeremytag:de.mathworks.com,2005:Question/4718562019-07-16T05:05:10Z2019-07-17T12:50:30Zhow to read multiple excel files, apply hampel filter and save them into folder with same names as input filesHi everyone
I have 20 excel files in a folder, I want to read those files, apply hampel filter and save them into a folder with same names.
files=dir('E:\EEG_RECORDING\Male_Data\*.csv');
files=files(~[files.isdir]);
n=length(files);
for i=1:n
data=xlsread(fullfile(files(i).folder, files(i).name));
a=hampel(data,y)
end
I am not getting how to apply filter and save the files. Here is attachement of error.
bushra fatimahttps://de.mathworks.com/matlabcentral/profile/authors/6925812-bushra-fatimatag:de.mathworks.com,2005:Question/4718162019-07-15T18:53:31Z2019-07-17T12:50:16ZChange name of figures in figures TabHello all, i was wandering how to change the name of figures in theFigures tab. Even if i create the figures like
CurvaJV = figure
the name that it displays still "Figure 1" as shown in the picture. Thanks!!!
fedeventohttps://de.mathworks.com/matlabcentral/profile/authors/5097589-fedeventotag:de.mathworks.com,2005:Question/3616962017-10-17T08:53:01Z2019-07-17T12:48:47ZHow to update variable names after a "clear"Dear Community,
I wonder if there is another way to clear variables. If I do:
clear var1 var2
% or
clearvars('var1','var2')
The variables are strings or purple and are not updated if the name of the variable is changed.
How can I realize that variables after a clear or clearvars are updated if the variable name is changed. (e.g. the original variable name was not descriptive enough).
Edit: I mean not during running the code, the variable name is not dynamic!
I mean during writing, the editor offers you the possibility to rename all instances of a variable (Shift-Enter)
>> Press Shift+Enter to rename 4 instances of " _var1_" to " _anothernameOfVar1_"
within a script. Variables after a clear or clearvars are not affected by this.
Best, RobinRobin Hhttps://de.mathworks.com/matlabcentral/profile/authors/9972403-robin-htag:de.mathworks.com,2005:Question/4718982019-07-16T09:18:16Z2019-07-17T12:48:18ZReport generator only showing names of the objects instead of their contentHello everyone!
I have a code generating a full report but I want to add an image in the header so I created a template and tried out. But now the word file only gives me the name of the objects in the report and not the actual content like this:
Do anyone know where does this problem comes from?
My code is
rpt = Document('Report','docx', 'template.dotx');
moveToNextHole(rpt)
%% title page generation
tp = TitlePage;
tp.Title = 'Report';
tp.Subtitle = 'This report is generated from the test.';
tp.Author = 'Jack'
append(rpt, tp);
%% Adding table of contents
append(rpt, TableOfContents);
%% Summary of the whole regressiotest
ChapterRegression = Chapter;
ChapterRegression.Title = 'Summary';
SectionIntro = Section;
SectionIntro.Title = 'Introduction';
para = Paragraph('The test script ran all the tests.');
para.Style = {FontSize('14pt'), FirstLineIndent('0.2in')};
add(SectionIntro, para);
add(ChapterRegression, SectionIntro);
append(rpt, ChapterRegression)
close(rpt)
My dotx template just have one Rich Text Content Control hole.
Thank you in advance!Jack Arnoldihttps://de.mathworks.com/matlabcentral/profile/authors/15661301-jack-arnolditag:de.mathworks.com,2005:Question/4719772019-07-16T15:26:42Z2019-07-17T12:47:13ZWhere are all drawn shapes stored from an axis?Let's say that I have an axis and I draw three shapes on it using drawrectangle.
Is there some way to call an array that holds the handles to each of these shapes?
ThanksJoseph Henryhttps://de.mathworks.com/matlabcentral/profile/authors/15701279-joseph-henry