http://nl.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2016-07-29T21:44:22Ztag:nl.mathworks.com,2005:Question/2603872015-12-15T10:27:47Z2016-07-29T21:44:22ZHow to Extract High density pixels in a RGB Image?<p>How to Extract High density pixels in a RGB Image?</p>Selva Karnahttp://nl.mathworks.com/matlabcentral/profile/authors/4733665-selva-karnatag:nl.mathworks.com,2005:Question/2977282016-07-29T21:23:23Z2016-07-29T21:23:23ZIs it possible to install LEGO MINDSTORMS EV3 toolbox for Matlab silently using script?<p>I have Matlab 2016a installed on lab PCs. I want to install Lego MindStroms EV3 toolbox using a script on all of them. Is it possible to do it?</p>Nikhil Vementalahttp://nl.mathworks.com/matlabcentral/profile/authors/8480729-nikhil-vementalatag:nl.mathworks.com,2005:Question/2977272016-07-29T04:00:00Z2016-07-29T21:13:02ZHow can I name and display mux signals read on a real-time target scope?<p>How can I name and display mux signals read on a real-time target scope?</p>MathWorks Support Teamhttp://nl.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:nl.mathworks.com,2005:Question/2977192016-07-29T19:55:46Z2016-07-29T21:09:13ZHow to calculate the inter distance between consecutive random numbers?<p>dear MATLAB community,</p><p>I need to run 1000 iterations of 100 randomly generated synthetic events in space, and in time, and record the inter distances between all possible pairs, i.e.,.</p><p>1-2, 1-3, 1-4, 1-100, (space) and (time)</p><p>2-3, 2-4, 2-5, 2-100,</p><p>and so on eventually to 99 - 100</p><p>The plan is to run a students t test to compare the standard deviation of the synthetic events inter distances in space-time, against the inter distances in space-time for data collected from the field. We think spatial temporal clustering exists in our real world data and we want to find out if our data is statistically significant from clustering that can occur in a bunch of random numbers.</p><p>I am a MATLAB beginner, not shy of hard work, but I do not know how to write code. I'm wanting and willing to learn and would really appreciate any help with getting this sorted out in MATLAB,</p><p>Thank you very much in advance for any help that is offered,
R</p>Ricky Stevenshttp://nl.mathworks.com/matlabcentral/profile/authors/8365891-ricky-stevenstag:nl.mathworks.com,2005:Question/2977242016-07-29T20:33:40Z2016-07-29T20:58:35Zhow to put output of a function in diagonal of matrix<p>how would i have a function output become the diagonal of a matrix, for instance</p><pre> function y=f(x)
y= 3x+1;
end </pre><p>how do i put the output of this function as the diagonal of a matrix with 0s everywhere else.
i've attempted some type of for loop but it doesnt seem to work</p><p>i.e. the diagonal should have y(0), y(1), y(2),... y(n),</p><p>for different values of n</p>akayhttp://nl.mathworks.com/matlabcentral/profile/authors/8455279-akaytag:nl.mathworks.com,2005:Question/2971412016-07-25T23:49:34Z2016-07-29T20:58:08ZInterface dll missing error message from a Matlab compiled application<p>I have created a Windows application using the mcc compiler from 2013b. When I try to install it on machines that have already a later version of Matlab, 2016a, installed, my application cannot run and it gives the message "Interface dll missing". When the installation of my app is made to machines with Matlab 2013b, or no matlab at all, everything works fine.</p><p>Is there a trick that will fix this problem without having to change my 2013b compiler? I thought that by using mcc to bundle the application and installing it with the compatible mcr (2013b), my application was completely self sufficient and independent of anything else on the machine.</p>Nick B.http://nl.mathworks.com/matlabcentral/profile/authors/2025307-nick-btag:nl.mathworks.com,2005:Question/2977262016-07-29T20:57:11Z2016-07-29T20:59:18ZIntersection of two variable functions<p>Hello, I need to find intersection of two variable functions that are real and imaginary parts of complex function.</p><pre class="language-matlab">if true
%%close all;clear; clc
x1=sym('x1','real');
x2=sym('x2','real');
x=x1+1i*x2;
R=8;
S=1+1i;
Ck=0;
for k=20:-1:0
Ak=(k+1)*(k+1);
Bk=-k*(k+1)+1i*2*k*R;
Sk=Bk-(x)-(Ak*Ck)/S;
S=Sk;
Ck=-2*R-1i*2*R*k;
end
Sk(x1,x2)=Sk;
f1=real(Sk);
f2=imag(Sk);
ezplot(f1);
hold on;
ezplot(f2);
grid on;
end
</pre><p>I want to get this point coordinates if you can help me. Thanks.</p>Ts.Gamshttp://nl.mathworks.com/matlabcentral/profile/authors/4920046-ts-gamstag:nl.mathworks.com,2005:Question/2976772016-07-29T14:17:15Z2016-07-29T20:51:24ZHow to keep eigenvalues consistent between matrix iterations?<p>I have a 24x24 matrix evaluated at 8000 values of a parameter (frequency). I've found the complex eigenvalues using eig() at each of these iterations and stored them in an 8000x24 matrix, and then plotted the resulting curves. However, MATLAB doesn't keep successive values of the eigenvalues consistent, and due to the somewhat arbitrary ordering of the eigenvalues, the values jump around and leaves me with extreme discontinuities in the curves.</p><p>There's no set order I'm interested in in particular (e.g ascending, descending) but just as long as the eigenvalue at the (i+1)th iteration of frequency for eigenvalue j follows on smoothly from the eigenvalue at the ith iteration of frequency for eigenvalue j, and doesn't jump to one of the other 23 possible eigenvalues.</p><p>I hope this is clear what I'm asking. Also, I've tried using the eigenshuffle() function which helps slightly but still leaves the curves discontinuous in several places.</p><p>Many thanks</p>Joe Manchesterhttp://nl.mathworks.com/matlabcentral/profile/authors/8333138-joe-manchestertag:nl.mathworks.com,2005:Question/2977222016-07-29T20:31:52Z2016-07-29T20:46:15ZParallel Processing An Array/Array Appending<p>I'm attempting to store data in internal memory (an array) until I'm ready to export the data to an excel document. However, my current implementation slows down my program after a while as I'm consistently 'growing' the array by adding another array to the end of it.</p><p>This is my current implementation:</p><pre class="language-matlab">memoryArray = [memoryArray, arrayToAdd] (x6)
</pre><p>I'm wondering if it would be easy to implement parallel programming to do something like this:</p><pre class="language-matlab">%Psuedo Code
serial code...
serial code tell parallel process workers to start the following:
memoryArray1 = [memoryArray1, arrayToAdd1] %memoryArray is a global variable
memoryArray2 = [memoryArray2, arrayToAdd2]
memoryArray3 = [memoryArray3, arrayToAdd3]
memoryArray4 = [memoryArray4, arrayToAdd4]
memoryArray5 = [memoryArray5, arrayToAdd5]
memoryArray6 = [memoryArray6, arrayToAdd6]
serial code continues without waiting for results..
</pre><p>Is this possible to do? Perhaps my array manipulations are highly inefficient? I'm wondering if it might be as simple as using an spmd block... I apologize for the poorly written question. Thanks :)</p>Matthew Mellorhttp://nl.mathworks.com/matlabcentral/profile/authors/4592396-matthew-mellortag:nl.mathworks.com,2005:Question/2977152016-07-29T19:03:58Z2016-07-29T20:44:56ZGPS Time conversion from uint8 to decimal<p>I have the following GPS time in decimal as follows [65 31 163 67 100 90 28 172] and the data type is uint8. I need to write a matlab function as a block in Simulink to convert the time to the value 518352.848. Currently, the only way is to convert the data to hex and then back to decimal. As simulink does not accept char type, how can i do this conversion without going through the hex conversion?</p>Kelvin Wonghttp://nl.mathworks.com/matlabcentral/profile/authors/7183634-kelvin-wongtag:nl.mathworks.com,2005:Question/2977252016-07-29T04:00:00Z2016-07-29T20:43:01ZWhy am I unable to compile my Simulink Real-Time model to my Real-Time target with R2016a?<p>I am trying to run a Simulink model on my Simulink Real-Time target with R2016a. While it worked correctly in previous versions of Simulink Real-Time, with R2016a I receive an error message:</p><p> </p><pre class="error"> "mkusrdlm.exe has stopped working"</pre><p>What can I do to prevent this?</p>MathWorks Support Teamhttp://nl.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:nl.mathworks.com,2005:Question/2977232016-07-29T20:32:54Z2016-07-29T20:34:17Z2D images into a 3D stack of images<p>Hello All,</p><p>I have lot of 2D images and would like to stack them in a 3D volumetric cube and then plot it. I have written a code which is making a 3D array of it but I am not getting a correct plot of all the stack as a 3D cube.
My code is given below, please suggest the modification or idea by which I can plot the 3D cube as a stack of all the 2D images.</p><pre class="language-matlab">for i=100:259
% {} = cell array
images{i} = imread(sprintf('%d.png',i));
I{i} = (images{i});
end
</pre><pre class="language-matlab">myImage = cat(3,I{100:258});
image=myImage(:,:,1);
imagesc(image);
</pre><pre class="language-matlab">vector=reshape(image',numel(image),1);
X=ifft(image);
</pre><p>Although eventually the end result would need me to produce the inverse FFT of that stack. But, first concern is to produce the stack.</p>Rahul Thakurhttp://nl.mathworks.com/matlabcentral/profile/authors/8363428-rahul-thakurtag:nl.mathworks.com,2005:Question/2977212016-07-29T20:28:07Z2016-07-29T20:28:07ZHow to plot probability for specific value?<p>Hi,</p><p>I am trying to find probability for a given range. I have this formual d(0)=1-(d/d0)^k. I know the the range but I don't know how to plot this probability. I want to find probability of reception with respect to range. The plot should go exponential. But my plot is just plotting one dot. WHat should I do? Here is my code.
function r0=Sims( )
syms r r0 k d
r0=solve('1-(r/r0)^k=d','r0');
r=input('Enter the value of r');
d=input('Enter the value of d');
k=input('Enter the value of k');
r0 =r/exp(log(1-d)/k);
fprintf('\n the value of r0 %d\n',r0)
figure;
probplot(x,y)
xlim([0 100])
xlabel('Range(NM)')
title('Non-interference Probability')
end</p><p>Please help me. I am new to Matlab.</p>krishna kumarhttp://nl.mathworks.com/matlabcentral/profile/authors/8409250-krishna-kumartag:nl.mathworks.com,2005:Question/2976842016-07-29T14:53:57Z2016-07-29T20:25:41ZHow to create a decent looking report<p>Hi,</p><p>I'm having a lot of trouble creating a decent looking final report in Matlab. The, rather bad, way I'm currently doing it is to create a GUI window, 'print' that window, and then save that as an image or a PDF:</p><img src = "/matlabcentral/answers/uploaded_files/56941/5PNG.png"><p>This looks decent enough but has a lot of problems like the GUI refusing to be the size I set it as (namely A4 size, it automatically resizes to something that fits on the user's screen) and if the user's resolution or DPI is different to the one I have then, regardless of setting all the sizes in normalized units, boxes/text get moved around, squished, cut off, and it just looks bad in general.</p><p>I tried creating something similar using the included report generator in Matlab, but I could not figure out how to use the generator at all. Even the very first thing I tried, the title, proved to be impossible since I couldn't figure out how to center the text, or change its size, or remove the 'Chapter 1.' preface when using the chapter/section blocks.</p><p>Then I spent the entire week trying to make my current attempt using a GUI made with GUIDE work properly in different scenarios and made literally no progress whatsoever.</p><p>Today I messed around with the code publishing feature which made excellent pdf, word and html documents, but sadly was clearly not designed for my use case. Is there a way to use the code publisher's document creation features outside of the publisher? One idea I had was to just write all the values I want, like name, date, etc..., to a .m file using a function, then publish that .m, but that seems like a really hacky roundabout way of doing it.</p><p>Right now the only other option I can think of is to create a .tex template and have a function in matlab search through that template substituting in things like <b>PutNameHere</b> for the name, and inserting .png images into the tex code, then using the command line function to compile the modified tex template. But this means the user would have to install additional latex compilers too.</p><p>Is there really no decent way to create a good looking report in matlab, or am I just missing something? I quite like the layout of my stupid GUI-based report, but it doesn't produce the same report on computers with different screens and doesn't even have proper A4 dimensions.</p><p>Does anybody have any advice or is my best bet to write a function which searches through a .tex file, substitutes in bits of code and then compiles to pdf? Since that seems like a really stupid way to do it as well.</p><p>Thanks for any help,</p><p>Robert</p>Robert Roscahttp://nl.mathworks.com/matlabcentral/profile/authors/6235667-robert-roscatag:nl.mathworks.com,2005:Question/2977142016-07-29T18:45:04Z2016-07-29T20:12:25ZMatlab 2012b(32 bit) not able to find Microsoft Visual C++ 2012 compiler<p>I have Matlab 2014a(64 bit) and Matlab 2012b(32 bit) installed.
While running Mex -setup Matlab 2014a detects Microsoft Visual C++ 2012 compiler but Matlab 2012b didnt.</p><p>How can I make it detectable for 2012b version</p>Pranjalhttp://nl.mathworks.com/matlabcentral/profile/authors/4777635-pranjaltag:nl.mathworks.com,2005:Question/2977182016-07-29T19:47:12Z2016-07-29T20:04:56ZThe use of Nargin in Otsu Image Processing<p>I was actually given the full code to use from my professor and all I had to do was process it with a couple of photos. However I'm running into a few problems with the given code and I've tried to understand why it's not working but I think I could use some help. Here it is:</p><p>This is the function I think?</p><p>%Otsu Thresholding</p><p>% [ot,outim]=otsu_thresh(im)</p><p>% where im is the grey image (integer 0-255)</p><p>% Otsu Thresholding is performed on the image</p><p>% ot is the threshold determined</p><p>% outim is the image after thresholding</p><pre> if nargin<1
im=mean(double(imread('10um.jpg')),3);
else
if max(max(imread('10um.jpg')))<=1
im=round(im.*255);
end
end
[height,width]=size(im);
pixels=height*width;
bins=[0:255]+0.5;
N=hist(reshape(im,pixels,1),bins);
Nnorm=N/sum(N); %normalising the bin frequencies to make probabilities
theta=cumsum(Nnorm); %cumulative probability
mu=cumsum(Nnorm.*[0:255]);
%Repeat on the image
sigB2=(mu-mu(256)*theta).^2./(theta.*(1-theta)); %evaluate sigB2 over the t range
[p ot]=max(sigB2); %find the maximum value and the index where it is (this is the Otsu threshold)</pre><p>and this is the script im supposed to run:</p><p>x=(im>ot); %thresholding</p><p>figure(1)</p><p>imshow(x)</p><p>figure(2)</p><p>imshow(x)</p><p>hist(x);</p><p>(I believe there is 0 problems with the actual script just the function)</p>Michael Yabuthttp://nl.mathworks.com/matlabcentral/profile/authors/8480142-michael-yabuttag:nl.mathworks.com,2005:Question/2976092016-07-29T03:57:21Z2016-07-29T20:03:00ZWhat is the best way to work with large "Table" data type variables?<p>I find the "table" data type very useful and I would like to take advantage of its features when working with very large tables. Essentially, what I want to do is take a number of delimited text files, all with the same number of columns/variables, import each one as a table, and vertically concatenate them into one MATLAB table. The size of the tables presents a problem, as the files get very big, very fast. My initial thought was to use the "matfile" function, but it is not compatible with the table data type; you have to load the entire table variable to add rows to it, which defeats the purpose. As an example, if I have a .mat file called "test.mat" that contains a table variable called "table1," I cannot access it with "matfile."</p><pre class="language-matlab">m = matfile(test.mat,'Writable',true);
m.table1(1,1);
</pre><p>The second line produces an error:</p><pre class="language-matlab">The variable 'table1' is of class 'table'. To use 'table1', load the entire variable.
</pre><p>I used that example for simplicity, but the same error is generated if I attempt to add rows from a table
in the workspace to table1.</p><p>Is there a way to do what I want that does not require the entire table to be loaded? If the entire table has to be loaded, I imagine I'll run out of memory very quickly. I would also like to minimize the time required to process the data, so loading the entire table does not lend itself to that goal. It may well be that tables are not an option, but I wanted to ask to see if anyone else had any ideas. If I have to move away from tables, what would be the most efficient alternative?</p><p>Thanks,
Matt</p>Matthttp://nl.mathworks.com/matlabcentral/profile/authors/1460942-matttag:nl.mathworks.com,2005:Question/2977202016-07-29T19:57:02Z2016-07-29T19:58:38ZTrying to resample data in a uniform manner (with some twists)<p>I have a set of x and y coordinates that create a spline.</p><p>Image: <a href = "http://tinypic.com/view.php?pic=4k7kwk&s=9#.V5u0C-srLIU">http://tinypic.com/view.php?pic=4k7kwk&s=9#.V5u0C-srLIU</a></p><p>Currently, the coordinates that make up the spline are non-uniformly spaced in both x and y axes. How can I resample them so that there is uniform spacing? To be more specific, the coordinates are locations along a tube. I would love some way of defining the distance traveled along the tube so that I could specify a percent distance along the tube and it would translate to a specific length of the matrix.</p><p>I am familiar with the resample function, but it requires that there is a dependent (uniformly increasing) matrix is provided.</p><p>Thank you in advance.</p>Eric Dingeshttp://nl.mathworks.com/matlabcentral/profile/authors/5564924-eric-dingestag:nl.mathworks.com,2005:Question/2975542016-07-28T16:09:25Z2016-07-29T19:47:44ZHow can I plot the region for two inequalities?<p>I'm looking to plot the two inequalities for the formula:
abs(x+y+x.^2<3)
and
abs(y+x+y.^2<3)</p><p>with them both being on the same plot. How would I go about doing this please? Or any other similar example is fine.</p><p>Thanks in advance</p>Matthew Morrisonhttp://nl.mathworks.com/matlabcentral/profile/authors/7300299-matthew-morrisontag:nl.mathworks.com,2005:Question/2977172016-07-29T19:36:45Z2016-07-29T19:36:45Zfsolve: Index exceeds Matrix dimension<p>I am trying to solve a system of non-linear equations using fsolve. For that purpose I have defined a function "root2d" of the vector x (which shall represent 15 variables).</p><p>The first error I get is " <b>Index exceeds matrix dimensions</b>" with the addition that the error occurs when defining the 15th variable (i.e. vector element) - <b>"Error in root2d (line 19)
yd = x(15);"</b>. The error is not related to the specific variable but to the 15th position - for whatever reason.</p><p>Has anyone had this issue before? Do you have any clue what the reason for this could be?</p><p>For your reference there is my code below, the function (system of non-linear equations) as well as the fsolve referring to the function.</p><pre class="language-matlab">function F = root2d(x)
</pre><pre class="language-matlab">%defining the vector x of 19 endogenous input variables
</pre><pre class="language-matlab">c = x(1);
lambda = x(2);
r = x(3);
gammma1 = x(4);
f = x(5);
wstar = x(6);
Pistarw = x(7);
ld = x(8);
g1 = x(9);
mc = x(10);
g2 = x(11);
Pistar = x(12);
k = x(13);
x = x(14);
yd = x(15);
vp = x(16);
l = x(17);
vw = x(18);
Rbar = x(19);
</pre><pre class="language-matlab">%defining the parameters
</pre><pre class="language-matlab">delta = 0.025;
epsilon = 10;
eta = 10;
Phi = 0;
gammma2 = 0.001;
betta = 0.998;
h = 0.97;
varpsi = 8.92;
gammma = 1.17;
kappa = 9.51;
alppha = 0.21;
thetap = 0.82;
chi = 0.63;
thetaw = 0.68;
chiw = 0.62;
gammmaR = 0.77;
gammmay = 0.19;
gammmaPI= 1.29;
PIbar = 1.01;
rhod = 0.12;
rhophi = 0.93;
sigma_A = -3.97;
sigma_d = -1.51;
sigma_phi= -2.36;
sigma_mu= -5.43;
sigma_m = -5.85;
Lambdamu= 3.4e-3;
LambdaA = 2.8e-3;
LambdaYd= (LambdaA+alppha*Lambdamu)/(1-alppha);
Lambdaz = LambdaYd;
Lambdac = LambdaYd;
Lambdaw = LambdaYd;
</pre><pre class="language-matlab">%specifying the function
</pre><pre> F1 = (1-h*betta*Lambdaz)/((1-h/Lambdaz)*c)-lambda;
F2 = Rbar-(PIbar*Lambdaz/betta);
F3 = r-gammma1;
F4 = r-(1-(betta/(exp(Lambdaz)*exp(Lambdamu))))*(1-delta)/(betta/(exp(Lambdaz)*exp(Lambdamu)));
F5 = (1-betta*thetaw*exp(Lambdaz)^(eta-1)*PIbar^(-(1-chiw)*(1-eta)))*f-((eta-1)/eta)*wstar*lambda*PIstarw^(-eta)*ld;
F6 = (1-betta*thetaw*exp(Lambdaz)^(eta*(1+gammma))*PIbar^(eta*(1-chiw)*(1+gammma)))*f-varpsi*PIstarw^(-eta*(1+gammma))*ld^(1+gammma);
F7 = (1-betta*thetap*PIbar^((1-chi)*epsilon))*g1-lambda*mc*LambdaYd;
F8 = (1-betta*thetap*PIbar^(-(1-chi)*(1-epsilon)))*g2-lambda*PIstar*LambdaYd;
F9 = epsilon*g1-(epsilon-1)*g2;
F10= k/ld-(alppha/(1-alppha))*(w/r)*exp(Lambdaz)*exp(Lambdamu);
F11= mc-(1/(1-alppha))^(1-alppha)*(1/alppha)^alppha*w^(1-alppha)*r^alppha;
F12= (1-thetaw*PIbar^(-(1-chiw)*(1-eta))*exp(Lambdaz)^(-(1-eta)))/(1-thetaw)-PIstarw^(1-eta);
F13= (1-thetap*PIbar^(-(1-chi)*(1-epsilon)))/(1-thetap)-PIstar^(1-epsilon);
F14= c+x-yd;
F15= vp*yd-(exp(LambdaA)/exp(Lambdaz))*k^alppha*ld^(1-alppha)-Phi;
F16= l-vw*ld;
F17= (1-thetap*PIbar^((1-chi)*epsilon))*vp/(1-thetap)-PIstar^(-epsilon);
F18= (1-thetaw*exp(Lambdaz)^eta*PIbar^((1-chiw)*eta))/(1-thetaw)-PIstarw^(-eta);
F19= k-(exp(Lambdaz)*exp(Lambdamu)*x)/(x*exp(Lambdamu)-(1-delta));</pre><pre class="language-matlab">F = [F1; F2; F3; F4; F5; F6; F7; F8; F9; F10; F11; F12; F13; F14; F15; F16; F17; F18; F19];
--------------------------------------------------------------------------------------------------------------
------------------------------------------------SEPERATE CODE-------------------------------------------------
--------------------------------------------------------------------------------------------------------------
%initial guess
</pre><pre class="language-matlab">c0 = 0.40819;
lambda0 = 2.58777;
r0 = 0.0348988;
gammma10 = 1
f0 = 2.55673;
wstar0 = 1.13352;
PIstarw0 = 1.02002;
ld0 = 0.317845;
g10 = 7.64784;
mc0 = 0.89825;
g20 = 8.4976;
PIstar0 = 1.01869;
k0 = 2.71161;
x0 = 0.0884579;
yd0 = 0.496648;
vp0 = 1.00222;
l0 = 0.318814;
vw0 = 1.00305;
Rbar0 = 0;
</pre><pre class="language-matlab">x0 = [c0; lambda0; r0; gammma10; f0; wstar0; PIstarw0; ld0; g10; mc0; g20; PIstar0; k0; x0; yd0; vp0; l0; vw0; Rbar0]
</pre><pre class="language-matlab">fun = @root2d;
F = fsolve(fun,x0);
</pre>Daniel Bäumlerhttp://nl.mathworks.com/matlabcentral/profile/authors/7563724-daniel-baumlertag:nl.mathworks.com,2005:Question/2717952016-03-06T21:42:40Z2016-07-29T19:34:46ZHow to start Simulink model on Raspberry Pi automatically on startup?<p>I have built a Simulink model consisting of three blocks (Pulse generator + Data Type Conversion + GPIO Write) to flash a LED.</p><p>I loaded it onto the board, and the model ran normally from the computer in both normal and external modes. The LED was flashing. I stopped the Simulink model and unplugged the power and ethernet cables.</p><p>The Simulink model is converted into an executable that runs on the Raspberry Pi board. Typically, the executable is saved in the `/home/pi/Simulink_model_name_rtt/MW/Simulink_model_name` directory. The name of the executable is the same as the Simulink model name.</p><p>I ran the operating system of the Raspberry Pi via VNC viewer to execute the Simulink model that exists in MW folder. But the LED wasn't flashing.</p><img src = "/matlabcentral/answers/uploaded_files/46975/Captuddre.PNG"><p>Terminal from VNC viewer.</p><p>I went to Terminal from PuTTY to execute the Simulink model that exists in the MW folder. It returned the error:</p><pre> Error setting GPIO pin direction.</pre><img src = "/matlabcentral/answers/uploaded_files/46976/Capture.PNG"><p>Terminal from Putty.</p><p><b>*I want to run the Simulink model*</b> that has been loaded onto the Raspberry Pi board (after Raspberry Pi booting and startup) without running the Simulink model again on the computer via Ethernet connection.</p>Ahmed Desokyhttp://nl.mathworks.com/matlabcentral/profile/authors/6688823-ahmed-desokytag:nl.mathworks.com,2005:Question/2975422016-07-28T14:48:58Z2016-07-29T19:34:35ZHow to remove noise from strain data?<p>I am fairly new to DSP so I have no idea what am I doing after reading so many papers and stuff. I was given a set of strain data as shown below and asked to remove the noise in these data using MatLab.</p><p>As you can see the time is from 0 to 480 MSec and end at 0 for the last data. The total data collected is 1001.</p><img src = "/matlabcentral/answers/uploaded_files/56865/Capture.PNG"><p>Below is a plot of the first set of data in MatLab that i trying to use FFT to remove high frequency noises but I keep getting error and not sure how to do it. I tried following Youtube tutorial but I am not sure how to input my data into the script.</p><img src = "/matlabcentral/answers/uploaded_files/56866/untitled.jpg"><p>Can anyone teach or guide me how to remove noise in these data ? I don't know if FFT is a best method for noise removal but it seems to be one of the recommended technique from what I have read. Please advice.</p><p>My ultimate goal of my thesis is to develop a normalisation tool for SHM data with techniques such as regression analysis, neural network, novelty detection and more.</p><p>Any further information required in order to help, please ask me, I will provide as much information as I could. Thank you all so much.</p><p>Edit: Below shows a part of the waveform zoomed in.</p><img src = "/matlabcentral/answers/uploaded_files/56876/untitled1.jpg">Terence YEOhttp://nl.mathworks.com/matlabcentral/profile/authors/8476456-terence-yeotag:nl.mathworks.com,2005:Question/2255762015-06-27T15:27:16Z2016-07-29T19:33:09ZRaspi.m : Do we have the right code to connect with the Raspberry PI2 ?<p>I speak about the raspi.m version with date 13.02.2015</p><p>Some facts:</p><p>1. Raspi.m is unable to connect with a proper installed Raspbian wheezy with a running sshd and a running
MATLABserver. ping and external ssh-client (putty) function. firewall on windows (Windows 8.1) paused.</p><p>With rpi = raspi();</p><p>i get the error message:</p><pre class="language-matlab">"Error using raspi (line 153)
Error executing command: Die Syntax fr den Dateinamen, Verzeichnisnamen oder die Datentr„gerbezeichnung
ist falsch. "
</pre><p>Seems there is a problem with a filename, directory name etc. , not with the ip-address or the username or the password.</p><p>What is in line 153 of the raspi.m ?</p><pre class="language-matlab">connect(obj.Ssh, ['echo `pgrep MATLABserver` | sudo tee /tmp/.' hashKey]);
</pre><p>Is there an error in ?</p><p>I tried this code on the board and i got an output like "1616" (i think this is the hashKey).</p><p>My conclusion is now : the above code is unable to get this hashKey, thinks there is no running MATLABserver, stops further connection trials and delivers the above cited error code.</p><p>2. Trying Simulink-raspberry-examples :</p><p>Sendig the model to the Raspberry board livers:</p><p>a) the incoming (login etc.) and acception by the sshd can be read in the var/log/auth.log</p><p>b) but followed by a logout immediately</p><p>and the same error-code as above mentioned.</p><p>Conclusion: no problem with the login of the ssh-client ! the connection with the running MALABserver fails</p><p>These are my facts.</p><p>Now my questions.</p><p>1. Has someone got the same error-code and could not connect ?</p><p>2. What is the reaction of the matlab-support if he was informed ?</p><p>3. What is the solution / the work-around of the (i think: errornious) code in line 153 ?</p><p>Has someone a working solution ?</p><p>Summary: With the actual raspi.m and the actual raspian wheezy from the matlab-download (with the MATLABserver running in) i am not able to work with: worthless !!!. With working network etc. etc.</p><p>And i think it is a general problem with this connecting-code ; see above.</p><p>An update is needed !!!</p><p>Hope insiders, developpers etc. can give comments /answers immediately.</p><p>Kind regards</p><p>Walter Knell</p>Walter Knellhttp://nl.mathworks.com/matlabcentral/profile/authors/6521587-walter-knelltag:nl.mathworks.com,2005:Question/2973942016-07-27T15:07:44Z2016-07-29T19:32:44ZASIO audio driver with MATLAB 2016a<p>Hi everybody,</p><p>I want to use ASIO drivers with the DSP system toolbox in MATLAB2016a, however, it seems that the option in the preferences as in 2015 does not exist anymore. I use 'audioDeviceWriter' and one of the options is 'Driver' but it seems that I need the 'Audio System Toolbox' (not for free?!).
Is there a way to use ASIO drivers with MATLAB2016a without the need of external toolboxes like Psychtoolbox?</p><p>Best,
Axel</p>Axel Ahrenshttp://nl.mathworks.com/matlabcentral/profile/authors/5998459-axel-ahrenstag:nl.mathworks.com,2005:Question/2543132015-11-11T17:40:15Z2016-07-29T19:31:09ZRapberry Pi connection problem; Error raspi; Cannot establish a TCP/IP connection<p>I'm working on Matlab 2015a with support package for raspberry pi; Windows 7; Raspberry Pi 2 B</p><p>Rasbian Wheezy is downloaded from www.raspberrypi.org. Simulink (blinking led example) is working; Simulink (camera example) not; Writing programs in command window - not. The worst is that <b>raspi is not working</b>.</p><pre> mypi=raspi('192.168.0.12','pi','raspberry')</pre><pre class="language-matlab">Error using raspi (line 169)
Cannot establish a TCP/IP connection to the board with device address "192.168.0.12".
</pre><pre class="language-matlab">Caused by:
Error using raspi (line 165)
Cannot create a communication link with the remote server. Please
check the input arguments(ADDRESS and PORT) and make sure the server
is running.
Additional Information: Unable to connect, because
the target machine actively refused it.
</pre><p>Everything is connected properly, IP address checked in n-map; ping is working, putty working.</p><p>I tried downloading Raspian Wheezy also from Matlab. Than N-map cannot find raspberry in my network at all; test connection fails; tried SD card setup 3 times - all failes. Ack LED blinks around 5sec than stops, the other is solid red all the time.</p><pre class="language-matlab">Warning: Could not detect the Raspberry Pi hardware in allotted time.
Try using "Test Connection" button.
> In raspi.setup.RaspberryPiFirmwareUpdate/configureNetwork (line 404)
In raspi.setup.internal.executeRaspberryPiConnectHardware (line 38)
In hwconnectinstaller.Step/next (line 169)
</pre><p>and</p><pre class="language-matlab">>> mypi=rspi
Error using raspi (line 157)
Cannot establish an SSH connection to the board with device address
"raspberrypi-zuza".
</pre><pre class="language-matlab">Caused by:
Error using raspi (line 153)
Error executing command: Unable to open connection:
Host does not exist
</pre><p>Help!!!</p>Zuzannahttp://nl.mathworks.com/matlabcentral/profile/authors/5905670-zuzannatag:nl.mathworks.com,2005:Question/2977162016-07-29T19:25:41Z2016-07-29T19:31:50ZI use matlab to compile C++, and the result just give me a model not a function. What happens? give me this--- PDESystemSize: 40 Geometry: [] BoundaryConditions: [] Mesh: []<pre class="language-matlab">if true
#ifndef SLINE_H
#define SLINE_H
#include<cmath>
#include<mex.h>
#include<matrix.h>
class Sline{
private:
double arg;
double dist;
double stx;
double sty;
public:
Sline() = default;
Sline(const double a, const double b, const double c, const double d){
arg=a;
dist=b;
stx=c;
sty=d;
};
double angle(void){
return arg;
};
void setangle(double a){
arg=a;
};
double dis(void){
return dist;
};
void setdis(double b){
dist=b;
}
double startx(void){
return stx;
};
void setstx(double c){
stx=c;
}
double starty(void){
return sty;
};
void setsty(double d){
sty=d;
}
double endx(void){
return stx+dist*cos(arg);
};
double endy(void){
return sty+dist*sin(arg);
};
};
#endif
#include <mex.h>
#include <matrix.h>
#include <fstream>
#include <cstring>
#define pi 3.1415926
#define g 9.8065
#define sigma 75
#define delroe 9.80675e2
#define H0 -6.05
#define step 0.0000008
#include "sline.h"
#include <vector>
#include <cmath>
using namespace std;
void thetap(Sline & snplus, Sline & sn){
double a;
a =0.5*delroe*g*sn.endy()/sigma;
snplus.setangle(sn.angle() + (a + H0)*sn.dis());
snplus.setstx(sn.endx());
snplus.setsty(sn.endy());
}
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[]){
Sline init(0, step, 0, 0);
vector<Sline> a(1);
a[0] = init;
mexPrintf("good");
double ang =-40;
do{
Sline *c = new Sline;
c->setdis(step);
a.push_back(*c);
thetap(*(a.end() - 1), *(a.end() - 2));
} while ((a.end() - 1)->angle() * 180.00 / pi > (ang));
auto m = a.size();
plhs[0] = mxCreateDoubleMatrix(int(m), 1, mxREAL);
plhs[1] = mxCreateDoubleMatrix(int(m), 1, mxREAL);
double *outdataone = mxGetPr(plhs[0]);
double *outdatatwo = mxGetPr(plhs[1]);
for (int i = 0; i < int(m); i++)
{
outdataone[i] = a[i].startx();
outdatatwo[i] = a[i].starty();
}
}
end
</pre>jiahao zhanghttp://nl.mathworks.com/matlabcentral/profile/authors/7712683-jiahao-zhangtag:nl.mathworks.com,2005:Question/2970892016-07-25T16:00:23Z2016-07-29T19:18:32ZMDCS Is it possible to limit the number of workers a user can use per job?<p>I'm trying to find out how to tell MDCS to limit the total number of workers a user can request or receive. Finding nothing, or I'm terrible at searching. Anyone know if this is even possible?
Thanks!</p>Brance Amussenhttp://nl.mathworks.com/matlabcentral/profile/authors/7297769-brance-amussentag:nl.mathworks.com,2005:Question/2976022016-07-29T00:27:17Z2016-07-29T19:14:40ZSelecting data based on string contents<p>I am attempting to create a series of plots based on a variable set of inputs. Each plot would include multiple sets of data but the user may not necessarily have the same number of sets as I have for testing.</p><p>The data is set up in a manner similar to:</p><pre class="language-matlab">[Time Plot1-1 Plot1-2 Plot2-1 Plot2-2 Plot2-3;
0 1 2 3 4 5;
1 2 3 4 5 6;
2 3 4 5 6 7]
</pre><p>Using this sample, I would like to plot all the columns against time, but in two separate plots, Plot1 and Plot2.</p><p>Is there some kind of code I could use to look for similarities in the headers and have those sets plotted on the same plot?</p><p>Thanks</p>Parker Phillipshttp://nl.mathworks.com/matlabcentral/profile/authors/7983890-parker-phillipstag:nl.mathworks.com,2005:Question/2976602016-07-29T11:41:00Z2016-07-29T19:01:37ZFind Centroid of a rectangular mask<p>Four coordinates of a rectangle are given. I need to find the centroid of the area enclosed by the polygon.</p><p>Either provide the pixel values and coordinate values of all the pixels enclosed by the polygon
OR
Provide the centroid of the polygon directly.
Please help me out.</p>Bankim Chandra Yadavhttp://nl.mathworks.com/matlabcentral/profile/authors/7445251-bankim-chandra-yadavtag:nl.mathworks.com,2005:Question/2977072016-07-29T18:17:55Z2016-07-29T18:56:52Z\matlab\extern\include\matrix.h(604) : error C2143: syntax error : missing ')' before 'constant',what happen to this ?<pre class="language-matlab">#include <iostream>
#include <fstream>
#include <cstring>
#define pi 3.1415926
#define g 9.8065
#define sigma 75
#define delroe 9.80675e2
#define H0 -6.05
#define step 0.0000008
#include "sline.h"
#include <vector>
#include "mex.h"
#include <cmath>
using namespace std;
void thetap(Sline & snplus, Sline & sn){
double a;
a =0.5*delroe*g*sn.endy()/sigma;
snplus.setangle(sn.angle() + (a + H0)*sn.dis());
snplus.setstx(sn.endx());
snplus.setsty(sn.endy());
}
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[]){
Sline init(0, step, 0, 0);
vector<Sline> a(1);
a[0] = init;
double ang = mxGetScalar(prhs[0]);
do{
Sline *c = new Sline;
c->setdis(step);
a.push_back(*c);
thetap(*(a.end() - 1), *(a.end() - 2));
} while ((a.end() - 1)->angle() * 180.00 / pi > ang);
auto m = a.size();
plhs[0] = mxCreateDoubleMatrix(int(m), 1, mxREAL);
plhs[1] = mxCreateDoubleMatrix(int(m), 1, mxREAL);
double *outdataone = mxGetPr(plhs[0]);
double *outdatatwo = mxGetPr(plhs[1]);
for (int i = 0; i < int(m); i++)
{
outdataone[i] = a[i].startx();
outdatatwo[i] = a[i].starty();
}
}
</pre>jiahao zhanghttp://nl.mathworks.com/matlabcentral/profile/authors/7712683-jiahao-zhangtag:nl.mathworks.com,2005:Question/187952011-10-20T06:04:53Z2016-07-29T18:53:46ZHow to recostruct ROI on an image and diaplay it? <p>dear friends,
I hav got a set of co ordinates of an ROI. Now i want to reconstruct the ROI on an image and display it. How can i do this? plz help....</p>Pramod Bhathttp://nl.mathworks.com/matlabcentral/profile/authors/1452235-pramod-bhattag:nl.mathworks.com,2005:Question/2977122016-07-29T18:35:54Z2016-07-29T18:52:00ZFastest alternative to |y = ones(size(x))| ?<p>The profiler red flagged this line, in a small function that is called by an inner-loop computation:</p><pre class="language-matlab">...
if n == 0
y = ones(size(x));
else if n == 1
...
end
</pre><p>I must clarify that this line is <b>not just pre-allocation!</b> I really need the variable <tt>y</tt> to be the same shape as <tt>x</tt> and hold <tt>1</tt> in each element. Ideally <tt>x</tt> can be of any dimensions but if pressed I will admit it is unlikely to be anything but a scalar, vector, or 2D matrix.</p><p>I can think of so many possible alternatives, and the practical problem is mostly solved, so this question is mostly for curiosity's sake. I am interested in the fastest method and also in the analysis of why it is fastest. Any ideas?</p><p>Thanks,
-naor</p>Naor Movshovitzhttp://nl.mathworks.com/matlabcentral/profile/authors/482202-naor-movshovitztag:nl.mathworks.com,2005:Question/2970922016-07-22T04:00:00Z2016-07-29T18:43:19ZHow do I incorporate MATLAB code into Simulink?<p>How do I incorporate MATLAB code into Simulink? I would like to put my existing MATLAB algorithm into a Simulink block.</p>MathWorks Support Teamhttp://nl.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:nl.mathworks.com,2005:Question/2977112016-07-29T18:33:17Z2016-07-29T20:13:18ZHow to stop for loop with a different command?<pre class="language-matlab">classdef compute<handle
properties
%Properties go here
width;
height;
s;
end
</pre><pre> properties(Access = private)
nComputedPerimeter;
end</pre><pre> methods
%methods go here
%Defining a costructor</pre><pre> function obj = compute(w,h)
if(nargin>0)
obj.width = w;
obj.height = h;
obj.s=0;
end</pre><pre> end</pre><pre> function p = compute_perimeter(obj,li)</pre><pre> p=2*(obj.width+obj.height);
obj.s=li;
notify(obj,'ComputePerimeter');</pre><pre> end</pre><pre> function scale(obj,n)
obj.width = n*obj.width;
obj.height = n*obj.height;
end</pre><pre> function track_perimeter_method(obj)
obj.nComputedPerimeter = 0;
addlistener(obj,'ComputePerimeter',@compute.update_nComputedPerimeter);
end</pre><pre> function print_tracking_info(obj)
fprintf('The '' get_perimeter '' function has been called %i times.\n',obj.nComputedPerimeter);
end</pre><pre> end</pre><pre> methods(Static)</pre><pre> function update_nComputedPerimeter(obj,~)
% obj.nComputedPerimeter = obj.nComputedPerimeter+1;</pre><pre> if(obj.s==0)
for i=1:10
pause(0.5)</pre><pre> fprintf('%d\n',i);
end
else
lp=6;
fprintf('%d\n',lp);</pre><pre> end</pre><pre> end</pre><pre> end</pre><pre> events
ComputePerimeter</pre><pre> end</pre><pre class="language-matlab">end
</pre><p>This is the code to type in Command Window</p><pre class="language-matlab">c=compute(3,2)
c.track_perimeter_method
c.compute_perimeter(0)
c.compute_perimeter(1)
</pre><p>So, when I type c.compute_perimeter(1), the program should quit. The program keeps running and then when it ends, c.compute_perimeter(1) is executed.Is there a way I can stop the execution of code when I press c.compute_perimeter(1) and do not run anything.</p>Mafuzal Hoquehttp://nl.mathworks.com/matlabcentral/profile/authors/6571004-mafuzal-hoquetag:nl.mathworks.com,2005:Question/2974192016-07-27T18:07:21Z2016-07-29T18:31:19ZListbox and Pushbutton in GUI<p>I have a listbox(tag:listbox) that gives different choices of plotting(axes tag:plotty), and a pushbutton(tag: NextButton) called "next" which execute the choice that the listbox made.
My code in GUI looks something like this:</p><pre class="language-matlab">%some code
handles.i = 1;
handles.k = length(files);
handles.files = files;
guidata(hObject, handles);
</pre><pre class="language-matlab">% --- Executes on selection change in plotbox.
function listbox_Callback(hObject, eventdata, handles)
files = handles.files;
i=handles.i;
axes(handles.plotty);
listbox_index=get(hObject, 'Value');
switch listbox_index
case 1
[data,~,~] = xlsread(files{i});
x = 1:6;
plot(x, data(1:end))
case 2
[data,~,~] = xlsread(files{i});
x = 2:7;
plot(x, data(1:end))
case 3
[data,~,~] = xlsread(files{i});
x = 4:9;
plot(x, data(1:end))
end
</pre><pre class="language-matlab">% --- Executes on button press in NextButton.
function NextButton_Callback(hObject, eventdata, handles)
if handles.i < handles.k
handles.i = handles.i + 1
listbox_Callback(hObject, eventdata, handles);
else
handles.i=1
end
</pre><pre class="language-matlab">guidata(hObject, handles)
</pre><p>After some fig test run, the GUI is able to run but not correctly---it seems that my listbox function and pushbutton works separately.</p><p>No matter which choice I made in the listbox. The pushbutton automatically execute whats in listbox function case 1, and never goes to case 2 and 3.</p><p>I would like to fix the code, any clue is appreciated. Thank you!!</p>chlor thankshttp://nl.mathworks.com/matlabcentral/profile/authors/8383523-chlor-thankstag:nl.mathworks.com,2005:Question/1410252014-07-08T22:54:58Z2016-07-29T18:27:40ZThe current folder window<p>I close the current folders window by mistake,</p><p>how can I re display it ?</p><p>.
.</p>Fatima Al Marzoqihttp://nl.mathworks.com/matlabcentral/profile/authors/5430873-fatima-al-marzoqitag:nl.mathworks.com,2005:Question/2972882016-07-26T20:39:41Z2016-07-29T18:24:21ZI need a code to solve this problem<p>The budget to be shared is 40.5;
The participant initially gets the following amount</p><pre class="language-matlab">v1= 7;
v2=10.5
v3= 13
v(1,2)= 28
v(1,3)=28
v(2,3)=28
v(1,2,3)=40.5
</pre><p>v1,v2 and v3 should get an amount greater 7, 10.5,13 respectively and the total should be equal to 40.5</p><p>At the same time the this conditions should be satisfied as well v1+v2 >=28 ; v1+v3 >=28 ; v2+v3 >=28</p>Jeffrey Eiyikehttp://nl.mathworks.com/matlabcentral/profile/authors/7113348-jeffrey-eiyiketag:nl.mathworks.com,2005:Question/2977102016-07-29T18:22:23Z2016-07-29T18:22:23Z NaN performance and gradient in RNN<p>Hello to everyone! I'm trying to run a recurrent neural network, performing something slightly different from usual, that is time series classification, instead of prediction. By doing this, I present to the rnn same length series. If this last is not as long as the input size, I add NaN values, as usual. Then, as I care about the outcome of the rnn only at certain time step, I put NaN values in error weights related to all the others (I forgot to tell I'm running a concurrent input analysis). The learning process of the rnn starts, but during the process you can see performance and gradients bars show a NaN, intead of numerical values. At the end of learning, you're consequently not able to visualize the performance plot. Do someone know how to manage these situations?</p>Francesco Semerarohttp://nl.mathworks.com/matlabcentral/profile/authors/7533485-francesco-semerarotag:nl.mathworks.com,2005:Question/2977092016-07-29T18:22:11Z2016-07-29T18:22:11Zinitialising variable in embedded function<p>Hello,</p><p>my model function contains three embedded function Matlab connected in cascade, the output of the last one: (s) is fed back as an input in the first.</p><p>So to simulate the model (s) must be firstly initialized to run the model in the first time and then the value (s) change with each iteration.</p><p>I had had try to use coder.nullcopy, and initialise (s) in init.m than run model, but it is still not considered the initial guess of (s).</p><p>I would greatly appreciate any sort of guidance in solving this problem.</p><p>Thank you.</p>studentUhttp://nl.mathworks.com/matlabcentral/profile/authors/6410228-studentutag:nl.mathworks.com,2005:Question/2977082016-07-29T18:21:50Z2016-07-29T18:49:55ZUsing Consolidator with Zeros<p>Using <a href = "https://www.mathworks.com/matlabcentral/fileexchange/8354-consolidator">Consolidator</a> with a vector comprised of whole number values ranging from 0 to 23 (hourly time code), I get an output vector with 23 values (not 24 as expected), with the first three being:</p><p><b>0.5122, 2, 3 ...</b></p><p>They should be:</p><p><b>0, 1, 2 ...</b></p><p>Code is as follows:</p><pre class="language-matlab">[hourdC, OCS_d41C]=consolidator(hourd, OCS_d41, 'nanmean', 1);
</pre><p>My suspicion is that <a href = "https://www.mathworks.com/matlabcentral/fileexchange/8354-consolidator">Consolidator</a> is processing the zeros in an unexpected way or that I need a different function other than nanmean in there.</p><p>Thanks for the help.</p>balsiphttp://nl.mathworks.com/matlabcentral/profile/authors/7071705-balsiptag:nl.mathworks.com,2005:Question/2977002016-07-29T16:58:01Z2016-07-29T18:16:04ZHow can I read many netcdf files with complex names by using loop in MATLAB?<p>Hello Guys,</p><p>I would like to read many Netcdf files with this type of names:</p><p>3B-HHR.MS.MRG.3IMERG.20140401-S000000-E002959.0000.V03D.HDF5.nc?precipitationCal[960:969][986:992],lat[986:992],lon[960:969]</p><p>3B-HHR.MS.MRG.3IMERG.20140401-S003000-E005959.0030.V03D.HDF5.nc?precipitationCal[960:969][986:992],lat[986:992],lon[960:969]</p><p>3B-HHR.MS.MRG.3IMERG.20140401-S010000-E012959.0060.V03D.HDF5.nc?precipitationCal[960:969][986:992],lat[986:992],lon[960:969]</p><p>As you see the first number shows the date 20140401 and then time in order to hour, minute and second.</p><p>I need to use a loop to read them in order to sorting time!!</p><p>these three files as a sample are attached.</p><p>Thank you in advance for considering this question.</p><p>Regards,</p>ehsan http://nl.mathworks.com/matlabcentral/profile/authors/4483511-ehsantag:nl.mathworks.com,2005:Question/2977062016-07-29T18:16:03Z2016-07-29T18:18:05ZHow to identify gold color in image?<p>Hello. I'm Thiyraash.I'm newbie for Matlab.I have an assignment regarding coin recognition. My country's coins consist of two color gold and silver. Can i know how to identify the gold color. I managed crop each coin from images consist of few coins. I wan to know how to identify gold color coin. Convert rgb to hsi than get the hue and saturation value of the cropped coin image than if its hue and saturation value in the range of gold's hue and saturation than it is gold coin. This what my lecture suggested but i have no idea how to implement it. Can you help me?</p><img src = "/matlabcentral/answers/uploaded_files/56959/coin3.jpg">Raash Visionhttp://nl.mathworks.com/matlabcentral/profile/authors/8400288-raash-visiontag:nl.mathworks.com,2005:Question/395692012-05-27T20:41:15Z2016-07-29T18:00:07ZCBIR code in matlab<p>Hi every one!
I found a project on CBIR coded in matlab and when i go to see its source code (*.m files) there is nothing but strange text which is illegible. Also the project isn't runnable.
you can see the code here <a href="http://code.google.com/p/cbir-in-matlab/">http://code.google.com/p/cbir-in-matlab/</a>
plz help i need to go through the code because you have to read good code to write good one.
v8ing 4 reply.</p>zainhttp://nl.mathworks.com/matlabcentral/profile/authors/3451774-zaintag:nl.mathworks.com,2005:Question/2976882016-07-29T15:19:31Z2016-07-29T17:59:12ZCannot download the content of parallel toolbox after purchasing it<p>I cannot download Parallel Toolbox after purchased it, it still shows "BUY" on the page of the Add-On</p>Hang Cheunghttp://nl.mathworks.com/matlabcentral/profile/authors/8317599-hang-cheungtag:nl.mathworks.com,2005:Question/2976012016-07-28T23:45:50Z2016-07-29T17:58:36Zunder one condition, how to select the value with possibility?<img src = "/matlabcentral/answers/uploaded_files/56912/m.png"><p>Hi, I'm learning matlab, I don't know how to edit the code when adding a condition. The whole process is in the picture.</p><p>I search the forum, and the code without the beginning condition would be like this:</p><pre class="language-matlab">x=random
if x<0.8
select=1
else
select=0
if select=1
event happen
if select=0
event not happen
end
</pre><p>But if I want to add the beginning condition, how could I edit the code?</p><p>Thanks.</p><p>M.W.</p>Mengke Wuhttp://nl.mathworks.com/matlabcentral/profile/authors/8364871-mengke-wutag:nl.mathworks.com,2005:Question/2955102016-07-13T21:12:22Z2016-07-29T17:58:10Z3D Slices smoothing<p>Hi I want to create a 3D object out of the 2D slices I created. I am able to stack them all but not getting a smooth 3D object I am attaching the picture.Please let me know of a way to better demonstrate it and look inside the object. Currently I am doing it with</p><pre class="language-matlab">slice(3d, [], [], 1:0.1:size(3d,3));
</pre><p>This makes the edges pretty thick and I am not able to get it as one 3D object.
Any suggestions will be highly helpful.</p>Farhad Ahmad Qureshihttp://nl.mathworks.com/matlabcentral/profile/authors/7723332-farhad-ahmad-qureshitag:nl.mathworks.com,2005:Question/2976952016-07-29T15:55:58Z2016-07-29T17:55:18Ztable variable name based on array<p>Hi, is it possible to assign table variable name based on strings in an array. For example:</p><pre class="language-matlab">colnames={'a' 'b'};
a=[1;2];
b=[3;4];
c=table();
c.colnames{1}=a;
c.colnames{2}=b;
</pre><p>Thank you.</p>Azura Hashimhttp://nl.mathworks.com/matlabcentral/profile/authors/8418427-azura-hashimtag:nl.mathworks.com,2005:Question/2976722016-07-29T13:34:35Z2016-07-29T17:54:47Zhow to discretize second order fractional derivative on x to use in ode solver?<p>All Dear
I want to discretize a second order fractional derivative in the form of "(d^2 ((f(x))/(g(x))))/(dx^2 )" on x to use in ode solver.
According to the definition of second order derivatives,
Can i discretize it simply as follow:</p><p>(d^2 ((f(x))/(g(x))))/(dx^2 )=((f(x+h))/(g(x+h))-2 f(x)/g(x) +(f(x-h))/(g(x-h)))/h h~0</p><p>or require to use fractional derivative formula ? (d(u/v)=(u*dv-v*du)/v^2)</p>Johnhttp://nl.mathworks.com/matlabcentral/profile/authors/8407466-johntag:nl.mathworks.com,2005:Question/2974112016-07-27T17:34:49Z2016-07-29T17:54:17Zhow would i create a loop within a loop<p>for example, if I had 3 functions say, alpha, beta and pi</p><p>we have the boundary conditions that pi(0) = 0 and pi(1) = 1.</p><p>now we have pi(i+1) = alpha(i)*pi(i) + beta(i)*pi(i-1)</p><p>where alpha(i) = 5*pi(i) + 2</p><p>and beta(i) = pi(i)*pi(i-1) + 1/2</p><p>my question is how do a create a loop within a loop which automatically solves this for all i</p>akayhttp://nl.mathworks.com/matlabcentral/profile/authors/8455279-akaytag:nl.mathworks.com,2005:Question/2975712016-07-28T18:20:12Z2016-07-29T17:52:43Zhow to do interpolation?<p>Hi all,</p><p>I worked with the time series of the sea level data (non-tidal residual. thus, there is no periodicity in the time series. could you please help me to do interpolation because it contains some NaN values.</p><p>Thank you in advance.</p>Ms. Oceanographer http://nl.mathworks.com/matlabcentral/profile/authors/6648456-ms-oceanographer