https://nl.mathworks.com/matlabcentral/newsreader/most_recent_feed
MATLAB Central Newsreader Recent Posts
Most Recent Posts
enus
©19942017 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
https://nl.mathworks.com/images/membrane_icon.gif

Sat, 25 Mar 2017 11:08:03 +0000
creating a database of data entered on GUI textbox
https://nl.mathworks.com/matlabcentral/newsreader/view_thread/347960#952645
Omkar Kane
how to create a database? which includes<br>
1. text entered in the textbox in GUI.<br>
2. image corresponding it. <br>
database should be created by just clicking a button on GUI

Sat, 25 Mar 2017 09:59:03 +0000
Re: pixel position after rotation using imrotate with crop
https://nl.mathworks.com/matlabcentral/newsreader/view_thread/347959#952644
Tanju
I finally solved it and i'd like to share it with who ever needs:<br>
<br>
Here is the solution:<br>
<br>
% pX,pY is the pixel position in original img<br>
% xM,yM is the center of the original img<br>
% xMr,yMr is the center of the rotated img<br>
[th, ra] = cart2pol(pXxM, pYyM);<br>
tD = radtodeg(th)  theta; % here was my mistake  i used (+) instead of ()<br>
tR = degtorad(tD);<br>
[pXc, pYc] = pol2cart(tR,ra);<br>
% new position<br>
pXr = round(pXc + xMr);<br>
pYr = round(pYc + yMr);<br>
<br>
Comments are welcome<br>
Thanks & enjoy

Sat, 25 Mar 2017 09:43:33 +0000
Re: How to convert multiple images of a folder from RGB to Grayscale
https://nl.mathworks.com/matlabcentral/newsreader/view_thread/347958#952643
Nasser M. Abbasi
On 3/25/2017 4:36 AM, Tousif Ahmed wrote:<br>
<br>
> Thank You very much, actually i am new to matlab dont<br>
>know much about that. can you help me out with the coding please<br>
><br>
<br>
There are actualy code which does very similar things<br>
as you are asking. If you google<br>
<br>
"convert multiple images matlab" for example<br>
<br>
<a href="http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F">http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F</a><br>
<br>
Has complete code showing how to do this.<br>
<br>
One way to learn program is to start with simple tasks.<br>
Try to open one image file and read it and convert it.<br>
Code to so this is all in the help as well. This only<br>
takes 3 lines of code and the lines are in the help<br>
pages.<br>
<br>
<br>
Nasser<br>
<br>

Sat, 25 Mar 2017 09:40:03 +0000
Re: How to import all the text files in a folder by clicking a button in MATLAB GUI ?
https://nl.mathworks.com/matlabcentral/newsreader/view_thread/347948#952642
R. B.K.
"Mora Akhil" wrote in message <ob2n4n$pl1$1@newscl01ah.mathworks.com>...<br>
> Hello, everyone! I have to import all the text files in a folder by clicking a button in MATLAB GUI. One of the text files looks like the following way. I am unable to do it. Please help me out.<br>
> <br>
> Hello! I have a problem. How to import a text file and save it in the workspace that contains the data below in Matlab GUI.<br>
> <br>
> % File1.txt<br>
> Car sales <br>
> <br>
> Data Time Sclass Gclass AClass<br>
> <br>
> 122016 10:00:1.1 5 2 10<br>
> 222016 10:00:1.5 10 1 12<br>
> 322016 10:00:2.0 3 3 07<br>
> 422016 10:00:2.5 9 1 05?<br>
<br>
I think import tool(https://www.mathworks.com/help/matlab/ref/importtoolapp.html) is what you are looking for.

Sat, 25 Mar 2017 09:36:03 +0000
Re: How to convert multiple images of a folder from RGB to Grayscale
https://nl.mathworks.com/matlabcentral/newsreader/view_thread/347958#952641
Tousif Ahmed
"Nasser M. Abbasi" wrote in message <ob590h$149k$1@gioia.aioe.org>...<br>
> On 3/25/2017 3:04 AM, Tousif Ahmed wrote:<br>
> > How to convert multiple images of a folder from RGB to Grayscale<br>
> ><br>
> <br>
> to convert RGB to gray, the command is rgb2gray()<br>
> <br>
> To read image from file the command is imread<br>
> <br>
> To find files in folder the command is listing = dir('*.gif')<br>
> or whatever the image file extension is.<br>
> <br>
> Once you obtain the listing of of files, then you<br>
> can loop over them reading them one by one and<br>
> convert the image. to save it back to disk the command<br>
> is imwrite.<br>
> <br>
> It is all so easy :)<br>
> <br>
> Nasser<br>
<br>
Thank You very much, actually i am new to matlab dont know much about that. can you help me out with the coding please

