https://se.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://se.mathworks.com/images/membrane_icon.gif

Tue, 25 Jul 2017 21:02:05 +0000
Re: Divide char array into equal parts
https://se.mathworks.com/matlabcentral/newsreader/view_thread/349160#955502
dpb
On 07/25/2017 10:49 AM, mia saam wrote:<br>
><br>
>> What is the subsequent processing?<br>
>><br>
>> <br>
> I want to encrypt a block of text each time the algorithm should handle<br>
> 16 byte but I'm having problems because using a char will force me to<br>
> handle only 8 elements each time(16 bytes) and the results will also be<br>
> doubled in size because of using hex2dec so I'm confused and don't know<br>
> what to do or what to use<br>
<br>
Actually, in Matlab it likely would be better to just leave the text as <br>
a char() array and do your operations on it in situ. Likely these can <br>
be vectorized (for example, rearranging by 16 in one dimension would let <br>
vector operations work by column as they're natively built to do).<br>
<br>
However, w/o more detail we really can't tell where the problems you're <br>
having arise and what would be the way around them.<br>
<br>


Tue, 25 Jul 2017 20:45:08 +0000
Re: Time limit on function execution
https://se.mathworks.com/matlabcentral/newsreader/view_thread/255067#955501
Abhinav Gaur
Unless the function under question is being called in a loop, how is this possible in Matlab without Multithreading concept?<br>
<br>
Abhinav<br>
<br>
"Bruno Luong" wrote in message <o6kql4$rs1$1@newscl01ah.mathworks.com>...<br>
> "Jan Simon" wrote in message <o6kpl6$pr6$1@newscl01ah.mathworks.com>...<br>
> > See: https://www.mathworks.com/matlabcentral/fileexchange/61263timeout<br>
> > <br>
> > This emulates a CtrlC after a specified amount of time.<br>
> <br>
> ControlC is very crude because one cannot control what stack level it should interrupt. I goes back to the first level.<br>
> <br>
> I think a better way is to use timer to update some shared logical variable and the function have to check this variable periodically and exit properly if the interrupt signal is set.<br>
> <br>
> Yes it requires some more complex programing, but it's much cleaner.<br>
> <br>
> Bruno

Tue, 25 Jul 2017 20:00:26 +0000
Re: OPENLOOP NARXNET FOR THE PH_DATASET
https://se.mathworks.com/matlabcentral/newsreader/view_thread/346212#955500
Greg Heath
"Marco Illiano" wrote in message <oiqp2g$4ui$1@newscl01ah.mathworks.com>...<br>
> Hello Greg,<br>
> I'm working on data from a cosmic ray detector. I have about 11 explanatory variables and it is difficult to produce a unique model for ID. <br>
> From ACP analisys you can see that the weather and seismic variables have good relations in the short term with the dependent variable. The variables relate to solar activity, have a poorer relationship.<br>
> But from the studies it is well known that the relationship is visible over longer periods than the one in question: in the last year (since the detector is in operation), solar activity was quite contained: Cross correlation and correlation with the dependent variable does not show significant values for solar activity variables.<br>
> <br>
> So I'm trying to develop two networks for the short (daily basis) and long term (on a monthly basis).<br>
> <br>
> Now I'm starting from your program to optimize the number of hidden nodes. Just a question about: <br>
> Why did you set MSEgoal so low (0.001) when default "trainlm" will always stop train on validation data??<br>
> Do you know if exist pruning algorithm of weights in Matlab??<br>
<br>
1. TRAINLM DOES NOT ALWAYS STOP FRON VAL STOPPING.<br>
2. For regression and classification MSEgoal = 0.01*mean(var(target'),1) yields NMSE = 0.01 and Rsquare = 0.99.<br>
3. To get that for a closeloop timeseries net, the openloop goal has to be lower. <br>
How much lower depends on the difficulty of the training. So, it really is trial and error. For easy looking problems I try 0.005. For harder problems I try 0.001.<br>
4. I don't know of any pruning programs. I just satisfy myself with trying to minimize the number of hidden nodes subject to the constraint on NMSE.<br>
<br>
Hope this helps.<br>
<br>
Greg

Tue, 25 Jul 2017 19:39:09 +0000
Re: Write Member Variable of a Class
https://se.mathworks.com/matlabcentral/newsreader/view_thread/137342#955499
Nathanael Kazmierczak
Glenn.Ehrlich@specastro.com wrote in message <1165346882.055423.220990@73g2000cwn.googlegroups.com>...<br>
> <br>
> mike wrote:<br>
> > Hello Everyone,<br>
> ><br>
> > That may be not the most sophisticated question you have ever seen on this forum but I am new to object oriented programming with Matlab and I would appreciate a bit help.<br>
> > How do I change the value of a member variable outside the constructor? I can read but not write the member variables inside the member function.<br>
> ><br>
> > Example:<br>
> ><br>
> > % constructor <br>
> > function p = CTest()<br>
> > p.var = 1;<br>
> > p = class(p,'Test');<br>
> ><br>
> > % member function <br>
> > function ret = inc(p)<br>
> > p.var = p.var + 2;<br>
> > ret = p.var;<br>
> ><br>
> ><br>
> > % command window <br>
> > obj = CTest();<br>
> > inc(obj)<br>
> ><br>
> > ans =<br>
> ><br>
> > 3<br>
> ><br>
> > inc(obj)<br>
> ><br>
> > ans =<br>
> ><br>
> > 3<br>
> <br>
> Unlike C++ or Java, if you have a method update an instance variable,<br>
> you need to return the object and save it. So your inc method should<br>
> look like this:<br>
> <br>
> function [p, ret] = inc(p)<br>
> p.var = p.var + 2;<br>
> ret = p.var<br>
> <br>
> And in the command window, or in any code, you need to do this:<br>
> <br>
> >> obj = CTest();<br>
> >> [obj, ret] = inc(obj);<br>
> <br>
> This is explained in the docs here:<br>
> <br>
> MATLAB > Programming > Classes and Objects > Tips for C++ and Java<br>
> Programmers<br>
> <br>
> Glenn<br>
> <br>
<br>
I ran across this when searching for a solution to a data loading problem I was having, and thought I would post an alternative solution in case anyone else has the same issue. <br>
<br>
I have a class instance mySOI which can be initialized with or without a particular instance variable myStoichiometryOptimizationObject. Defining the class for mySOI as a handle class allows you to update the instance variable just by calling a method, rather than through reassigning the object as presented above. In the code example below, the invocation of "testdostuff()" assigned the instance variable.<br>
<br>
<br>
>> mySOI = StoichiometryOptimizationInterface<br>
<br>
To begin a stoichiometric optimization, type in the name of your optimizer followed by .CLI() to invoke the command line interface.<br>
<br>
mySOI = <br>
<br>
StoichiometryOptimizationInterface with properties:<br>
<br>
optimization_algorithm_preference: []<br>
spectral_algorithm_preference: []<br>
nesting_preference: []<br>
myStoichiometryOptimizationObject: []<br>
<br>
>> mySOI.testdostuff()<br>
>> mySOI<br>
<br>
mySOI = <br>
<br>
StoichiometryOptimizationInterface with properties:<br>
<br>
optimization_algorithm_preference: []<br>
spectral_algorithm_preference: []<br>
nesting_preference: []<br>
myStoichiometryOptimizationObject: [1x1 StoichiometryOptimization]

Tue, 25 Jul 2017 19:26:49 +0000
Re: Divide char array into equal parts
https://se.mathworks.com/matlabcentral/newsreader/view_thread/349160#955498
dpb
On 07/25/2017 10:49 AM, mia saam wrote:<br>
><br>
>> What is the subsequent processing?<br>
>><br>
>> <br>
> I want to encrypt a block of text each time the algorithm should handle<br>
> 16 byte but I'm having problems because using a char will force me to<br>
> handle only 8 elements each time(16 bytes) and the results will also be<br>
> doubled in size because of using hex2dec so I'm confused and don't know<br>
> what to do or what to use<br>
<br>
So what's the problem with the previous and ARRAYFUN() (although you'll <br>
still need to step through the characters I'd presume)?<br>
<br>
_Show_ us the algorithm, don't just talk around it. We can only know <br>
what you specifically tell us; we can't see your terminal from here to <br>
look over your shoulder...<br>
<br>


Tue, 25 Jul 2017 17:44:12 +0000
Re: Problem of 'set(gca, 'yscale', 'log')'
https://se.mathworks.com/matlabcentral/newsreader/view_thread/273948#955496
Hadi
"Steven_Lord" <slord@mathworks.com> wrote in message <ik6d98$bef$1@fred.mathworks.com>...<br>
> <br>
> <br>
> "TideMan" <mulgor@gmail.com> wrote in message <br>
> news:6f2dda2eb06245b4bb0564a5bc35b565@t13g2000prc.googlegroups.com...<br>
> > On Feb 25, 5:55 am, "Steven_Lord" <sl...@mathworks.com> wrote:<br>
> >><br>
> >> This is not the cause of the problem, I believe.<br>
> >><br>
> >> To the OP: execute all your code up to but not including the command <br>
> >> that<br>
> >> changes the scale to 'log'. Now look at the limits of your Y axis.<br>
> >><br>
> >> ylim<br>
> >><br>
> >> Remember that IMAGESC, like IMAGE, uses the x and y inputs as the <br>
> >> _centers_<br>
> >> of the pixels. Because the smallest element of w*t is so small, the <br>
> >> pixels<br>
> >> corresponding to that coordinate extend into the region of the plane <br>
> >> where<br>
> >> the y coordinate is barely negative, and this causes the limits of the <br>
> >> axes<br>
> >> to be just slightly negative. When you set the YScale to be a <br>
> >> logarithmic<br>
> >> scale, that slight section of the axes where the Y coordinate is negative<br>
> >> causes this warning.<br>
> >><br>
> >> <br>
> >> Steve Lord<br>
> >> sl...@mathworks.com<br>
> >> To contact Technical Support use the Contact Us link <br>
> >> on<a href="http://www.mathworks.com">http://www.mathworks.com</a><br>
> ><br>
> > Steven<br>
> ><br>
> <br>
> I have to disagree with your disagreement. The exact line of code the user <br>
> executes, from the first message I see in this thread, is:<br>
> <br>
> imagesc(d, w*t, log10(F));<br>
> <br>
> From the signature of IMAGESC as given in the documentation:<br>
> <br>
> <a href="http://www.mathworks.com/help/techdoc/ref/imagesc.html">http://www.mathworks.com/help/techdoc/ref/imagesc.html</a><br>
> <br>
> "imagesc(x,y,C) displays C as an image and specifies the bounds of the x <br>
> and yaxis with vectors x and y."<br>
> <br>
> log10(F) is the user's image data [the C input]. d controls the x <br>
> coordinates of the pixel centers. w*t controls the y coordinates of the <br>
> pixel centers. It is w*t that has values so small that the extent of the <br>
> pixel includes points with negative y coordinates and it is that which <br>
> causes the warning.<br>
> <br>
> To check this, let's take the log10(F) out of the picture entirely.<br>
> <br>
> <br>
> N = 1000;<br>
> t = 3e9;<br>
> d = 0.0001:0.01:1;<br>
> w = logspace(3, 1, 101)/t;<br>
> <br>
> [D, W] = meshgrid(d, w);<br>
> <br>
> % Execute these blocks one at a time. The first should warn and the second <br>
> should not<br>
> figure<br>
> imagesc(d, w*t, ones(size(D)))<br>
> set(gca, 'YScale', 'log') % should warn<br>
> <br>
> figure<br>
> imagesc(d, 0.1+w*t, ones(size(D)))<br>
> set(gca, 'YScale', 'log') % should not warn<br>
> <br>
> <br>
>  <br>
> Steve Lord<br>
> slord@mathworks.com<br>
> To contact Technical Support use the Contact Us link on <br>
> <a href="http://www.mathworks.com">http://www.mathworks.com</a> <br>
<br>
So, is there a solution to make this work with imagesc, or is there another function that acts like imagesc and doesn't use corners to interpret the pixel color. Because pcolor and surf don't have this problem.<br>
<br>
Thanks,

Tue, 25 Jul 2017 17:28:09 +0000
Elas
https://se.mathworks.com/matlabcentral/newsreader/view_thread/349177#955495
Jimmy
Hi <br>
i kindly need some assistance in getting the principle directions from this stress matrix where i am to multiply it with nx,ny,nz matrix after using my 1st eigenvalue from a the stress matrix

Tue, 25 Jul 2017 15:49:06 +0000
Re: Divide char array into equal parts
https://se.mathworks.com/matlabcentral/newsreader/view_thread/349160#955494
mia saam
<br>
> What is the subsequent processing?<br>
> <br>
> <br>
I want to encrypt a block of text each time the algorithm should handle 16 byte but I'm having problems because using a char will force me to handle only 8 elements each time(16 bytes) and the results will also be doubled in size because of using hex2dec so I'm confused and don't know what to do or what to use

Tue, 25 Jul 2017 15:45:14 +0000
Re: Divide char array into equal parts
https://se.mathworks.com/matlabcentral/newsreader/view_thread/349160#955493
mia saam
"dpb" wrote in message <ol4p1u$rs$1@dontemail.me>...<br>
> On 07/23/2017 11:59 PM, mia saam wrote:<br>
> ><br>
> > I don't want to use reshape because when I call b(1) it will return only<br>
> > the first character not the 8 elements that I want to process ,<br>
> <br>
> Well, in that case you don't want a char() array at all but a cellstr or <br>
> the new string class. Or, use both things you don't want together... :)<br>
> <br>
> >> cellstr(reshape(a,8,[]).')<br>
> ans =<br>
> 'a24eac45'<br>
> '864def52'<br>
> >> whos ans<br>
> Name Size Bytes Class Attributes<br>
> <br>
> ans 2x1 152 cell<br>
> <br>
> >> cellfun(@disp,ans)<br>
> a24eac45<br>
> 864def52<br>
> >><br>
> <br>
> What is the subsequent processing?<br>
> <br>
> 

Tue, 25 Jul 2017 15:27:08 +0000
Report Generator locOpenDoc
https://se.mathworks.com/matlabcentral/newsreader/view_thread/349176#955492
Usmar Barrera
Recently, while using Matlab's Report Generator I encountered the following error when attempting to run my MLX file on the live editor.<br>
<br>
Error Using rptgen/docview>locOpenDoc (line 143)<br>
Could not open file "D:\data\Matlab\report\Q2\Report_61.docx"<br>
Invoke Error, Dispatch Exception:<br>
Source: Microsoft Word<br>
Description: Word encountered an error processing the XML file Report_61<br>
Unspecified error<br>
<br>
Location: Part: /word/document.xml, Line: 0, Column: 0<br>
Help File: wdmain11.chm<br>
Help Context ID: 63ee<br>
<br>
Error in rptgen/docview>locRunWordCommands (line 237)<br>
hDoc  locOpenDoc(fileName);<br>
<br>
Error in rptgen/docview (line 59)<br>
locRunWordCommands(fullFileName, varargin{:});<br>
<br>
Error in rptgen/rptview (line 116)<br>
rptgen.docview(fullFileName, 'updatedocxfields');<br>
<br>
Error in rptview (line 19)<br>
rptgen.rptview(fileName, varargin{:})<br>
<br>
I couldn't find anything online and I know that the code was right. So, the only thing that worked for me was to remove the Content Control from the word template and recreate it again. You can use the same name and the same properties. However, for whatever reason the report generator does not like certain "Holes". I figure this post may save some people some extremely precious time.<br>
<br>
<br>
Using: Matlab R2016b 64Bit Report Generator Statistics toolbox Word 2016<br>

Tue, 25 Jul 2017 15:17:08 +0000
How do I get function prototypes for PowerPoint macros called from MATLAB?
https://se.mathworks.com/matlabcentral/newsreader/view_thread/349175#955491
Michael
I am using the activex capability to control PowerPoint from MATLAB. I have written a couple VBA macros and saved them as a PowerPoint addin. I can successfully call some of those macros, but not others. It appears that I don't have the right functional form, but I'm not sure how to discover it when it's not obvious. <br>
<br>
For example, the VB function:<br>
Function triggerBoxFcn()<br>
needs to be called from MATLAB like this with an extra dummy argument (though I don't know why):<br>
ppt.Run('triggerBoxFcn',[]);<br>
yet this VB function:<br>
Function showBoxFcn(textStr As String)<br>
needs to be called without the extra argument:<br>
ppt.Run('showBoxFcn','This worked though :)');<br>
<br>
I can't figure out the MATLAB calling syntax for this VB function:<br>
Function getItemAdjustments(slideNum As Integer, shapeNum As Integer) As Variant<br>
<br>
Any suggestions on how to discover the correct calling syntax for a particular VB function? The full set of code and more details on what I've tried are here:<br>
https://www.mathworks.com/matlabcentral/answers/350190howdoigetfunctionprototypesforpowerpointmacroscalledfrommatlab

Tue, 25 Jul 2017 15:15:37 +0000
SPM 12 CAT 12
https://se.mathworks.com/matlabcentral/newsreader/view_thread/349174#955490
chama belkhiria
Hi Matlab community<br>
I had this message when using CAT 12 on SPM 12; I could not define the T or F contrast. <br>
Any help?<br>
<br>
Error using spm_conman (line 473)<br>
Error while evaluating UIControl Callback.

Tue, 25 Jul 2017 13:51:10 +0000
Re: fprintf error "function is not defined for 'cell' inputs.
https://se.mathworks.com/matlabcentral/newsreader/view_thread/349169#955489
dpb
On 07/24/2017 8:00 PM, Muhammad RSMY wrote:<br>
> how to solve the fprintf error "function is not defined for 'cell'<br>
> inputs" while using string<br>
<br>
It is so...cast to char() or dereference the cellstring content using <br>
the {} indexing to a character string.<br>
<br>
Not sure if TMW has done anything with the new STRINGS class to make it <br>
any simpler or not; don't have recentenough version here to test.<br>
<br>
There's an example "Export Cell Array Using fprintf" in the doc under <br>
the Data Import and Export heading...<br>
<br>


Tue, 25 Jul 2017 13:46:07 +0000
Re: fixing matlsab code error
https://se.mathworks.com/matlabcentral/newsreader/view_thread/349170#955488
dpb
On 07/25/2017 2:33 AM, Gebrehiwot Gebreyohans wrote:<br>
> Demand(GWH) %GDP Growth Population (10^6)<br>
> 1 4050 1.7526 10<br>
> 2 4127 1.3716 12<br>
> 3 4374 1.0668 15<br>
> 4 4637 1.143 20<br>
> 5 4915 2.3622 25<br>
> 6 5210 3.3528 30<br>
> 7 5722 4.191 35<br>
> 8 5854 5 37<br>
> 9 6504 6.1 39<br>
> 10 6600 6.5 42<br>
> 11 6604.5 6.5 45<br>
>>> input=[1.7526 10*10^6 4050;1.3716 12*10^6 4127;1.0668 15*10^6<br>
>>> 4374;1.143 20*10^6 4637;2.3622 25*10^6 4915;<br>
> 3.3528 30*10^6 5210;4.191 35*10^6 5722;5 37*10^6 5854;6.1 39*10^6<br>
> 6504;6.5 42*10^6 6600];<br>
> >>target=[ 4127 4374 4637 4915 5210 5722 5854 6504 6600 6604.5]';<br>
><br>
>>> net=newff(minmax([input,target]),[20 1],{'tansig','purelin'});<br>
><br>
>>> net=train(net,input,target);<br>
> Error using network/train (line 272)<br>
> Inputs and targets have different numbers of samples.<br>
> pls help me<br>
> how to fix the code error!<br>
> thanks<br>
<br>
You sure that's the same code that generated the error? There are 11 <br>
lines in the initial table but only 10 in the two arrays shown  maybe <br>
the actual code had the 11th entry in one but not the other would be <br>
first guess.<br>
<br>
BTW, _INPUT_ is a builtin Matlab function, better to use some other name <br>
for the variable.<br>
<br>


Tue, 25 Jul 2017 13:39:36 +0000
The centralization problem of gda
https://se.mathworks.com/matlabcentral/newsreader/view_thread/349173#955487
youan Li
Hello all,<br>
<br>
I found a gdatoolbox in GitHub and then use it to do the data classification. The problem is that the centralization is too low. Is there anyone who can help me?<br>
https://github.com/vjethava/svmtheta/blob/master/lib/SVMKM/gda.m<br>
<br>
Thanks,<br>
Youan