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

Tue, 17 Oct 2017 15:03:52 +0000
Re: Is it a rounding error?
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349585#956508
dpb
On 17Oct17 9:31 AM, Muhammad Abir wrote:<br>
> I understand there is a certain tolerance but this makes my life<br>
> difficult. I am trying to plot something and it gives me imaginary<br>
> number, something like this:<br>
> a= (z_arb+ sqrt(z_arb^2+ri^2))/2;<br>
> k1= 4*a= 1.1559; k2= 1.156;<br>
> Then I have sqrt(k1k2)= 0.0000 + 0.0100i but I expect it should be<br>
> zero. How can I correct this? This should correct automatically as k2 is<br>
> another function of something (but that's not important here).<br>
<br>
You're doing the rounding at the command line and causing the difference <br>
there...with your original post<br>
<br>
>> z_arb= 4000; ri= 68;<br>
>> a= (z_arb+ sqrt(z_arb^2+ri^2))/2;<br>
>> format long<br>
>> a<br>
a =<br>
0.288979122766705<br>
>> 4*a<br>
ans =<br>
1.155916491066819<br>
>><br>
<br>
So, when you round a to 0.289 and multiply by four, you've already <br>
rounded off to only three digits and subsequently the difference between <br>
internal an external representations are 4X what are to begin with.<br>
<br>
Why are you comparing this k1, and an external approximation k2 to begin <br>
with? Why not just keep the internal representation in its full <br>
precision and continue on your merry way? It's introducing that rounded <br>
value and then trying to compute the difference that is resulting in the <br>
sqrt() of negative number.<br>
<br>
It's not clear from what you've posted what you're trying to accomplish <br>
in the end, but it appears another formulation would be the solution.<br>
<br>
Show us what the real problem is you're trying to solve, not where you <br>
got stuck on what appears to be an artificiallyintroduced rounding problem.<br>
<br>


Tue, 17 Oct 2017 14:50:12 +0000
Re: Is it a rounding error?
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349585#956507
Muhammad Abir
Thanks all for your reply. <br>
<br>
I understand there is a certain tolerance but this makes my life difficult. I am trying to plot something and it gives me imaginary number, something like this: <br>
<br>
z_arb= 4000; ri= 68;<br>
a= (z_arb+ sqrt(z_arb^2+ri^2))/2; <br>
<br>
k1= 4*a= 1.1559; <br>
k2= 1.156; <br>
<br>
Then I have sqrt(k1k2)= 0.0000 + 0.0100i but I expect it should be zero. How can I correct this? This should correct automatically as k2 is another function of something (but that's not important here). <br>
<br>
Thanks, <br>
Muhammad Abir

Tue, 17 Oct 2017 14:31:09 +0000
Re: Is it a rounding error?
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349585#956506
Muhammad Abir
I understand there is a certain tolerance but this makes my life difficult. I am trying to plot something and it gives me imaginary number, something like this: <br>
<br>
a= (z_arb+ sqrt(z_arb^2+ri^2))/2; <br>
<br>
k1= 4*a= 1.1559; <br>
k2= 1.156; <br>
<br>
Then I have sqrt(k1k2)= 0.0000 + 0.0100i but I expect it should be zero. How can I correct this? This should correct automatically as k2 is another function of something (but that's not important here). <br>
<br>
Thanks, <br>
Muhammad Abir

Tue, 17 Oct 2017 06:45:11 +0000
Re: Iteration process for obtaining optimal values
https://www.mathworks.com/matlabcentral/newsreader/view_thread/346606#956505
Kwaku OwusuAnsah
Alan Weiss <aweiss@mathworks.com> wrote in message <nva318$j35$1@newscl01ah.mathworks.com>...<br>
> On 10/31/2016 4:37 PM, Kwaku OwusuAnsah wrote:<br>
> > Hi Guys,<br>
> ><br>
> > I am modelling the performance of a centrifuge. I have 6 variables:<br>
> > Inner radius of blades Inlet blades of height Outer radius of blades<br>
> > Outlet blades height Spiral angle Number of blades<br>
> > For the purpose of this task i have decided to keep the number of blades<br>
> > fixed at 5 to reduce the complexity of this problem. These variables<br>
> > determine the performance of my centrifuge. What I want to find out is<br>
> > the optimal combination of values my variables should take in order to<br>
> > produce the maximum desired output. In this case my output values based<br>
> > on my own calculations are:<br>
> ><br>
> > Outlet velocity Outlet Tangential Velocity Outlet flow angle Slip factor<br>
> > Outlet Tangential Velocity *<br>
> > Outlet flow angle*<br>
> > Inlet Tangential Velocity Outlet Tangential Velocity Inlet Normal Velocity<br>
> ><br>
> > My key performance indicators are velocity match (the difference between<br>
> > my absolute velocity and my velocity at entry to the diffuser) and my<br>
> > outflow disalignment ( difference between spiral angle and outlet flow<br>
> > angle). The differences in my two key values should be +/ 10%. How do I<br>
> > go about solving this problem? I know this involves partial differential<br>
> > calculus but i'm not sure how to translate this to matlab code.<br>
> > Any help would be very much appreciated.<br>
> <br>
> It sounds like a standard sort of optimization problem. Likely, you can <br>
> use fmincon from Optimization Toolbox.<br>
> <br>
> Formulate your problem with a 5dimensional variable x, where, say, x(1) <br>
> is the inner radius, x(2) is the inlet blade height, etc. You have to <br>
> create an objective function f(x), where f is a real variable that <br>
> measures the badness of your system with variables x, so you want to <br>
> minimize the badness. In addition, you have some constraints on x, such <br>
> as positivity, maybe being within certain ranges, and you have that <br>
> +10% constraint that I do not quite understand. Then fmincon can tell <br>
> you the x that minimizes the badness of the system.<br>
> <br>
> For an example, see <br>
> <a href="http://www.mathworks.com/help/optim/ug/examplenonlinearconstrainedminimization.html">http://www.mathworks.com/help/optim/ug/examplenonlinearconstrainedminimization.html</a><br>
> <br>
> Alan Weiss<br>
> MATLAB mathematical toolbox documentation<br>
<br>
<br>
<br>
Thanks!

Mon, 16 Oct 2017 19:52:31 +0000
Applying Lookup Table (LUT) matlab help!
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349587#956504
Sarah
Hi, so i've never really done one of these forum things so I'll explain as best as I can. I am taking an earth imaging class and we are looking at using a Lookup table (LUT) WITHOUT using the function intlut. This is only my second time using matlab so I have no idea what to do, even after large amounts of googling. Our instructions are:<br>
<br>
Write a Matlab function, convert_pix_lut.m, which applies a Lookup<br>
Table (LUT) pixel value transformation to a given image. <br>
<br>
The function will receive as input the following parameters:<br>
f  The input image<br>
n  The number of bits per pixel in  The input LUT values<br>
out  The output LUT values<br>
<br>
Based on these parameters, the function will convert the image f using the LUT values [in out] and return the converted image.<br>
<br>
Apply your function to the image stjohn.tif using the LUT in stjohn_LUT.mat and show the resulting image. Briefly describe what was the effect of the given LUT on the image.<br>
<br>
Please help!!!! Thank you!

Mon, 16 Oct 2017 18:08:45 +0000
Re: matlab programming
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349583#956503
barry.r.williams01@gmail.com
On Saturday, October 14, 2017 at 2:30:05 PM UTC4, simion wrote:<br>
> Hi All,<br>
> QUESTION<br>
> how to store data result to excel from an equation in matlab for a simulation<br>
> <br>
> <br>
> I want to know how can we write multiple data strings in the same excel sheet for a design simulation. As We know that whenever we specify xlswrite command it starts writing from cell A1 of the excel sheet.<br>
> <br>
> Now, my problem is I am carrying out a design calculation for a treatment works. At the end of the design calculation I am storing the variables in the excelsheet using xlswrite command. Now for a set of values of particular variable A , I want to do all the design calculations and then store them consecutively one calculation after the other in excel sheet in different rows. How can we do it. I tried to run for loop but it always stores the data in the first row of the excelsheet so only the last set of data is available through xlswrite statement.<br>
> <br>
> Program is a gui,the user will be prompted to enter values which will be calculated using different values of a and b and upon calculation the user will click a button to create an excel file and save the values for about 24 sessions<br>
> <br>
> a= handles.edit1;<br>
> <br>
> b= handles.edit 2;<br>
> <br>
> y = a^2 + b;<br>
> <br>
> then finally I use xls write to write all these variables in an excelsheet.<br>
> <br>
> Now for a range of values for variables and b I want y to be calculated 24 times and store them in the same excel sheet row wise. How can one do it . I would appreciate if someone comes up with a solution.<br>
> <br>
> Regards<br>
<br>
Look at help for xlswrite:<br>
xlswrite(filename,A,sheet,xlRange)<br>
<br>
Hint: xlswrite defaults to A1 if you don't specify the range, which is the last input variable above.<br>
<br>
Best,<br>
Barry

Mon, 16 Oct 2017 17:11:08 +0000
Re: EEG signal processingmatlab code
https://www.mathworks.com/matlabcentral/newsreader/view_thread/328008#956502
VENKATA PHANIKRISHNA B
Please provide the information about decomposing levels. here u are using 8. how to choose 8. Is there any relation between the sampling frequency and decomposition levels.

Mon, 16 Oct 2017 16:46:58 +0000
Re: random variable
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349586#956501
Nasser M. Abbasi
On 10/16/2017 11:28 AM, arash wrote:<br>
> why this program is not working? (the figure is empty)<br>
> N=100000;<br>
> p=[];<br>
> x=sign(rand(1,N).5);<br>
> n=rand(1,N);<br>
> for snrindb=10:1:10;<br>
> snr=10^(snrindb/10);<br>
> A=sqrt(snr*1*2);<br>
> y=A*x+n;<br>
> xhat=sign(y);<br>
> pe=sum(abs(xxhat))/2/N;<br>
> p=[p pe];<br>
> end<br>
> plot(snrindb,p)<br>
> <br>
<br>
<br>
Try<br>
<br>
plot(10:1:10,p)<br>
<br>
snrindb is just ONE number at the end, which is 10. So<br>
you were doing plot(10,p)<br>
<br>
ps. you should preallocate p[] before the loop.<br>
<br>
Nasser

Mon, 16 Oct 2017 16:28:42 +0000
random variable
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349586#956500
arash
why this program is not working? (the figure is empty)<br>
N=100000;<br>
p=[];<br>
x=sign(rand(1,N).5);<br>
n=rand(1,N);<br>
for snrindb=10:1:10;<br>
snr=10^(snrindb/10);<br>
A=sqrt(snr*1*2);<br>
y=A*x+n;<br>
xhat=sign(y);<br>
pe=sum(abs(xxhat))/2/N;<br>
p=[p pe];<br>
end<br>
plot(snrindb,p)

Mon, 16 Oct 2017 14:06:09 +0000
Re: Is it a rounding error?
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349585#956499
dpb
On 16Oct17 8:13 AM, Nasser M. Abbasi wrote:<br>
...<br>
<br>
>> where, z_arb= 4000; ri= 68; then a becomes 0.289.<br>
>> Now if I write 4*a in the command window, this becomes 4*a= 1.1559.<br>
>> But if I multiply 4*0.289 this should be 4*0.289= 1.156, not 1.1559.<br>
>><br>
>><br>
>> Could someone please explain why is that? Doesn't seem it's should do<br>
>> any rounding.<br>
...<br>
<br>
> try with format long.<br>
><br>
...<br>
<br>
>>> format long<br>
>>> a<br>
><br>
> a =<br>
><br>
> 0.288979122766705<br>
...<br>
<br>
<br>
Which illustrates what internal storage of a really is in higher <br>
precision of the output than default but not the "why" behind it.<br>
<br>
That's discussed at the <FAQ> at <br>
<<a href="http://matlab.wikia.com/wiki/FAQ#Why_is_0.3__0.2__0.1_.28or_similar.29_not_equal_to_zero.3F">http://matlab.wikia.com/wiki/FAQ#Why_is_0.3__0.2__0.1_.28or_similar.29_not_equal_to_zero.3F</a>><br>
<br>


Mon, 16 Oct 2017 13:13:23 +0000
Re: Is it a rounding error?
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349585#956498
Nasser M. Abbasi
On 10/16/2017 7:39 AM, Muhammad Abir wrote:<br>
> Hello,<br>
> <br>
> I got an interesting problem in Matlab 2017.<br>
> <br>
> I have the following equation:<br>
> <br>
> a= (z_arb+ sqrt(z_arb^2+ri^2))/2;<br>
> <br>
> where, z_arb= 4000; ri= 68; then a becomes 0.289.<br>
> Now if I write 4*a in the command window, this becomes 4*a= 1.1559.<br>
> But if I multiply 4*0.289 this should be 4*0.289= 1.156, not 1.1559.<br>
> <br>
> <br>
> Could someone please explain why is that? Doesn't seem it's should do any rounding.<br>
> <br>
> Thanks in Advance,<br>
> Abir<br>
> <br>
<br>
try with format long.<br>
<br>
>> z_arb= 4000; ri= 68; a= (z_arb+ sqrt(z_arb^2+ri^2))/2<br>
<br>
a =<br>
<br>
0.2890<br>
<br>
>> format long<br>
>> a<br>
<br>
a =<br>
<br>
0.288979122766705<br>
<br>
<br>
Nasser

Mon, 16 Oct 2017 12:58:44 +0000
Re: lsqnonlin nonlinear complex matrix equation
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349578#956497
Alan Weiss
On 10/13/2017 3:54 AM, mohammad bod wrote:<br>
> Dear friends<br>
> <br>
> I want to use 'levenbergmarquardt for solving a nonlinear matrix <br>
> equation.<br>
> the matrix equation is defined as follows:<br>
> f(X)= A.X^2 B^2 /  B  ^2<br>
> <br>
> and I wrote this equation in Mfile as follows :<br>
> function [F]=Fu_LVM(X,A,B)<br>
> <br>
> F= ( (abs(A*X)).^2  (B).^2 )/(norm(B)); ;<br>
> <br>
> and i have define the optimization as follows :<br>
> options = <br>
> optimoptions(@lsqnonlin,'Algorithm','levenbergmarquardt','Display','iter',... <br>
> <br>
> 'MaxIter',500);<br>
> <br>
> [Alpha_Sx,~,~,~,output] =lsqnonlin (@(X) Fu_LVM(X,A,B),...<br>
> ones(200,1).*1i,[],[],options );<br>
> <br>
> However, this optimization find a real Value for X while the global <br>
> minimum should be a complex value.<br>
> <br>
> dose any body have an idea about how to minimize this cost function with <br>
> lsqnonlin ?<br>
> <br>
> Your helps are highly appericated.<br>
As described in the documentation<br>
https://www.mathworks.com/help/optim/ug/complexnumbersinoptimizationtoolboxsolvers.html<br>
when you want a complex value for the minimum, use a complex value for <br>
the initial point.<br>
<br>
Alan Weiss<br>
MATLAB mathematical toolbox documentation

Mon, 16 Oct 2017 12:39:09 +0000
Is it a rounding error?
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349585#956496
Muhammad Abir
Hello, <br>
<br>
I got an interesting problem in Matlab 2017. <br>
<br>
I have the following equation: <br>
<br>
a= (z_arb+ sqrt(z_arb^2+ri^2))/2; <br>
<br>
where, z_arb= 4000; ri= 68; then a becomes 0.289. <br>
Now if I write 4*a in the command window, this becomes 4*a= 1.1559. <br>
But if I multiply 4*0.289 this should be 4*0.289= 1.156, not 1.1559. <br>
<br>
<br>
Could someone please explain why is that? Doesn't seem it's should do any rounding. <br>
<br>
Thanks in Advance, <br>
Abir

Sun, 15 Oct 2017 23:55:51 +0000
Re: NEWSREADER ASSASINATION
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349572#956495
dpb
On 15Oct17 4:25 PM, Paul wrote:<br>
...<br>
<br>
> I wonder if the reduction in news group activity correlates with when<br>
> Answers started up.<br>
<br>
Well, that was a big contributor to traffic loss, certainly, but usenet <br>
was passing away long before.<br>
<br>


Sun, 15 Oct 2017 21:25:09 +0000
Re: NEWSREADER ASSASINATION
https://www.mathworks.com/matlabcentral/newsreader/view_thread/349572#956494
Paul
"Bruno Luong" wrote in message <orn3b4$ogv$1@newscl01ah.mathworks.com>...<br>
> TMW sucks.<br>
> <br>
> Time to say good bye for all the folks we get to know each other from the exchange on the newsgroup. Thank you all. <br>
<br>
Interesting that the front page of the newsreader on matlab central is showing only three replies in this thread. Maybe the assassination has already started.<br>
<br>
My first reaction is disappointment. I quite like having all of the matlab related resources all in one site. Also, i find Answers somewhat limited in scope. It's marginally ok for howto type questions, but I can't imagine threads like the speed of the new graphics engine taking place over there.<br>
<br>
However, it's true that this newsgroup has been withering. Maybe one or two new posts a day lately.<br>
<br>
I wonder if the reduction in news group activity correlates with when Answers started up.