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

Thu, 19 Oct 2017 15:16:44 +0000
variable with truncate distribution  matlab
http://feedproxy.google.com/~r/mathworks/zAHF/~3/EFwbYJEcml0/349594
Tiago João Fazeres Ferradosa
Hi people,<br>
<br>
I need to generate random values of two variables in matlab:<br>
<br>
1 X has mean = 0.4 and std=0.05 but I want generate X with a lognormal distribution knowing that X belongs to [0.3;0.5]<br>
<br>
2 Y has mean 0.4 and std 0.2 I want it to follow a weibull distribution. Y belongs to [0;inf[<br>
<br>
I want to do this in matlab can someone help me please? <br>
Tiago<img src="http://feeds.feedburner.com/~r/mathworks/zAHF/~4/EFwbYJEcml0" height="1" width="1" alt=""/>
http://www.mathworks.com/matlabcentral/newsreader/view_thread/349594#956517

Thu, 19 Oct 2017 12:20:10 +0000
Re: need algorithm to reduction of noise from image
http://feedproxy.google.com/~r/mathworks/zAHF/~3/n5UbdWrZNhg/288965
Abubakar Sadiq
"Naeem" wrote in message <i3s7p9$bt0$1@fred.mathworks.com>...<br>
> Hello,<br>
> i am trying to remove mixed noise(gaussian and impulsive)from image and i really need an algorithm with filters for mixed noise along with a noise detection scheme.<br>
> If anyone could provide me with matlab code for such algorithm it would be a great help.<br>
> <br>
> I have two IEEE papers titled "A Universal Noise Removal Algorithm<br>
> With an Impulse Detector" and "Switching Bilateral Filter with a Texture/Noise Detector for Universal Noise Removal" if u have codes for these please help me out.<br>
> <br>
> thanks<br>
> Naeem<img src="http://feeds.feedburner.com/~r/mathworks/zAHF/~4/n5UbdWrZNhg" height="1" width="1" alt=""/>
http://www.mathworks.com/matlabcentral/newsreader/view_thread/288965#956516

Thu, 19 Oct 2017 01:55:09 +0000
where is the "helperFrequencyAnalysisPlot1.m" function?
http://feedproxy.google.com/~r/mathworks/zAHF/~3/MurP6mnpd4/349592
Baha411
For the example below when I type<br>
> edit('helperFrequencyAnalysisPlot1.m');<br>
<br>
It is asking if I wanna create that file and when I click yes it shows an empty file. Where is this "helperFrequencyAnalysisPlot1.m" file and why isn't this example working?<br>
<br>
I have 2016b version.<br>
<br>
% https://www.mathworks.com/help/signal/examples/practicalintroductiontofrequencydomainanalysis.html<br>
Fs = 44100;<br>
y = audioread('guitartune.wav');<br>
NFFT = length(y);<br>
Y = fft(y_data0,NFFT);<br>
F = ((0:1/NFFT:11/NFFT)*Fs).';<br>
magnitudeY = abs(Y); % Magnitude of the FFT<br>
phaseY = unwrap(angle(Y)); % Phase of the FFT<br>
edit('helperFrequencyAnalysisPlot1.m');<br>
helperFrequencyAnalysisPlot1(F,magnitudeY,phaseY,NFFT)<img src="http://feeds.feedburner.com/~r/mathworks/zAHF/~4/MurP6mnpd4" height="1" width="1" alt=""/>
http://www.mathworks.com/matlabcentral/newsreader/view_thread/349592#956514

Wed, 18 Oct 2017 20:13:29 +0000
Simscape  Switch with hysteresis example does not compile
http://feedproxy.google.com/~r/mathworks/zAHF/~3/1obKgisLDE/349589
Efim Sturov
Hi there,<br>
<br>
Want to ask for help some Matlab/Simscape professionals. I have designed recently a few Simscape hydraulic customs models (written in Simscape language). I can say that it was not too difficult. However, now I've came across one small issue with the "Switch with Hysteresis" example (https://au.mathworks.com/help/physmod/simscape/lang/delayedswitch.html). I need to design a valve that has two pressure flow characteristics at different thresholds.<br>
<br>
Pretty much I need to use this hysteresis structure for my new hydraulic block. The issue is that I can't compile (hence create) the switch model by using the presented code. It gives me "Unexpected MATLAB expression" in :modecharts(ExternalAccess = observe" line (compiling directly from a Simulink model via the block "Simscape component" . I can see in the help section that I need to also create the switching m file, but even with this file in a working folder I am still getting the same error all the time. Are there any suggestions how I can overcome it? Or maybe there are other options of modelling the hysteresis effect?<img src="http://feeds.feedburner.com/~r/mathworks/zAHF/~4/1obKgisLDE" height="1" width="1" alt=""/>
http://www.mathworks.com/matlabcentral/newsreader/view_thread/349589#956511

Wed, 18 Oct 2017 18:36:58 +0000
Re: Help!
http://feedproxy.google.com/~r/mathworks/zAHF/~3/bamVIWtaCAU/349588
Nasser M. Abbasi
On 10/18/2017 1:11 PM, Matt Stover wrote:<br>
> Hello, I am a beginner at MATlab and am somehow stuck on a problem for my intro to engineering class. I keep getting:<br>
> Error using *<br>
> Inner matrix dimensions must agree.<br>
> <br>
> Error in Class_15_App (line 20)<br>
> R=((p*V*D)/(U));<br>
> <br>
> Any help would be great!<br>
> <br>
> %% Problem 1<br>
> Name=input('What is you name?','s');<br>
> p=input('What is p (fluid density)?','s');<br>
> U=input('What is u (dynamic viscosity)?','s');<br>
> V=input('What is V (fluid velocity)?','s');<br>
> D=input('What is D (characteristic length)?','s');<br>
> R=((p*V*D)/(U));<br>
<br>
<br>
You need to use STR2DOUBLE to first convert the input which<br>
is supposed to be number to actual numerical values.<br>
<br>
The way it works, you are try to multiply chars of different<br>
lengths and Matlab complains.<br>
<br>
just write p=str2double(p); etc... for each value,<br>
and only then do R=((p*V*D)/(U)) then it should work<br>
<br>
Nasser<img src="http://feeds.feedburner.com/~r/mathworks/zAHF/~4/bamVIWtaCAU" height="1" width="1" alt=""/>
http://www.mathworks.com/matlabcentral/newsreader/view_thread/349588#956510

Wed, 18 Oct 2017 18:11:08 +0000
Help!
http://feedproxy.google.com/~r/mathworks/zAHF/~3/UB9hn3HPas0/349588
Matt Stover
Hello, I am a beginner at MATlab and am somehow stuck on a problem for my intro to engineering class. I keep getting:<br>
Error using * <br>
Inner matrix dimensions must agree.<br>
<br>
Error in Class_15_App (line 20)<br>
R=((p*V*D)/(U));<br>
<br>
Any help would be great!<br>
<br>
%% Problem 1<br>
Name=input('What is you name?','s');<br>
p=input('What is p (fluid density)?','s');<br>
U=input('What is u (dynamic viscosity)?','s');<br>
V=input('What is V (fluid velocity)?','s');<br>
D=input('What is D (characteristic length)?','s');<br>
R=((p*V*D)/(U));<br>
fprintf ('\n Name')<br>
<br>
fprintf ('\n Density=P')<br>
fprintf ('\n Viscosity=U')<br>
fprintf ('\n Velocity=V')<br>
fprintf ('\n Characteristic Length=D')<br>
<br>
fprintf ('\n The Reynolds number for this fluid flow is R')<img src="http://feeds.feedburner.com/~r/mathworks/zAHF/~4/UB9hn3HPas0" height="1" width="1" alt=""/>
http://www.mathworks.com/matlabcentral/newsreader/view_thread/349588#956509

Tue, 17 Oct 2017 15:03:52 +0000
Re: Is it a rounding error?
http://feedproxy.google.com/~r/mathworks/zAHF/~3/_kBVAxfa6cI/349585
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>
<img src="http://feeds.feedburner.com/~r/mathworks/zAHF/~4/_kBVAxfa6cI" height="1" width="1" alt=""/>
http://www.mathworks.com/matlabcentral/newsreader/view_thread/349585#956508

Tue, 17 Oct 2017 14:50:12 +0000
Re: Is it a rounding error?
http://feedproxy.google.com/~r/mathworks/zAHF/~3/hUAHVcYZYMk/349585
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<img src="http://feeds.feedburner.com/~r/mathworks/zAHF/~4/hUAHVcYZYMk" height="1" width="1" alt=""/>
http://www.mathworks.com/matlabcentral/newsreader/view_thread/349585#956507

Tue, 17 Oct 2017 14:31:09 +0000
Re: Is it a rounding error?
http://feedproxy.google.com/~r/mathworks/zAHF/~3/UdWzYAiidP0/349585
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<img src="http://feeds.feedburner.com/~r/mathworks/zAHF/~4/UdWzYAiidP0" height="1" width="1" alt=""/>
http://www.mathworks.com/matlabcentral/newsreader/view_thread/349585#956506

Tue, 17 Oct 2017 06:45:11 +0000
Re: Iteration process for obtaining optimal values
http://feedproxy.google.com/~r/mathworks/zAHF/~3/5XMIiWL80I/346606
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!<img src="http://feeds.feedburner.com/~r/mathworks/zAHF/~4/5XMIiWL80I" height="1" width="1" alt=""/>
http://www.mathworks.com/matlabcentral/newsreader/view_thread/346606#956505

Mon, 16 Oct 2017 19:52:31 +0000
Applying Lookup Table (LUT) matlab help!
http://feedproxy.google.com/~r/mathworks/zAHF/~3/Vseq6X3tiHw/349587
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!<img src="http://feeds.feedburner.com/~r/mathworks/zAHF/~4/Vseq6X3tiHw" height="1" width="1" alt=""/>
http://www.mathworks.com/matlabcentral/newsreader/view_thread/349587#956504

Mon, 16 Oct 2017 18:08:45 +0000
Re: matlab programming
http://feedproxy.google.com/~r/mathworks/zAHF/~3/2pepJ1n94Po/349583
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<img src="http://feeds.feedburner.com/~r/mathworks/zAHF/~4/2pepJ1n94Po" height="1" width="1" alt=""/>
http://www.mathworks.com/matlabcentral/newsreader/view_thread/349583#956503

Mon, 16 Oct 2017 17:11:08 +0000
Re: EEG signal processingmatlab code
http://feedproxy.google.com/~r/mathworks/zAHF/~3/LT6Ih6Xb4G4/328008
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.<img src="http://feeds.feedburner.com/~r/mathworks/zAHF/~4/LT6Ih6Xb4G4" height="1" width="1" alt=""/>
http://www.mathworks.com/matlabcentral/newsreader/view_thread/328008#956502

Mon, 16 Oct 2017 16:46:58 +0000
Re: random variable
http://feedproxy.google.com/~r/mathworks/zAHF/~3/1emZ2X1J0pA/349586
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<img src="http://feeds.feedburner.com/~r/mathworks/zAHF/~4/1emZ2X1J0pA" height="1" width="1" alt=""/>
http://www.mathworks.com/matlabcentral/newsreader/view_thread/349586#956501

Mon, 16 Oct 2017 16:28:42 +0000
random variable
http://feedproxy.google.com/~r/mathworks/zAHF/~3/5Zab7y9Scb4/349586
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)<img src="http://feeds.feedburner.com/~r/mathworks/zAHF/~4/5Zab7y9Scb4" height="1" width="1" alt=""/>
http://www.mathworks.com/matlabcentral/newsreader/view_thread/349586#956500