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

Tue, 27 Jun 2017 23:39:06 +0000
Re: fminsearch vs. fminunc
https://kr.mathworks.com/matlabcentral/newsreader/view_thread/118092#954864
Myrtle42
If anyone else stumbles over this question years later, as I did  I found this page useful as a broad overview of the many different optimization functions in matlab:<br>
https://www.mathworks.com/help/optim/ug/optimizationdecisiontable.html<br>
<br>
(not equivalent to understanding the algorthims, but a place to start)

Tue, 27 Jun 2017 19:42:05 +0000
how to append projection information to plain txt data?
https://kr.mathworks.com/matlabcentral/newsreader/view_thread/348915#954863
Christoph Macho
Hello, <br>
I would like to know if there is a possibility of adding projection information to plain text data points. i read out the raw log from a gps module and wrote them into a shapefile. no problem, but know i would like to add projection information to this shapefile best would be a .prj file, is there a posibility how to do that? the points are defined by EPSG:4326 now I would like to project them to EPSG:27700. Isn't there a function which holds information of the ESPG codes? <br>
Cheers christoph

Tue, 27 Jun 2017 17:37:11 +0000
Re: Multiple parameter fit using lsqcurvefit
https://kr.mathworks.com/matlabcentral/newsreader/view_thread/348913#954862
Alan Weiss
On 6/27/2017 12:34 PM, Hina86 wrote:<br>
> Hi,<br>
><br>
> I have been trying to fit my model with respect to the data obtained<br>
> from the experiments and i have tried using lsqcurvefit in Matlab. I<br>
> used the following tutorial as the basis for my fit:<br>
> https://de.mathworks.com/help/optim/ug/lsqcurvefit.html<br>
><br>
> On the basis of the above, I have generated the new script:<br>
><br>
> ydata=[15.00, 15.00, 17.69, 17.69, 17.69, 17.69, 17.83, 20.02, 23.00,<br>
> 25.00, 26.29, 26.63, 26.76, 26.82, 26.95, 26.95, 26.95, 26.95, 26.95,<br>
> 26.95, 26.95, 32.00, 33.00, 34.99, 35.65, 35.65, 35.65, 39.88, 40.00,<br>
> 46.91, 46.92, 46.92, 46.92, 46.93, 46.93, 46.93, 46.93 ];<br>
> xdata=[448772, 450067, 5038477, 1507006, 2505205, 470047, 1400021,<br>
> 212743, 2400000, 111156, 47141, 54605, 45598, 51941, 17719, 9873, 10151,<br>
> 10781, 8216, 15561, 20685, 15461, 49000, 7530, 5010, 8185, 3389, 6,<br>
> 16000, 285, 6, 374, 370, 195, 235, 545, 511];<br>
> fun =<br>
> @(y,ydata)((y(1)+abs(y(2))abs(2*y(3)*0*ydatay(1)+abs(y(2))))/(abs(2*y(4)*1*ydata)))^y(5);<br>
><br>
> y0 = [125,181,1,1,8.5];<br>
> y = lsqcurvefit(fun,y0,xdata,ydata);<br>
> times = linspace(ydata(1),ydata(end));<br>
> plot(xdata,ydata,'ko',times,fun(y,times),'b')<br>
> legend('Data','Fitted exponential')<br>
> title('Data and Fitted Curve')<br>
><br>
> When executing my new script, I always get an error stating:<br>
><br>
> "Error using lsqcurvefit (line 247)<br>
> Function value and YDATA sizes are not equal.<br>
><br>
> Error in SN_curvefit (line 18)<br>
> y = lsqcurvefit(fun,y0,xdata,ydata);"<br>
><br>
> Did I miss something? I shall be grateful if someone could explain, what<br>
> exactly the source of the error is.<br>
><br>
> Thanks in advacnce.<br>
<br>
fun(y0,xdata) should return a vector that is the same size as ydata. <br>
Instead, it returns a scalar.<br>
<br>
I suspect that the error arises in the / and ^ statements.<br>
You probably should have ./ and .^ instead.<br>
<br>
I am also troubled by your factor 2*y(3)*0*ydata, which yields zeros, <br>
having nothing to do with y(3). And I am disturbed by your use of ydata <br>
in your times vector, when I believe that you should be using xdata.<br>
<br>
Good luck,<br>
<br>
Alan Weiss<br>
MATLAB mathematical toolbox documentation