Sat, 25 Mar 2017 09:17:03 +0000
pixel position after rotation using imrotate with crop
https://nl.mathworks.com/matlabcentral/newsreader/view_thread/347959#952640
Tanju
Could anyone please help me for finding the new position of a particular pixel (say row=100, col=150 in the original image) after rotation using imrotate?<br>
<br>
I checked several treats on the topic, but the ones I found do not solve the 'crop' case, which I guess changes the whole thing.<br>
<br>
Here is the command I used for rotation:<br>
<br>
imgRotated = imrotate(img, theta, 'nearest', 'crop');<br>
<br>
Thanks

Sat, 25 Mar 2017 08:16:15 +0000
Re: How to convert multiple images of a folder from RGB to Grayscale
https://nl.mathworks.com/matlabcentral/newsreader/view_thread/347958#952639
Nasser M. Abbasi
On 3/25/2017 3:04 AM, Tousif Ahmed wrote:<br>
> How to convert multiple images of a folder from RGB to Grayscale<br>
><br>
<br>
to convert RGB to gray, the command is rgb2gray()<br>
<br>
To read image from file the command is imread<br>
<br>
To find files in folder the command is listing = dir('*.gif')<br>
or whatever the image file extension is.<br>
<br>
Once you obtain the listing of of files, then you<br>
can loop over them reading them one by one and<br>
convert the image. to save it back to disk the command<br>
is imwrite.<br>
<br>
It is all so easy :)<br>
<br>
Nasser

Sat, 25 Mar 2017 08:04:03 +0000
How to convert multiple images of a folder from RGB to Grayscale
https://nl.mathworks.com/matlabcentral/newsreader/view_thread/347958#952638
Tousif Ahmed
How to convert multiple images of a folder from RGB to Grayscale

Sat, 25 Mar 2017 07:41:07 +0000
Re: Segmenting a vector with NaN´s
https://nl.mathworks.com/matlabcentral/newsreader/view_thread/347957#952637
Nasser M. Abbasi
On 3/24/2017 9:07 PM, Paramonte wrote:<br>
> Dear All<br>
><br>
> I have an index vector with NaN's such as:<br>
><br>
> index=[ 1 2 3 NaN NaN NaN 7 8 9 10 NaN 12 13 14 15 NaN NaN NaN 19 20]<br>
><br>
> What I want is to obtain in a cell the segments between the NaN's.<br>
><br>
> So I would want:<br>
><br>
> segments_index={[1 2 3 ], [ 7 8 9 10], [12 13 14 15], [19 20]};<br>
> How to automatically implement this operation?<br>
><br>
> Many Thanks in Advance<br>
><br>
<br>
One possible way<br>
<br>
data=[1 2 3 NaN NaN NaN 7 8 9 10 NaN 12 13 14 15 NaN NaN NaN 19 20];<br>
r=num2str(data)<br>
C = strsplit(r,'NaN')<br>
C(cellfun(@(c) size(c,2) == 2, C)) = [];<br>
C{:}<br>
<br>
1 2 3<br>
<br>
7 8 9 10<br>
<br>
12 13 14 15<br>
<br>
19 20<br>
<br>
>><br>
<br>
Or you could do it the good old fashioned way, use a loop<br>
<br>
<br>
myCell={};<br>
currentCell=[];<br>
lastEntryWasNaN=false;<br>
j=0;<br>
data=[1 2 3 NaN NaN NaN 7 8 9 10 NaN 12 13 14 15 NaN NaN NaN 19 20];<br>
for i=1:length(data)<br>
if isnan(data(i))<br>
if ~lastEntryWasNan<br>
lastEntryWasNan=true;<br>
j=j+1;<br>
myCell{j}=currentCell;<br>
currentCell=[];<br>
end<br>
else<br>
lastEntryWasNan=false;<br>
currentCell=[currentCell i];<br>
if i==length(data)<br>
j=j+1;<br>
myCell{j}=currentCell;<br>
end<br>
end<br>
end<br>
<br>
<br>
>> myCell{:}<br>
<br>
1 2 3<br>
7 8 9 10<br>
12 13 14 15<br>
19 20<br>
<br>
Nasser

