https://ch.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2018-03-17T22:20:59Ztag:ch.mathworks.com,2005:Question/3858282018-03-01T23:05:33Z2018-03-17T22:20:59ZI have a nonlinear equation ,, which i didn't know how to put it in matlab<p>the equation</p><pre class="language-matlab">x exp x = [(segma / KB * T ) ^ 2 - x ]* (tr/ttr) * exp(E0 - Ea)/KB * T
</pre><p>while :</p><pre class="language-matlab">segma = 13 , KB =8.617*10^-5 , tr= 250 , ttr= 0.027 , E0=1.185 , Ea=E0+0.073
T=0:300
</pre><p>and the other one is</p><pre class="language-matlab">E(T)= E0 -(0.00000048 * T^2) /(270 + T) - x * KB *T
</pre><p>while</p><pre class="language-matlab">E0=1.185 , KB =8.617*10^-5 and also T =0:300
</pre><p>can any one help me with it please</p>beso sshttps://ch.mathworks.com/matlabcentral/profile/authors/12115301-beso-sstag:ch.mathworks.com,2005:Question/3889722018-03-17T21:05:15Z2018-03-17T22:16:29ZMy int function is returning the function back instead of an integral<p>I have this function</p><pre> f = (sin(2*r^2)*(16*r^4 + 1)^(1/2))/(r^2 + z^2)^(3/2)</pre><p>but when I try to integrate it</p><pre class="language-matlab">int(f,r,[0 10])
</pre><p>it returns the function back:</p><pre class="language-matlab">ans =
</pre><pre class="language-matlab">int((sin(2*r^2)*(16*r^4 + 1)^(1/2))/(r^2 + z^2)^(3/2), r, 0, 10)
</pre><p>How do I find the integral?</p>Marc Adamshttps://ch.mathworks.com/matlabcentral/profile/authors/12100594-marc-adamstag:ch.mathworks.com,2005:Question/3888512018-03-16T23:55:51Z2018-03-17T22:14:04Zhow do i identify the background of binary image?<p>i have a binary image and I want to identify the background of the image?
the image is bellow.</p>naya taajhttps://ch.mathworks.com/matlabcentral/profile/authors/12403969-naya-taajtag:ch.mathworks.com,2005:Question/3889702018-03-17T20:36:20Z2018-03-17T22:12:39ZHow to generate a joint probability matrix from a data matrix<p>Suppose I have a data matrix</p><p>Sample# X Y</p><p>1 1 1</p><p>2 1 2</p><p>3 1 1</p><p>Then I want to generate a joint prob matrix</p><p>X Y Prob</p><p>1 1 0.67</p><p>1 2 0.33</p><p>Please advise.</p>alpedhuezhttps://ch.mathworks.com/matlabcentral/profile/authors/10930090-alpedhueztag:ch.mathworks.com,2005:Question/3889792018-03-17T22:12:09Z2018-03-17T22:12:09ZData structures for multiple variables<p>Im trying to create a data structure with 6 elements for 6 satellites i have modelled. when i call stat(1) it works, but when attempting to call an other stat, e.g stat(2), i get an error saying 'index exceeds matrix dimension'</p><pre class="language-matlab">if true
%
end
</pre>Christopher Marajhttps://ch.mathworks.com/matlabcentral/profile/authors/11133285-christopher-marajtag:ch.mathworks.com,2005:Question/3872202018-03-09T00:33:05Z2018-03-17T22:10:15ZDetecting thin edges of the connected cell<p>Hello Everyone!
I have a B/W image of a cell and want to extract a thin edges out of it. I tried imclose() but it gives the closed object. Please find the source image, target image (Image which I want) and image with imclose() operation.
Yellow line in the Targetimage.jpg is the output, which I want.
Thanking you in anticipation.</p>Mahihttps://ch.mathworks.com/matlabcentral/profile/authors/11410091-mahitag:ch.mathworks.com,2005:Question/3889402018-03-17T16:18:39Z2018-03-17T22:06:06ZIn the following sample. The result of the graphic is one point What is wrong here please<pre> energy = energy + deltaE; </pre><pre> for A = 1:nPart</pre><pre class="language-matlab"> th=A*L;
</pre><pre> end</pre><pre class="language-matlab">plot(energy,A,'b*')
xlabel('energy')
ylabel('( th)')
</pre><pre> end</pre>zina shadidihttps://ch.mathworks.com/matlabcentral/profile/authors/2297996-zina-shadiditag:ch.mathworks.com,2005:Question/3889782018-03-17T21:47:25Z2018-03-17T22:02:04ZMatrix results with zeros?<p>I have a code that has a changing delta value. Initially, the value is 12.5 and I get the results:</p><img src = "/matlabcentral/answers/uploaded_files/108936/Screen%20Shot%202018-03-17%20at%205.37.32%20PM.png"><p>(accurate values)</p><p>But when the value of delta is 6.25, the results are completely different. I tested the functions independently to determine if the issue was with the them, but they don't seem to be the problem. They provide more accurate results as the increment is increased (as expected). This is the code I have for the changing delta value:</p><img src = "/matlabcentral/answers/uploaded_files/108933/Screen%20Shot%202018-03-17%20at%205.32.23%20PM.png"><p>I tested different delta values in a code that doesn't have the loop, and I get the results:</p><img src = "/matlabcentral/answers/uploaded_files/108934/Screen%20Shot%202018-03-17%20at%205.36.05%20PM.png"><p>How do I fix the code so that the results are correct? This code is representing deflection of a simply supported beam, so the deflection can't be zero for that many x values.</p><p>In case it helps, this is the code for the Thomas algorithm I'm using:</p><img src = "/matlabcentral/answers/uploaded_files/108937/Screen%20Shot%202018-03-17%20at%205.46.37%20PM.png">Anna Moseshttps://ch.mathworks.com/matlabcentral/profile/authors/10987796-anna-mosestag:ch.mathworks.com,2005:Question/3889742018-03-17T21:08:57Z2018-03-17T21:45:54ZHow to add trail to a tracer of a plot<p>This code generates an earth orbit around a fixed central point (the sun) in 3D. I want to be able to add a trail line showing where the earth has been but the closest I can get to this prints the whole orbit as well as the trail line. Any fixes?</p><pre class="language-matlab">function Planet_EART
%UNTITLED2 Ploting the orbit of earth in an ellipse
close all
Centre = [0,0,0];
E = struct('mass',5.97219e+24,'r_planet',6.371e+06,'C',4.00302e+07,'vol',1.08321e+21,'Avg_den',1.813756e-04,'Avg_r',1.4959826e+011,'a',1.495978707e+11,'b',1.495770086e+11,'Avg_orb_v',2.9783e+04,'T',3.1558118e+07,'Inc',0.0029);
Nm = 1
T_max = Nm*3.1557600e+07;
</pre><pre class="language-matlab">t = 0:86400:T_max;
x = Centre(1) + E.a*cos(((2*pi)/E.T)*t);
y = Centre(2) + E.b*sin(((2*pi)/E.T)*t);
z = Centre(3) + (x.*tan(E.Inc));
k = 2:length(x);
</pre><pre class="language-matlab">plot3(Centre(1),Centre(2),Centre(3),'k*');
hold on;
indis = 20*Nm
p_trace = plot3(x,y,z);
set(p_trace,'visible','off');
p = plot3(x(1),y(1),z(1),'co');
hold off
axis ([-2e+11 2e+11 -2e+11 2e+11 -2e+11 2e+11])
for k = 2:length(x)
p.XData = x(k);
p.YData = y(k);
p.ZData = z(k);
if k>indis
p_trace.XData = x(k-indis:length(x));
p_trace.YData = y(k-indis:length(x));
p_trace.ZData = z(k-indis:length(x));
</pre><pre> else
end
drawnow
pause(0.01);
end</pre><pre class="language-matlab">end
</pre>Daniel Elliotthttps://ch.mathworks.com/matlabcentral/profile/authors/12310336-daniel-elliotttag:ch.mathworks.com,2005:Question/3889772018-03-17T21:41:30Z2018-03-17T21:41:30ZWould I be able to use a Pocketbeagle, using the BeagleBone Black support package?<p>The Pocketbeagle was released a few months ago and from looking at the specs it seems like the Pocketbeagle is very similar to the beaglebone black just a smaller form factor. So would I be able to connect the Pocketbeagle to matlab? thanks</p>hgamarrohttps://ch.mathworks.com/matlabcentral/profile/authors/5599554-hgamarrotag:ch.mathworks.com,2005:Question/3889562018-03-17T17:47:59Z2018-03-17T21:15:15ZUndefined function 'count' for input arguments of type 'logical'.<p>Im trying to code my fitness function with just one constraint inside that m.file but i run into and error that says</p><pre class="language-matlab">"Undefined function 'count' for input arguments of type 'logical'.
</pre><pre class="language-matlab">Error in my_fun (line 22)
if count (L == 1) == 1; "
</pre><p>I don't really how to fix it.
the following is the piece of code.</p><pre class="language-matlab">function y = my_fun(c1)
w1 = 0.8;
% w2 = 0.8;
% w3 = 0.8;
% y = w1*x1 + w2*x2 + w3*x3;
X=xlsread('Dataset.xlsx');
% Xout=X(:,end);
D = 1:5;
T = 1:9;
L = 1:26;
chromosome = [D T L];
%Constraint 1
for DateID = D
for TimeID = T
if count (L == 1) == 1;
c1 = 0;
else
c1 = 1;
end
end
end
y = w1*c1;
</pre><p>In here, im trying to define my chromosome in the form of [D T L] and also assigning the ID in my dataset to be the genotype. In constraint 1, im trying to find if the L have violated the constraints and it gives the value 1, and if not then 0.</p><p>PLease advice. thanks.</p>yiwen yimhttps://ch.mathworks.com/matlabcentral/profile/authors/10259678-yiwen-yimtag:ch.mathworks.com,2005:Question/3889762018-03-17T21:14:48Z2018-03-17T21:14:48ZAdding rows to matrix according to sequence<p>I need help adding rows to my routh table matrix according to certain sequences.
Please see step 2,step 3 and general property 1.
Really need help
thankyou in advance</p>Mahnoor Alihttps://ch.mathworks.com/matlabcentral/profile/authors/12080796-mahnoor-alitag:ch.mathworks.com,2005:Question/3889752018-03-17T21:12:47Z2018-03-17T21:12:47ZRegarding Matrix row subtraction! Please Help, Urgent<p>HI</p><p>Consider this example</p><p>A=[6 5 6;2 4 1]
A(2,2)-A(1,2) gives me a zero value. However I needed the real value in positive.
I do understand that abs() would help in making it positive however I get a zero value to start with. CAN SOMEONE PLEASE HELP</p>Pavel Chatterjeehttps://ch.mathworks.com/matlabcentral/profile/authors/12144349-pavel-chatterjeetag:ch.mathworks.com,2005:Question/3889362018-03-17T15:57:58Z2018-03-17T21:12:32ZTwo for loops running simultaneously<p>Hi fellow experts,</p><p>I'm trying to design a matlab GUI where the user can key in the desired value in the display box which will display the output of the Arduino in graph. eg. if i key in 3 on the display box, the graph will show the output of the Arduino in 180 seconds. I am currently stuck at this stage as the For loops at b=2 would keep overlapping with b=1.</p><pre class="language-matlab">a=arduino
b = get(handles.edit1, 'String')
for b=1;
for d=1:60
temp(d)= readVoltage(a,'A15');
plot(temp);hold on;
pause(0.2);
end
end
for b=2;
for i=1:120
temp(i)= readVoltage(a,'A15');
plot(temp);hold on;
pause(0.2);
end
end
</pre><p>etc.</p><p>Any form of help would be greatly appreciated!!</p><p>Thanks</p><p>Jacob</p>Chong Kai Xianghttps://ch.mathworks.com/matlabcentral/profile/authors/6223807-chong-kai-xiangtag:ch.mathworks.com,2005:Question/3889732018-03-17T21:06:54Z2018-03-17T21:06:54ZHow to extract the values of RC transient from the battery model in Simulink?<p>Hi,
I'm wondering, <b>how can I extract the values of RC branch transient from the Simulink battery model</b>(as shown in the attached pictures) because I'm using a simplified battery model(Thevenin model) and I need those values.
Thank you in advance</p>waell telmesanihttps://ch.mathworks.com/matlabcentral/profile/authors/7479354-waell-telmesanitag:ch.mathworks.com,2005:Question/3889622018-03-17T18:58:33Z2018-03-17T21:04:51Zhow can I write a function y(n) in terms of function x(n)?<p>I run this code and I get error. (the error is for function y which contains function x in its defenition). how can i fix this error? (The functions x and y are discrete signals)</p><pre class="language-matlab">syms n y x
n=-10:1:10;
x=dirac(n+1)+dirac(-n+4)-2*heaviside(n+3);
y(n)=x(n)-x(2*n+3);
plot(x,'o');
plot(y,'o');
</pre>geometry geometryhttps://ch.mathworks.com/matlabcentral/profile/authors/10317129-geometry-geometrytag:ch.mathworks.com,2005:Question/3889692018-03-17T20:24:56Z2018-03-17T20:59:23ZTrying to do repeat math on multiple variables...<p>Fs = 44100;</p><p>W_t1 = [0,150]; W_r1 = [0,0];</p><p>W_t2 = [150,600]; W_r2 = [0,0];</p><p>W_t3 = [600,1700]; W_r3 = [0,0];</p><p>W_t4 = [1700,7000]; W_r4 = [0,0];</p><p>W_t5 = [7000,22050]; W_r5 = [0,0];</p><p>%W_r1 = W_t1 * 2*pi/Fs;</p><p>for i = [1:5]</p><pre> W_ri = W_ti*(2*pi/Fs) % This is where I want the loop to preform that math for W_t(1-5)</pre><p>end</p>Spencer Tullyhttps://ch.mathworks.com/matlabcentral/profile/authors/7583569-spencer-tullytag:ch.mathworks.com,2005:Question/3889712018-03-17T20:51:56Z2018-03-17T20:51:56ZOptimization of DAE with given constraints<p>Dear all,</p><p>I have some trouble trying to visualize what would be the tool to use for this problem:</p><p>I have a model of a moving object in terms of its differential algebraic equations. In these equations I have 2 control inputs. I want to obtain the optimum of these control inputs to move this object from A to B.</p><p>¿Which is the tool I should use?</p><p>Thanks in advance!</p>Ahmed Seraje EL Ouahabihttps://ch.mathworks.com/matlabcentral/profile/authors/8163993-ahmed-seraje-el-ouahabitag:ch.mathworks.com,2005:Question/3853032018-02-27T22:26:08Z2018-03-17T20:48:20ZHow do I speed up simulation time in SimMechanics using the Contact Forces Library?<p>I am modeling an inverted pendulum that is capable of falling over at certain angles. I am using the contact forces library to model forces between the base of the pendulum and a floor. When the pendulum is at 0 degrees (standing straight up) everything runs great. When I change the angle, the computation time is incredibly slow. I have tried some new ODE solvers and changing time steps but it is still very slow. Is there another way I might speed this simulation up?</p>Tim Christyhttps://ch.mathworks.com/matlabcentral/profile/authors/7665246-tim-christytag:ch.mathworks.com,2005:Question/3889652018-03-17T19:50:54Z2018-03-17T20:48:07ZHow do you get variables to open in Editor?<p>I accidentally did something stupid, and now when I double click on a variable to see its contents, it opens in a new window instead of opening a variable tab within the editor. How do I revert this back to normal?</p><p>Thank you</p>Tarik Gibanihttps://ch.mathworks.com/matlabcentral/profile/authors/10508930-tarik-gibanitag:ch.mathworks.com,2005:Question/3889682018-03-17T20:24:49Z2018-03-17T20:25:47ZHOW to combine either of SURF features and HOG features or Gabor and HOG?<p>Hello all, I am working on Low resolution Face recognition with Occlusion handling. My question is in two folds: <b>Question 1.</b> Which of the combination of feature extraction will work well on low resolution images with occlusion: <b>Gabor and Histogram of Oriented Gradients (HOG), or SURF and HOG features</b> when applied to other techniques to match the features. <b>Question 2.</b> I want a code to combine either of these features for better results.</p><p>Thanks</p>Chidiebere Ikehttps://ch.mathworks.com/matlabcentral/profile/authors/10712487-chidiebere-iketag:ch.mathworks.com,2005:Question/3889452018-03-17T16:47:05Z2018-03-17T20:12:16ZWorking with inputs in functions<p>I have got a problem. I need to code a bisection program in Matlab but I need to make it useful for any mathematical function the user wants. Does anyone know how to write a code without defining the mathematical function (leaving the option for the user) on which the program will work on?</p>Renan Portelahttps://ch.mathworks.com/matlabcentral/profile/authors/9228727-renan-portelatag:ch.mathworks.com,2005:Question/3889672018-03-17T20:10:49Z2018-03-17T20:10:49ZLoad a Dll's namespace without header file in C++(Mex)<p>I'm coding in Mex in MATLAB. I want to use CyUSB.dll (a dll for FX2LP USB controller Chip). It doesn't have any Header file. I Use the following code:</p><pre class="language-matlab">HINSTANCE CyUSBdll = LoadLibrary("D:\\JOb\\Projects\\\\Test\\Matlab\\matriX\\CyUSB.dll");
if(CyUSBdll == NULL)
{
mexErrMsgIdAndTxt("Test0:test","Could not load the DLL file.");
}
</pre><p>Dll loaded Successfully.I Used functions in Matlab(not Cmex) for example in this way:</p><pre class="language-matlab">usbDevices = CyUSB.USBDeviceList(CyUSB.CyConst.DEVICES_CYUSB);
</pre><p>But CyUSB is not declered after i use LoadLibrary. The CyUSB proggramer's Guide say that:</p><p><i>To use the library, you need to add a reference to CyUSB.dll to your project's References folder. Then, any source file that accesses the CyUSB namespace will need to include a line to include the namespace in the appropriate syntax. Examples: Visual Basic.net Imports CyUSB Visual C# using CyUSB; Visual C++ (Win Forms App) using namespace CyUSB; Visual J# import CyUSB.*;</i></p><p>Using this syntax in Mex makes error. CyUSB is namespace name and compiler says that CyUSB is not declared. How to load dll's namespace? I'am Confused!</p>javad habibihttps://ch.mathworks.com/matlabcentral/profile/authors/12417764-javad-habibitag:ch.mathworks.com,2005:Question/3889662018-03-17T20:07:03Z2018-03-17T20:07:03ZBiological model PDE Spatial Aggregation of Amoebae<p>Hi,</p><p>I have the following question and I have no idea how to even start to solve this on Matlab</p><p><b>Question:</b></p><p>Amoebae have a population density <b>n(x,t)</b> depending on the density of a chemical <b>a(x,t)</b> (called an attractant). The densities a and n satisfy the following system of PDEs:</p><p>n_t = d_1 * n_{xx} - X_{0} (n* a_x)_x</p><p>a_t = h*n - k*a + d_2*a_{xx}</p><p>where d1, d2, h, k and X_0 are all positive constants.</p><p>We assume that the population (and the attractant) live in a finite one dimensional habitat say x E [0,1].</p><p>Determine the densities a and n for t>=0 when we are given some initial distributions at t=0 with boundary conditions u_x(0,t)=u_x(1,t)=0, t>=0</p><p>If anyone has any advice, I would be very grateful</p>Ryan O'Connellhttps://ch.mathworks.com/matlabcentral/profile/authors/12410512-ryan-o-connelltag:ch.mathworks.com,2005:Question/3889642018-03-17T19:46:58Z2018-03-17T20:00:21Zhow to write multiple of 7 from 0 to 200 in matlab<p>how to write code that shows the multiple of 7??</p>omar alblooshihttps://ch.mathworks.com/matlabcentral/profile/authors/12404352-omar-alblooshitag:ch.mathworks.com,2005:Question/3867142018-03-06T19:22:02Z2018-03-17T19:47:37Zgraphshortestpath function visiting all nodes<p>Hi,</p><p>Is there a way I can manipulate this function in order to force the path include all nodes?
I mean, how can I change the code in order to include each node to find the shortest path , but with the constrain that we must visit all nodes?</p><p>Thank you in advance</p>Jasonhttps://ch.mathworks.com/matlabcentral/profile/authors/9280584-jasontag:ch.mathworks.com,2005:Question/3888262018-03-16T19:44:04Z2018-03-17T19:30:27ZPlotting two linear equations <p>Hi. How can i plot this equation between (-5,2) values</p><p>f(x) =</p><ul><li>-1 ----> x<-1</li><li>x^2+x ------> -1 <= x < 2</li></ul>Sam Oznchttps://ch.mathworks.com/matlabcentral/profile/authors/12258876-sam-oznctag:ch.mathworks.com,2005:Question/3862422018-03-04T14:37:33Z2018-03-17T19:24:21ZAssigning Attributes to the entity in simulink<p>I want to generate parts from a single Entity Generator block. the attributes attached with the parts are <b>Part type</b> and <b>Service Time</b>. I have tried this</p><img src = "/matlabcentral/answers/uploaded_files/107119/Capture.JPG"><p>what I understood from my code is that the first entity generated will get <b>Type</b> attribute randomly from 1 to 3 and <b>service time</b> will be 2 but I want that each entity generated with attribute <b>Type 1</b>, e.g. get <b>service time=2</b> and entity with <b>Type 2</b> get <b>Service time=4</b> etc. But I dont know how to write the syntax.
Can anybody guide me please?</p>summyia qamarhttps://ch.mathworks.com/matlabcentral/profile/authors/8556300-summyia-qamartag:ch.mathworks.com,2005:Question/2428012015-09-14T05:54:00Z2018-03-17T19:09:14ZHOW to combine between SURF features and HOG features<p>im doing my experiment using matlab
i want code thats combine between SURF features and HOG features</p>AHMED ALMARZOOQI https://ch.mathworks.com/matlabcentral/profile/authors/6468956-ahmed-almarzooqitag:ch.mathworks.com,2005:Question/3849772018-02-26T19:46:54Z2018-03-17T19:04:14ZSplitting an image into smaller regions<p>Hi Guys,</p><p>I'm working on a code that creates an RGB descriptor for visual search. i've managed to implement the rgb descriptor on the whole image. but i wanted to experiment by splitting the same image up into smaller areas and rerun the experiment by calculating the rgb descriptor on smaller parts of the image.</p><p>the reason behind this, is because i'm using a query image against a dataset in order to find visually similar results. but if i split up my image into smaller pieces, i got a feeling it will be more accurate.</p><p>my question is, is there a function or piece of code that could help me with this?</p><p>Thanks</p>hasan alhussainihttps://ch.mathworks.com/matlabcentral/profile/authors/9050095-hasan-alhussainitag:ch.mathworks.com,2005:Question/3888692018-03-17T04:59:28Z2018-03-17T19:03:05ZI need to repeat a word using a loop<p>I want to say "Hello" seven times. How can I do it using MATLAB? I know how to do it using numbers but not using words.</p><p>Thanks.</p>Thishan Dharshana Karandana Gamalathgehttps://ch.mathworks.com/matlabcentral/profile/authors/2762250-thishan-dharshana-karandana-gamalathgetag:ch.mathworks.com,2005:Question/3889602018-03-17T18:50:31Z2018-03-17T18:57:51ZHow would I find the 90th percentile of a vector, factoring in frequency?<p>I basically have vector 'A' and 'B', where A contains a list of ordered sizes and B contains the corresponding frequency of those sizes.</p><p>I'm trying to find the 90th percentile of the A vector whilst factoring in the frequencies of the B vector. Any ideas as to how I would achieve this?</p>Matthew Quigleyhttps://ch.mathworks.com/matlabcentral/profile/authors/12048551-matthew-quigleytag:ch.mathworks.com,2005:Question/3889272018-03-17T14:19:34Z2018-03-17T18:55:27Zhow can i solve this eqution and find ki please ? <img src = "/matlabcentral/answers/uploaded_files/108884/drbasim.png"><p>equation equal to zero</p>dina mohamedhttps://ch.mathworks.com/matlabcentral/profile/authors/9068399-dina-mohamedtag:ch.mathworks.com,2005:Question/3889612018-03-17T18:51:21Z2018-03-17T18:51:21ZWaitbar reappear after openning a GUI<p>In guiframe_OpeningFcn of my GUI, a function is called to process some data. It takes a little while so I added a simple waitbar in the function. The problem is that the waitbar reapears after the GUI is open. I have tried delete() or close(), but none of them works, the waitbar is closed when the function is finished, but it keeps popping up again after the GUI is open. Is there a way to solve this problem?</p>Chi Zhanghttps://ch.mathworks.com/matlabcentral/profile/authors/8767026-chi-zhangtag:ch.mathworks.com,2005:Question/3889552018-03-17T17:41:29Z2018-03-17T18:51:00ZFilter big data simulink or matlab<p>Hi I have the data in the image below :</p><img src = "https://www.mathworks.com/matlabcentral/answers/uploaded_files/108911/data.png"><p>and I tried smoothing and/or filtering, but had no luck to get a reasonable result. My goal is to get rid of all the spikes in the blue and make the plot similar to the red line much as possible. Any idea of the best method to that? The image below is for zoomed data</p><img src = "/matlabcentral/answers/uploaded_files/108910/dataz.png"><p>and the attached image is for the all plot:</p><img src = "https://www.mathworks.com/matlabcentral/answers/uploaded_files/108911/data.png">mikehttps://ch.mathworks.com/matlabcentral/profile/authors/3645412-miketag:ch.mathworks.com,2005:Question/3889582018-03-17T18:42:08Z2018-03-17T18:50:38ZI can't link the legend colours to my graph lines<p>I can't seem to be able to link my different plots (lines) to the legend colour. It doesn't match.</p><p>I went to this forum and searched similar questions and one of them was this: <a href = "https://www.mathworks.com/matlabcentral/answers/25379-legend-problem">https://www.mathworks.com/matlabcentral/answers/25379-legend-problem</a></p><p>It ended up showing more plots in the legend than expected (I only have 5 lines yet it showed more).</p><p>My code is very long so I have attached it here. Thank you in advance.</p>Calvin Leehttps://ch.mathworks.com/matlabcentral/profile/authors/11870131-calvin-leetag:ch.mathworks.com,2005:Question/3888862018-03-17T08:14:21Z2018-03-17T18:50:08ZHow to pass data in a gui and refresh/reload a list box<p>hello,
I trying to load a mat file into a GUI and then have to user choose the variable in the file in order to pass it into a function.
So far, I have managed to load the file using "uigetfile" and then "load" to assign all the variables in the file into a struct variable,and then I got the names of the variables (fields) using "fieldnames".</p><p>How can I display those variable names in a list box and assign the one chosen by the user to a new variable and pass it into my function?</p><p>thanks in advance
I'm not a programmer and I if the solution is too complex odds are that I'll not get it, however if it is simple, I will be thank full for your help.</p>ytzhak gousshahttps://ch.mathworks.com/matlabcentral/profile/authors/11482545-ytzhak-gousshatag:ch.mathworks.com,2005:Question/3889592018-03-17T18:46:23Z2018-03-17T18:46:23ZFlow In A Pipe Network<p>Hello everyone,
There is a question which solved with old program and I need to solved it with Matlab.I bothered with it but could not resolve it.Is it possible with Matlab?
Is there someone who can help me in this regard ?How should I approach the question? The question is as follows.Thank you...</p><img src = "/matlabcentral/answers/uploaded_files/108915/1.png"><img src = "/matlabcentral/answers/uploaded_files/108916/2.png"><img src = "/matlabcentral/answers/uploaded_files/108917/3.png">matstudenthttps://ch.mathworks.com/matlabcentral/profile/authors/6344432-matstudenttag:ch.mathworks.com,2005:Question/3889392018-03-17T16:09:07Z2018-03-17T18:44:57Zplotting non-linear equation<p>Hello matlab,</p><p>I have this equation
y*x= 1+ ln(y/x);</p><p>x varies from 0 to 1. Is there any way to plot x vs y?</p><p>Best</p>friethttps://ch.mathworks.com/matlabcentral/profile/authors/5876107-friettag:ch.mathworks.com,2005:Question/3888822018-03-17T07:38:43Z2018-03-17T18:41:00ZError loading files prompt in application compiler<p>I want to make an executable file from a gui,but a message box with "error loading files" is popping.please suggest a solution as soon as possible.
Thanks</p>Hitesh Kumarhttps://ch.mathworks.com/matlabcentral/profile/authors/9426782-hitesh-kumartag:ch.mathworks.com,2005:Question/1151502014-02-06T20:24:45Z2018-03-17T18:36:18ZHow to make script and command window adjacent<p>I'm new to MATLAB and am still getting used to the workspace. When I open a new file or script, it always comes out in a new window. How can I get it to be opened in the same window as the commands? Thanks!</p>Amyhttps://ch.mathworks.com/matlabcentral/profile/authors/3658914-amytag:ch.mathworks.com,2005:Question/3889092018-03-17T12:21:58Z2018-03-17T18:31:10ZHow can I work out the median of frequency tables?<p>I currently have vector A that contains an ordered range of values, and vector B that contains the corresponding frequencies of these values.</p><p>What would I need to do in order to discover the median of the values in vector A, based on the frequencies in vector B?</p>Matthew Quigleyhttps://ch.mathworks.com/matlabcentral/profile/authors/12048551-matthew-quigleytag:ch.mathworks.com,2005:Question/3889442018-03-17T16:47:01Z2018-03-17T18:30:18ZSymbolic integration inside numerical integration<p>I would like to solve the following integral numerically:</p><img src = "/matlabcentral/answers/uploaded_files/108898/numint.PNG"><p>As far as I can tell, the built-in function <i>integral2</i> is not applicable here due to the nature of the expression. Instead, from <a href = "http://www2.math.umd.edu/~jmr/241/doubleint.html">Evaluating Double Integrals</a>, I arrive at the following solution which takes forever to compute due to the third line:</p><pre class="language-matlab">syms x r
firstint=int(1./(1+x.^2.5),x,r,Inf)
answer=int(r.*exp(-r.^2).*firstint,r,0,Inf),
double(answer)
</pre><p>The last line is just to get a numerical answer out of the symbolic integration. To speed up things, I am inclined to replace the third line with the built-in function <i>integral</i>, but it requires me to make <i>firstint</i> into a handle first, for example by using another built-in function called <i>matlabFunction</i>. Unfortunately, I get an error when doing the following:</p><pre class="language-matlab">syms x r
firstint=int(1./(1+x.^2.5),x,r,Inf),
firstintHandle = matlabFunction(firstint),
answer=integral(r.*exp(-r.^2).*firstintHandle,0,Inf),
</pre><p>Any ideas on what to do? Please be very specific. Your help is greatly appreciated.</p>Gunnarhttps://ch.mathworks.com/matlabcentral/profile/authors/2004206-gunnartag:ch.mathworks.com,2005:Question/217842011-11-21T08:06:25Z2018-03-17T18:27:08ZSparse Matirx<p>How to code sparse matrix from the existing matrix?</p>David Chenhttps://ch.mathworks.com/matlabcentral/profile/authors/3191701-david-chentag:ch.mathworks.com,2005:Question/3889572018-03-17T18:17:03Z2018-03-17T18:17:03ZHDF5 V1.10<p>Can Matlab read/write HDF5 v1.10 files? If not, are there plans to add that support? I'm particularly interested in SWMR (Single Write Multiple Read) functionality, but I have not found any mention of that in the Matlab docs.</p>Norton Allenhttps://ch.mathworks.com/matlabcentral/profile/authors/474833-norton-allentag:ch.mathworks.com,2005:Question/3888042018-03-16T17:15:27Z2018-03-17T18:16:11ZIndex in position 2 exceeds array?<p>My code starts at connector on:</p><pre class="language-matlab">connector on MDTP1
m = mobiledev;
m.AngularVelocitySensorEnabled = 1;
m.AccelerationSensorEnabled = 1;
m.Logging = 1;
for K = 1 : 5; pause(1); end
m.Logging = 0;
[av, tav] = angvellog(m);
[o, to] = orientlog(m);
yAngVel = av(:,2);
roll = o(:, 3);
plot(tav, yAngVel, to, roll);
legend('Y Angular Velocity', 'Roll');
xlabel('Relative time (s)');
tInit = datetime(m.InitialTimestamp, 'InputFormat', 'dd-MM-yyyy HH:mm:ss.SSS');
tAngVel = tInit + seconds(tav);
tOrient = tInit + seconds(to);
yAngVelDeg = yAngVel * 180/pi;
plot(tAngVel, yAngVelDeg, tOrient, roll);
legend('Y Angular Velocity', 'Roll');
xlabel('Absolute time (s)');
m.AngularVelocitySensorEnabled = 0;
clear m;
</pre><p>So I made this program, and it runs on my Android phone. It's supposed to collect data from the sensors available in the mobile MATLAB app and graph it. I ran the program once, and it worked. But now this error pops up when I run the code:</p><pre class="language-matlab">index in position 2 exceeds array bounds.
</pre><p>What does this mean and how would I fix it?</p>Ryan Leonardhttps://ch.mathworks.com/matlabcentral/profile/authors/11845177-ryan-leonardtag:ch.mathworks.com,2005:Question/3888782018-03-17T06:50:05Z2018-03-17T18:09:16ZFor loop store variable with different dimension <p>Hi all,</p><p>I have a question about storing the results from a for loop. The problem is that each round results in a vector of different size. I thought creating an cell should work, but I'm clearly (doing something) wrong. Other option, maybe? would be to fill the "empty" places in the matrix with zeros.</p><p>Best,</p><p>Rick</p>Rick Verbernehttps://ch.mathworks.com/matlabcentral/profile/authors/12310191-rick-verbernetag:ch.mathworks.com,2005:Question/3888812018-03-17T07:27:55Z2018-03-17T18:02:36Zwhat algorithm/technique/method is used to calculate convex hull in bwconvhull ? is it based on qhull ? <p>what algorithm/technique/method is used to calculate convex hull in bwconvhull ?
is it based on qhull ?</p>Usman Saeedhttps://ch.mathworks.com/matlabcentral/profile/authors/4397476-usman-saeedtag:ch.mathworks.com,2005:Question/3723612017-12-11T18:36:15Z2018-03-17T17:55:17ZIs it possible to Create Custom Arduino Add-On Device, Library, or Code for Arduino DUE?<p>I wrote a custom Arduino Add-On following documentation (Create Custom Arduino Add-On Device, Library, or Code) that works very well on Arduino UNO and MEGA.
When I update my Add-On on Arduino DUE using the following command:</p><pre class="language-matlab">a = arduino('COM10', 'due', 'Libraries', 'ExampleAddon/HX711');
</pre><p>an error occurs: <b>Cannot program board Due (COM10). Please make sure the board is supported and the port and board type are correct. For
more information, see Arduino Hardware Troubleshooting.</b></p><p>The arduino board is original and works well when using Matlab Support package and libraries such as SPI or I2C.
If I upload the Arduino server with "arduinosetup" command, no errors occur and my library is detected by "listArduinoLibraries", but when I create an arduino object, Matlab starts uploading server again without my library.
I thought there's some special code that must be included in C++ header file, but I can't find anything in documentation. In Matlab support package description this functionality seems to be supported.</p>NICHOLAS GIACOBONIhttps://ch.mathworks.com/matlabcentral/profile/authors/7779346-nicholas-giacobonitag:ch.mathworks.com,2005:Question/3889542018-03-17T17:20:27Z2018-03-17T17:51:13ZHow to seperate weekdays and weekends from an hourly data?<p>I have a data in excel which has data in yyyy-mm-dd hr:min:sec Am/PM format and I want to separate this data to weekdays and weekends without doing any average of it. How do I do it?</p><p>Thank
Mahavir</p>Mahavir Nakumhttps://ch.mathworks.com/matlabcentral/profile/authors/9600835-mahavir-nakum