Tue, 27 Jun 2017 17:09:15 +0000
Re: fmincon error: Supplied objective function must return a scalar
https://kr.mathworks.com/matlabcentral/newsreader/view_thread/348905#954861
Alan Weiss
On 6/26/2017 1:29 PM, Alberto Grassi wrote:<br>
> Hi! I was minimizing a negative likelihood with 6 parameters and<br>
> everything was going well, but when I added a 7th parameter, then I<br>
> obtained the error :<br>
> Error using fmincon (line 609)<br>
> Supplied objective function must return a scalar<br>
> value.<br>
> This is what I am trying to minimize:<br>
*SNIP*<br>
<br>
><br>
> All went bad when i used w1 and w2 instead of only w. Can someone<br>
> explain me why?<br>
> Thanks in advance<br>
<br>
I cannot debug your function, because I do not see code for betapolyn2. <br>
I also do not see how you are calling fmincon, nor do I see your options.<br>
<br>
There are several possibilities. One is that your function is written <br>
inefficiently, because it always returns two outputs. It should return a <br>
second output only when it is called with the option that asks for the <br>
objective gradient (nargout > 1), as documented:<br>
https://www.mathworks.com/help/optim/ug/writingscalarobjectivefunctions.html#bsj1e55<br>
Because of this coding, it is possible that you get an error when you <br>
pass options unexpectedly.<br>
<br>
The more likely possibility is that when you use w1 and w2, your <br>
objective function is returning a vector value rather than a scalar <br>
value. Use the debugger to see what kind of value is being returned.<br>
https://www.mathworks.com/help/matlab/debuggingcode.html<br>
<br>
Sorry that I can't be more specific,<br>
<br>
Alan Weiss<br>
MATLAB mathematical toolbox documentation

Tue, 27 Jun 2017 16:43:05 +0000
filter bank
https://kr.mathworks.com/matlabcentral/newsreader/view_thread/348914#954860
Jing H
could you please help me how to use the 38 filters in filter bank RFS to filter ten images one by one? i want to transform the filters and image into Furier domain then convolute them. then transform the filtered 380 images back to spacial domain. <br>
I wrote a new function filterresponse to get the filtered image result. i used addpath to my new function. But i cant call RFS filter bank into my new function. <br>
<br>
thank you very much for help!!!<br>
<br>
<br>
function [ filterresponse ] = filter_response( )<br>
<br>
addpath('../Filter Bank');<br>
<br>
filters = makeRFSfilters;<br>
<br>
filterresponse = zeros(size(imgray{i},1),size(imgray{i},2),size(filters,3));<br>
<br>
for k=1:size(filters,3)<br>
s1=size(filters,1);<br>
s2=size(filters,2);<br>
pad1=floor(s1/2);<br>
pad2=floor(s2/2);<br>
imgray{i}=padarray(imgray{i},[pad1,pad2]);<br>
img_ft{i}=fft2(imgray{i});<br>
filters_ft{k}=fft2(filters,size(imgray{i},1),size(imgray{i},2));<br>
filterresponse(:,:,k)=img_ft{i}.*filter_ft{k};<br>
filterresponse(:,:,k)=iff2(img_res(i));<br>
figure;<br>
filterresponse(:,:,k)=img_res2(1+2*pad1,1+2*pad2:end)<br>
end;<br>
<br>
% imshow(grayim);<br>
%figure, imshow(filterresponse(:,:,k));<br>
end <br>

Tue, 27 Jun 2017 16:34:04 +0000
Multiple parameter fit using lsqcurvefit
https://kr.mathworks.com/matlabcentral/newsreader/view_thread/348913#954859
Hina86
Hi,<br>
<br>
I have been trying to fit my model with respect to the data obtained from the experiments and i have tried using lsqcurvefit in Matlab. I used the following tutorial as the basis for my fit:<br>
https://de.mathworks.com/help/optim/ug/lsqcurvefit.html<br>
<br>
On the basis of the above, I have generated the new script:<br>
<br>
ydata=[15.00, 15.00, 17.69, 17.69, 17.69, 17.69, 17.83, 20.02, 23.00, 25.00, 26.29, 26.63, 26.76, 26.82, 26.95, 26.95, 26.95, 26.95, 26.95, 26.95, 26.95, 32.00, 33.00, 34.99, 35.65, 35.65, 35.65, 39.88, 40.00, 46.91, 46.92, 46.92, 46.92, 46.93, 46.93, 46.93, 46.93 ];<br>
xdata=[448772, 450067, 5038477, 1507006, 2505205, 470047, 1400021, 212743, 2400000, 111156, 47141, 54605, 45598, 51941, 17719, 9873, 10151, 10781, 8216, 15561, 20685, 15461, 49000, 7530, 5010, 8185, 3389, 6, 16000, 285, 6, 374, 370, 195, 235, 545, 511];<br>
fun = @(y,ydata)((y(1)+abs(y(2))abs(2*y(3)*0*ydatay(1)+abs(y(2))))/(abs(2*y(4)*1*ydata)))^y(5);<br>
y0 = [125,181,1,1,8.5];<br>
y = lsqcurvefit(fun,y0,xdata,ydata);<br>
times = linspace(ydata(1),ydata(end));<br>
plot(xdata,ydata,'ko',times,fun(y,times),'b')<br>
legend('Data','Fitted exponential')<br>
title('Data and Fitted Curve')<br>
<br>
When executing my new script, I always get an error stating:<br>
<br>
"Error using lsqcurvefit (line 247)<br>
Function value and YDATA sizes are not equal.<br>
<br>
Error in SN_curvefit (line 18)<br>
y = lsqcurvefit(fun,y0,xdata,ydata);"<br>
<br>
Did I miss something? I shall be grateful if someone could explain, what exactly the source of the error is.<br>
<br>
Thanks in advacnce.