Sat, 25 Mar 2017 02:07:03 +0000
Segmenting a vector with NaN´s
https://nl.mathworks.com/matlabcentral/newsreader/view_thread/347957#952636
Paramonte
Dear All<br>
<br>
I have an index vector with NaN's such as:<br>
<br>
index=[ 1 2 3 NaN NaN NaN 7 8 9 10 NaN 12 13 14 15 NaN NaN NaN 19 20]<br>
<br>
What I want is to obtain in a cell the segments between the NaN's.<br>
<br>
So I would want:<br>
<br>
segments_index={[1 2 3 ], [ 7 8 9 10], [12 13 14 15], [19 20]};<br>
How to automatically implement this operation?<br>
<br>
Many Thanks in Advance

Sat, 25 Mar 2017 01:48:03 +0000
Re: How to read multiple/all files from dir
https://nl.mathworks.com/matlabcentral/newsreader/view_thread/161967#952635
Norianne Ingram
"Walter Roberson" wrote in message <fmditi$cbl$1@canopus.cc.umanitoba.ca>...<br>
> In article <fmdi47$rcv$1@fred.mathworks.com>,<br>
> L H <nospam.noanswer@mathworks.com> wrote:<br>
> <br>
> >How to read multiple/all datafiles from specified <br>
> >directory?<br>
> >There are up to ~1000 files to load&read to a struct for <br>
> >further analyses.<br>
> <br>
> >I would like it to work as easy as possible: just give a <br>
> >directory name to Matlab, and it should load files one by <br>
> >one and then add into struct (this struct part is ready to <br>
> >use for single filename given).<br>
> <br>
> fnames = dir('*.mat');<br>
> numfids = length(fnames);<br>
> vals = cell(1,numfids);<br>
> for K = 1:numfids<br>
> vals{K} = load(fnames(K).name);<br>
> end<br>
>  <br>
> "Beware of bugs in the above code; I have only proved it correct,<br>
> not tried it."  Donald Knuth<br>
<br>
<br>
<br>
<br>
This works amazingly for what I was trying to do. THANK YOUUUUU

Sat, 25 Mar 2017 01:31:03 +0000
Re: Derivate of Symbolic Equation with respect to time
https://nl.mathworks.com/matlabcentral/newsreader/view_thread/347946#952634
Andrew Tully
<br>
> > 1) what is syms V? What is V?<br>
> <br>
> The issue is this: We want to take derivative w.r.t. diff(x(t),t),<br>
> and not w.r.t to x(t), nor w.r.t. to "t".<br>
> <br>
> So what to do? Simply relpace diff(x(t),t) in the Lagrangian L with with V,<br>
> Then now take diff(L,V), then replace V in the replace back with diff(x(t),t).<br>
> <br>
> > 2) what does your variables tmp,eqm stand for?<br>
> ><br>
> <br>
> tmp is simply a temporary variable to hold the result of the<br>
> above, while doing this switching trick.<br>
> <br>
> EQM is short notation for equation of motion that I use. That is all.<br>
> <br>
> > Thankyou!!<br>
> ><br>
> <br>
> Hope this helps. You can now use subs to plugin numerical values<br>
> for those EQM paramaters (mass, etc...), and then simulate EQM with<br>
> time and see if the answer is correct or not :)<br>
> <br>
> Nasser<br>
<br>
Thanks! That does help! So subbing V is similar to a u substitution taught in calculus classes. Gotcha. You da man, sir!