Tue, 27 Jun 2017 14:47:04 +0000
Re: print text to postscript/pdf
https://kr.mathworks.com/matlabcentral/newsreader/view_thread/173601#954858
Devraj Dutt
Hello Geoff,<br>
Did you manage? I am trying the same thing now without much luck and wanted to bring this thread back alive..<br>
Thanks!<br>
<br>
"Geoffrey" wrote in message <gsrlqc$pmg$1@fred.mathworks.com>...<br>
> The only problem is, how do I handle actual page formatting and other things? For example text wrapping or multiple pages?<br>
> <br>
> In principle it'd be simple to just define a listbox, and make my GUI a full sheet of paper and each line in the listbox is a line in the text. And I've done a quick test of that and it works just fine. But I need the flexibility of multiple pages without adding a lot of extra code (hence more debugging).<br>
> <br>
> <br>
> "Oliver Woodford" <o.j.woodford.98@cantab.net> wrote in message <gsmuit$6ef$1@fred.mathworks.com>...<br>
> > "Geoffrey" <geoffrey.bourque@ch.abb.com> wrote in message <gsmmb3$dga$1@fred.mathworks.com>...<br>
> > > Chris, <br>
> > > <br>
> > > Did you ever find a solution to this problem? I'm having the same problem now.<br>
> > > <br>
> > > Geoff<br>
> > <br>
> > You could generate a figure with some text in and print this to eps. Then use the eps file to create a template that you can just write your text into in the future.

Tue, 27 Jun 2017 14:24:05 +0000
RE: (no subject)
https://kr.mathworks.com/matlabcentral/newsreader/view_thread/29749#954857
Caleb Williams
Harry,<br>
<br>
Yes, you are correct. B=unique(A,'rows') will take all duplicate rows out of array A.<br>
Here's the official MathWorks article: https://www.mathworks.com/help/matlab/ref/unique.html

Tue, 27 Jun 2017 14:03:36 +0000
Re: Remove all spaces in string
https://kr.mathworks.com/matlabcentral/newsreader/view_thread/158554#954856
Bruce
On Tue, 27 Jun 2017 11:25:06 +0000, Debahuti Mandal wrote:<br>
<br>
> "Matt J" wrote in message <hmga8m$1sc$1@fred.mathworks.com>...<br>
>> "Lauren D" <ld@mathworks.com> wrote in message<br>
>> <fg8ljd$dq1$1@fred.mathworks.com>...<br>
>> > I have to remove all punctuation and spaces from a sentence.<br>
>> > I'm using a for loop and if statement to do the removal. Is there a<br>
>> > function to remove all spaces in a string? If not what is the<br>
>> > statement to check if a string location is ~= to a space? How do you<br>
>> > specify a space in a statement?<br>
>> ====================<br>
>> <br>
>> This might also help<br>
>> <br>
>> s='I''m a cowboy. On a steel horse, I ride.';<br>
>> <br>
>> >> regexprep(s,'[^\w'']','')<br>
>> <br>
>> ans =<br>
>> <br>
>> I'macowboyOnasteelhorseIride<br>
> <br>
> Is there a way to do the opposite example: input 'wedoneedthis' with the<br>
> output 'we do need this'?<br>
> <br>
> Thanks<br>
> <br>
> Deb<br>
<br>
probably not simple.<br>
<br>
How do you decide that it's 'we do need this' as opposed to 'wed one ed, <br>
this'. Both contain legitimate words, so a simple dictionary search <br>
doesn't work, both are (debatably) grammatically correct.<br>
<br>
Bruce

Tue, 27 Jun 2017 13:21:03 +0000
How to include a toolbox to the MCRenvironment?
https://kr.mathworks.com/matlabcentral/newsreader/view_thread/348912#954855
kees de Kapper
Dear all,<br>
<br>
I'm using the functions vrrotvec2mat and vrrotvec which are part of the sl3d  toolbox. When I compile my program to run using the MCR (deployedapp) apparently this toolbox is not included.<br>
<br>
How can I include a toolbox to the MCRenvironment? <br>
<br>
Many thanks in advance.<br>
<br>
All the best,<br>
Kees

Tue, 27 Jun 2017 12:25:04 +0000
problem with ifft
https://kr.mathworks.com/matlabcentral/newsreader/view_thread/348911#954854
charlotte bouquerel
hello<br>
I created this code. I don't really understand how to use properly IFFT. Indeed, It seems that I have my signal Cr back after all.. but with wrong axis. <br>
Does anyone knows how I should change my code ?<br>
<br>
Thanks !!<br>
<br>
Fs = 150; % Sampling frequency <br>
t = 0.5:1/Fs:0.5; % Time vector of 1 second <br>
n=length(t);<br>
w = .2; % width of rectangle <br>
<br>
Cr=rectpuls(t,w);%GenerateSquarePulse<br>
figure(1)<br>
plot(t,Cr); <br>
title('Créneau N°1'); <br>
xlabel('Time (s)'); <br>
ylabel('Amplitude');<br>
<br>
nfft = 2^nextpow2(n); % Length of FFT <br>
% Take fft, padding with zeros so that length(X) is equal to nfft <br>
TFCr = fft(Cr,nfft)./n; % FFT is symmetric, throw away second half <br>
TFCr = TFCr(1:nfft/2); % Take the magnitude of fftof x<br>
<br>
% Frequency vector <br>
f = (0:(nfft/2)1)*Fs/nfft;<br>
<br>
TFinvCr=ifft(ifftshift(TFCr,nfft)).*n;<br>
figure(3)<br>
plot(f,TFinvCr); <br>
title('Créneau 1 after ifft'); <br>
xlabel('Frequency (Hz)'); <br>
ylabel('Power')

Tue, 27 Jun 2017 11:58:03 +0000
Re: Polynomial is badly conditioned
https://kr.mathworks.com/matlabcentral/newsreader/view_thread/275526#954853
chiara dec
> <br>
> Where would I insert P,S and MU?<br>
> <br>
> Thanks<br>
<br>
<br>
You can find an example of the implementation at the end of this page:<br>
https://ch.mathworks.com/help/matlab/ref/polyfit.html<br>
<br>
hope it helps!

Tue, 27 Jun 2017 11:25:06 +0000
Remove all spaces in string
https://kr.mathworks.com/matlabcentral/newsreader/view_thread/158554#954852
Debahuti Mandal
"Matt J" wrote in message <hmga8m$1sc$1@fred.mathworks.com>...<br>
> "Lauren D" <ld@mathworks.com> wrote in message <fg8ljd$dq1$1@fred.mathworks.com>...<br>
> > I have to remove all punctuation and spaces from a sentence.<br>
> > I'm using a for loop and if statement to do the removal. Is<br>
> > there a function to remove all spaces in a string? If not<br>
> > what is the statement to check if a string location is ~= to<br>
> > a space? How do you specify a space in a statement?<br>
> ====================<br>
> <br>
> This might also help<br>
> <br>
> s='I''m a cowboy. On a steel horse, I ride.';<br>
> <br>
> >> regexprep(s,'[^\w'']','')<br>
> <br>
> ans =<br>
> <br>
> I'macowboyOnasteelhorseIride<br>
<br>
Is there a way to do the opposite example: input 'wedoneedthis' with the output 'we do need this'? <br>
<br>
Thanks <br>
<br>
Deb

Tue, 27 Jun 2017 11:15:05 +0000
Separating text strings in Matlab
https://kr.mathworks.com/matlabcentral/newsreader/view_thread/348910#954851
Debahuti Mandal
Hi, <br>
<br>
How do I design a process to turn a text string without spaces in to meaningful sentences? <br>
<br>
Example: input 'ihaveaquestionforyou' with the output ' i have a question for you' <br>
<br>
Any help would be greatly appreciated. <br>
<br>
Thanks :) <br>
Deb

Tue, 27 Jun 2017 08:25:05 +0000
Re: FOTF The CLASS function must be called from a class constructor error
https://kr.mathworks.com/matlabcentral/newsreader/view_thread/348889#954850
hossein
anyone can help me in this regard?<br>
<br>
"hossein" wrote in message <oij1ig$j9i$1@newscl01ah.mathworks.com>...<br>
> Dear friends<br>
> <br>
> I developed a cod by fractional order transfer function (FOTF); I run the code in my PC and it does work correctly, but when I send the code to the supervisor the error of The CLASS function must be called from a class constructor is accrued in his PC, I have send the code to one of other my friend, but the error of running the code is as the same, <br>
> So, I want to ask what is the problem and how can I overcome?