Fri, 24 Mar 2017 23:04:03 +0000
Re: wavedec2 and NaN values
https://nl.mathworks.com/matlabcentral/newsreader/view_thread/344699#952633
Bino A Varghese
"M Falco" wrote in message <nb9drm$gjk$1@newscl01ah.mathworks.com>...<br>
> Hello everyone, I am trying to use the wavelet decomposition toolbox (particularly I'm decomposing with wavedec2 and reconstructing with wrcoef2) but I'm having problems as my matrix have some NaN values that really affect my results. Is there a way to ignore those NaN values?<br>
> <br>
> Hope someone can answer and thank you very much,<br>
> <br>
> Magui<br>
<br>
Do you have a solution to this problem?

Fri, 24 Mar 2017 21:20:03 +0000
Re: Error loading Java class
https://nl.mathworks.com/matlabcentral/newsreader/view_thread/347947#952632
M Laymon
"Yair Altman" wrote in message <ob2eiv$73v$1@newscl01ah.mathworks.com>...<br>
> "M Laymon" wrote in message <ob24at$ee1$1@newscl01ah.mathworks.com>...<br>
> > I have a Java class to facilitate interacting with an Oracle db from Matlab. When I try to load the Java object from a complex Matlab application where one script calls another using the command<br>
> > dbUtil = com.ge.MatlabDBUtil();<br>
> > I get the error:<br>
> > Undefined variable "com" or class "com.ge.MatlabDBUtil".<br>
> > I wrote a simple test script where the command<br>
> > dbUtil = com.ge.MatlabDBUtil();<br>
> > works fine. I am using javaaddpath to make sure the jar file is visible to Matlab. If I call javaclasspth('dynamic') right before calling "dbUtil = com.ge.MatlabDBUtil();", the jar containing MatlabDBUtil.class is on the classpath. I found a post from 2011 suggesting that when using 'javaaddpath' you also need to use 'clear java;' but I get the same error using 'clear java;'. Initially when running my simple test, I was getting an error about the jar for ojdbc not being found, so I am using javaaddpath to add the jar for ojdbc to the java classpath as well. Any suggestions on how to debug the difference between the two use cases ? Thanks.<br>
> <br>
> <br>
> The following article lists potential reasons for this:<br>
> <a href="http://UndocumentedMatlab.com/blog/javaclassaccesspitfalls">http://UndocumentedMatlab.com/blog/javaclassaccesspitfalls</a><br>
> <br>
> Yair Altman <br>
> <a href="http://UndocumentedMatlab.com">http://UndocumentedMatlab.com</a> <br>
> <br>
Thanks for the link. I was able to find the problem based on it. It was a Java version issue. In the case that worked, I was not explicitly loading my .jar with javaaddpath. (This is an old test code someone else wrote. Since it worked, I did not notice it was not loading my jar explicitly.) I had to use javaaddpath to load the JDBC jar, so I thought I would need to add the jar for my code as well. When I removed the javaaddpath command for the jar from the code that did not work, it started working. The version of Matlab I am using uses Java 1.6. I recently recompiled my Java class and built the jar file using Java 1.7. When I don't explicitly load my jar with javaaddpath, the directory containing the .class files is still included on the classpath. Since the jar file contains the same .class file, I don't know why the raw .class file works but using a jar containing it <br>
does not, but for now I can at least run the code. Thanks.

Fri, 24 Mar 2017 20:41:03 +0000
PDEToolbox 3D question and problem: Assigning holes inside geometry and meshing failed with a Hmax of ...
https://nl.mathworks.com/matlabcentral/newsreader/view_thread/347956#952631
Peter Fimognari
I have been attempting to set up a 3D PDE problem and have been running into a problem with generateMesh and a question about importGeometry.<br>
<br>
I can import a .STL file fine, my model consists of 4 cells and 41 faces. The four cells are (1) a shaped piece of iron which is in contact with a pair of bar magnets (2) and (3), all within a bounding box (4). Each of these seems to be reasonably recognized by importGeometry.<br>
<br>
My question about importGeometry is: I would like to treat cells (2) and (3) as holes in the model so I can assign boundary conditions on their edges. Is this possible? <br>
<br>
My problem with generateMesh is: I am unable to generate a mesh of this geometry. It seems that the contact between cell (1) and (2) and (3), and the bounding box (4) all prevent the creation of the mesh. If I generate each individual cell as its own STL model I can mesh them, but it seems there is no way to combine these into a single model. <br>
<br>
Has anyone else come across this? Thanks in advance.