https://au.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2017-03-30T08:47:32Ztag:au.mathworks.com,2005:Question/3327132017-03-30T08:47:32Z2017-03-30T08:47:32ZHow fmincon can manipulate continuous and discrete variables ?<p>Hello, I work on optimization with fmincon based on an artificial learning algorithm. And I used two types of variables: continuous and discrete. I got this error there, I think that fmincon can not work on both types of variables together. Is it possible ?
thank you in advance</p><p><<</p><img src = "/matlabcentral/answers/uploaded_files/73817/Capture%20fonction.PNG"><img src = "/matlabcentral/answers/uploaded_files/73818/error%20fmincon.PNG"><p>>></p>houda mejrihttps://au.mathworks.com/matlabcentral/profile/authors/9669688-houda-mejritag:au.mathworks.com,2005:Question/3326972017-03-30T06:58:01Z2017-03-30T08:46:21ZHow to form a feature vector?<p>Hello everyone
I am doing a project "identification of person using retina". I have extracted my features (Bifurcation Points and end Points). Now I have to make a feature vector. This feature vector should have the distance and angles between four nearest features of every feature point. Please guide me about some methods through which I can do it. I am not asking for the code. I am only asking for some methods to do it.
Below is the image of what I have done so far.</p><img src = "/matlabcentral/answers/uploaded_files/73808/un.png">Sidra Aleemhttps://au.mathworks.com/matlabcentral/profile/authors/9949650-sidra-aleemtag:au.mathworks.com,2005:Question/3326882017-03-30T06:28:49Z2017-03-30T08:45:50ZUnable to create project in xilinx vivado 2015.2 from simulink using hdl workflow adviser,Getting error [12-172],how can get pass this?<p>Hi,</p><p>I am trying to run HDL work flow adviser for the standard LED blink example from MATLAB. I am new to this style of programming FPGA, can someone advice me what to do or where I can find a solution. This is the following error:</p><pre class="language-matlab">Failed
INFO: [Ipptcl 7-578] No Compatible Board Interface found.Board Tab not created
VHDL Output written to : C:/MATLAB Saved files/hdl_prj/vivado_ip_prj/vivado_prj.srcs/sources_1/bd/system_top/hdl/system_top.vhd
VHDL Output written to : C:/MATLAB Saved files/hdl_prj/vivado_ip_prj/vivado_prj.srcs/sources_1/bd/system_top/hdl/system_top_wrapper.vhd
Wrote : <C:/MATLAB Saved files/hdl_prj/vivado_ip_prj/vivado_prj.srcs/sources_1/bd/system_top/system_top.bd>
make_wrapper: Time (s): cpu = 00:00:04 ; elapsed = 00:00:05 . Memory (MB): peak = 390.328 ; gain = 123.043
# regsub -all "system_top.vhd" [get_files system_top.vhd] "system_top_wrapper.vhd" TOPFILEPATH
# add_files -norecurse $TOPFILEPATH
ERROR: [Vivado 12-172] File or Directory 'Saved' does not exist
INFO: [Common 17-206] Exiting Vivado at Thu Mar 30 11:54:46 2017...
</pre><pre class="language-matlab">Elapsed time is 11.1759 seconds.
</pre>Ariz Wakilhttps://au.mathworks.com/matlabcentral/profile/authors/5154303-ariz-wakiltag:au.mathworks.com,2005:Question/3327122017-03-30T08:44:52Z2017-03-30T08:44:52ZHow can I apply fuzzy membership function in video processing ?<p>How can I apply fuzzy membership function in video processing ? After I make clustering then how can I proceed to assigning membership function and replace the crisp threshold value.</p>Bibhu Prasad Dashttps://au.mathworks.com/matlabcentral/profile/authors/9088446-bibhu-prasad-dastag:au.mathworks.com,2005:Question/3327072017-03-30T08:15:32Z2017-03-30T08:43:31ZBMI calculator Define a function CalculateBMI with inputs massKg and heightCm. The function returns bodyMassIndex. The function should be able to calculate the BMI of a single individual, or a group of inviduals provided as a row. need help w/ group<p>function bodyMassIndex= CalculateBMI(massKg,heightCm)
heightCm=heightCm/100;</p><p>bodyMassIndex=massKg/(heightCm*heightCm);</p><p>end</p>zachary stallingshttps://au.mathworks.com/matlabcentral/profile/authors/10008545-zachary-stallingstag:au.mathworks.com,2005:Question/3325032017-03-29T10:05:05Z2017-03-30T08:41:41ZSimulink Biquad Filter and HDL Coder<p>Hello,</p><p>in my Model i use a Biquad Filter from the DSP System Toolbox with the Coefficient Source: Input port(s).
At the Port Num i need to give it a M by 3 Matrix, Port Den a M by 2 Matrix and g a M+1 Vektor.
If is use any M>1 HDL Coder gives me an Error Message from the Matrix Source Block: <i>Matrices are not supported at Simulink block interfaces.</i>
So, does anyone have an Idea <b>how to get the Biquad Filter Working with a M bigger then 1</b>?</p><p>Thanks</p>sascha rubowhttps://au.mathworks.com/matlabcentral/profile/authors/9721903-sascha-rubowtag:au.mathworks.com,2005:Question/3325202017-03-29T11:54:40Z2017-03-30T08:41:28ZThe 10-bar truss optimization problem<p>Hello people,</p><p>I recently started working with Matlab and came across a problem with my code, if you have the time please take a look,
Any advice will be greatly appreciated.</p><p>Problem is attached I approched it by using Finite element method and got a 12*12 matrix which I would like to choose by using GA in Matlab, now I tried to write some sort of code with matlab but it is definily wrong cause I dont know how to write a matrix with unknown parameters being part of it.</p>farhad abtahihttps://au.mathworks.com/matlabcentral/profile/authors/9754951-farhad-abtahitag:au.mathworks.com,2005:Question/3323652017-03-28T17:01:06Z2017-03-30T08:42:59ZHeterogeneity in linear model<p>I'm fitting a generalized linear model. The response variable has a gamma distribution. I have 1 fixed (categorical) factor with three levels. The residuals show a quite strong heterogeneity. I'd like to avoid log-transforming the data. Is there any way to allow for different variances for each level?
I know FGLS, but that function only returns coefficient values, not the full model specification (pvalues, residuals, AIC, etc.). I've checked the 'Covariancepattern' option in fitglme, but as I understand that applies only to random factors and I don't have any. Is there something similar to the 'weights' argument in R's lme? I can provide the actual data if necessary.
Thanks</p>Francisco de Castrohttps://au.mathworks.com/matlabcentral/profile/authors/870206-francisco-de-castrotag:au.mathworks.com,2005:Question/3327112017-03-30T08:35:42Z2017-03-30T08:35:42ZI have license error 4, followed the instructions from your website but nothing came out(as you can see from the screenshot). What is wrong? Thank you<img src = "/matlabcentral/answers/uploaded_files/73815/%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202017-03-30%20%D0%B2%209.29.21.png">Bahdan Zviazhynskihttps://au.mathworks.com/matlabcentral/profile/authors/9978893-bahdan-zviazhynskitag:au.mathworks.com,2005:Question/3327102017-03-30T08:35:37Z2017-03-30T08:35:37ZAfter Matlab Compiler Error while opening Template<p>Hello,</p><p>I am writing a MATLAB Programm in MATLAB R2015b, which has to generate a Report, when the user presses a button. For the Report I am using MATLAB Report Generator.</p><p>I created a Word-Template with DOM-Object in it. In MATLAB I Import the mlreportgen.dom.*-class, look for the holes and fill them with data. This works very well in MATLAB. But when I create a standalone Tool with MATLAB Compiler, an error occurs.</p><p>The Error is:
Error using mlreportgen.dom.Document/movetoNextHole
Cannot open template. WordTemplate.dotx</p><p>So it seems like its not possible for programm to open my WordTemplate. Hope anybody can help me to solve this problem.</p>JoHabhttps://au.mathworks.com/matlabcentral/profile/authors/5909264-johabtag:au.mathworks.com,2005:Question/3326962017-03-30T06:55:09Z2017-03-30T08:32:00ZHow do I quickly delete array elements?<p>In my program I have 3 matrices each with roughly 300000000 elements if allowed to run to full.
This takes up a very large amount of RAM and thus I have implemented the following loop:</p><pre class="language-matlab">% Loop calculates the values of X, Y and Z
for i=1:N
X(j+1,1) = X(j,1) + (s*(-X(j,1) + Y(j,1)))*H;
Y(j+1,1) = Y(j,1) + (r*X(j,1) - Y(j,1) - X(j,1)*Z(j,1))*H;
Z(j+1,1) = Z(j,1) + (-b*Z(j,1) + X(j,1)*Y(j,1))*H;
</pre><pre> % Cuts out extra data that would otherwise fill memory and slow the
% program significantly at low H values
if mod(i,q) == 0
pop = j-q+1:j-1;
X(pop) = [];
Y(pop) = [];
Z(pop) = [];
j = j - q + 1;
end
j = j + 1;
end</pre><p>The central if statement is currently active for 93% of the time that the loop is running.</p><p>I have tried changing the data type of X, Y and Z to single instead of double to speed up the program, however this changes the final result of the iterative process by an unacceptable value.</p><p>Is there any way of removing the array elements more quickly without using a C compiler or Fortran?</p><p>Any help would be greatly appreciated :)</p>George Hulmehttps://au.mathworks.com/matlabcentral/profile/authors/8868307-george-hulmetag:au.mathworks.com,2005:Question/3327092017-03-30T08:27:00Z2017-03-30T08:31:54ZHow can I automatically trim/crop an image?<p>Hello Guys</p><p>I would like to know if there is a way to automatically crop/trim the attached image in horizontal direction (see red arrow).</p><p>I was thinking that something with color recognition could work, but im a beginner with matlab.</p><p>Thanks for your Help.</p>symmmhttps://au.mathworks.com/matlabcentral/profile/authors/5687799-symmmtag:au.mathworks.com,2005:Question/3326422017-03-29T22:06:34Z2017-03-30T08:18:43ZDeleting overlapped areas, and circle packing inside complicated shape<p>Dears,
I was able to script a triangle bordered with three circles at each vertice. After that, I was unable to take this further. I am trying to achieve two things:</p><img src = "/matlabcentral/answers/uploaded_files/73774/Plot%20(2).png"><p>1. How I can delete the overlapped (intersected areas) from the triangle like what is shown below (Scope: to have only the middle area).</p><img src = "/matlabcentral/answers/uploaded_files/73773/Plot%20(1).png"><p>2. I am trying to figure out how I can fill the final geometry(from part (1) after deleting the overlapped area) with circles of known diameter.</p><p>Your help is highly appreciated.</p><p>Thanks,</p><p>Albraa</p><p>Here is my script:</p><pre> %systme constants and inputs%
dfiber=5; %um%
spacing=1.149; %um, spacing for vf=60%
angle=60; %degrees%
%theta=0:1:360; %degrees%
ang=0:0.01:2*pi;%radians%
%--------------------------------------------------%
%-----------------Triangle drawing-----------------%
%--------------------------------------------------%
%Triangle verticies%
%1st point at orgin (0,0)%
x1=0;%um%
y1=0;%um%
%2nd point%
x2=dfiber+spacing;%um%
y2=0;%um%
%3rd point%
x3=(dfiber+spacing)/2;%um%
y3=(dfiber+spacing)*sind(angle);%um%
%4th point at orgin (0,0)%
x4=0;%um%
y4=0;%um%
%constructing the array%
a=[x1;x2;x3;x4];
b=[y1;y2;y3;y4];
%--------------------------------------------------%
%------------------circle drawing------------------%
%--------------------------------------------------%
% 1st circle%
xc1=x1;
yc1=y1;
r=dfiber/2;
xp1=r*cos(ang);
yp1=r*sin(ang);
%2nd circle%
xc2=x2;
yc2=y2;
r=dfiber/2;
xp2=r*cos(ang);
yp2=r*sin(ang);
%3rd circle%
xc3=x3;
yc3=y3;
r=dfiber/2;
xp3=r*cos(ang);
yp3=r*sin(ang);
%--------------------------------------------------%
%---plotting the triangle with the three circles---%
%--------------------------------------------------%
plot(a,b,xc1+xp1,yc1+yp1,xc2+xp2,yc2+yp2,xc3+xp3,yc3+yp3,'linewidth',2)
axis square</pre>ALBRAA JABERhttps://au.mathworks.com/matlabcentral/profile/authors/9393759-albraa-jabertag:au.mathworks.com,2005:Question/3327052017-03-30T08:11:13Z2017-03-30T08:18:42ZHow to load dataset using url in matlab?<p>how to load the datasets directly using url in matlab 2014.</p>Balaji khttps://au.mathworks.com/matlabcentral/profile/authors/9639400-balaji-ktag:au.mathworks.com,2005:Question/3327062017-03-30T08:13:05Z2017-03-30T08:16:37ZSimple Recurrence in Matlab<p>i have a question:</p><p>"Write a MATLAB program to compute wn for n = 1, 2, . . . , num where num is entered by the user, and display the values in two columns: n, wn (with appropriate headings)."</p><p>The recurrence for this question is W(0) = 25, Wn = W(n-1) +7 -(7*(n+1)/n) n ≥ 2</p><p>for the life of me i cant work out how to take this equation on matlab and take a "num" inputed by the user for the value of n</p><p>ie)
n=1 W(1) = 25 + 7 - 14 = 18</p><p>n=2 W(2) = 18 + 7 - 10.5 = 14.5 and so on</p>Bryce Standkeyhttps://au.mathworks.com/matlabcentral/profile/authors/10051616-bryce-standkeytag:au.mathworks.com,2005:Question/3327042017-03-30T08:06:26Z2017-03-30T08:06:26Zfscanf read multiple data<p>Hi everybody,</p><p>I have a matlab program in which I can read distance data from an Arduino. I received them over Bluetooth. I use fscanf function to read but now I want to read the number of sample and distance as follows:</p><pre class="language-matlab">N.sample (tab) distance
</pre><p>How could I do it?
Thank you</p>Itziar Uzquedahttps://au.mathworks.com/matlabcentral/profile/authors/9763198-itziar-uzquedatag:au.mathworks.com,2005:Question/3327032017-03-30T08:06:20Z2017-03-30T08:06:20ZOutput argument 'ledval1' is not assigned on some execution paths.<p>here is my code:-
function [ledval1,ledval2,ledval3]= checkTorque(Torque)
if Torque < 100;
ledval1 = led.RED;
else if 50 <= Torque < 80;
ledval2 = led.YELLOW;
else ledval3 = led.BLUE;
end
end</p>FENILKUMAR DESAIhttps://au.mathworks.com/matlabcentral/profile/authors/7557179-fenilkumar-desaitag:au.mathworks.com,2005:Question/3327022017-03-30T08:05:34Z2017-03-30T08:05:34ZHow to generate this(discribed below) type of signal using signal generator or PWM inverter in simulink ?<p>Total time =12 sec.</p><p>For 0 to 3 sec - positive constant amplitude (12)</p><p>For 3 to 6 sec - Zero amplitude(off)</p><p>for 6 to 9 sec - negative constant amplitude (-12)</p><p>for 9 to 12 sec - Zero amplitude(off)....</p><p>Please help as soon as possible...thank you in advance.</p>Kelvin Virojahttps://au.mathworks.com/matlabcentral/profile/authors/8519959-kelvin-virojatag:au.mathworks.com,2005:Question/3326892017-03-30T06:30:33Z2017-03-30T07:58:38ZDivide an image along lines and indexing different segments they produces <p>i wanted to plot axes at a specific points but couldn't. so added lines using hline and vline commands. now i have four segments at that point, but since they are not equal i can't use blockproc. but what need is i have got to index the four segments so that i can determine positions with respect to the intersecting points as quadrant position treating that point as origin.And I could also work with drawing normal axes, putting that point at origin and thus dividing the overall image into four indexed quadrants. Any of these two approach will do for me. but sadly i can't seem to do any. I'll be really grateful if anyone could help.Thanks.</p>Tasneem Tabassumhttps://au.mathworks.com/matlabcentral/profile/authors/9128595-tasneem-tabassumtag:au.mathworks.com,2005:Question/3326782017-03-30T05:24:43Z2017-03-30T07:55:23Zhow can we change particular part of binary image which is in white color to black color<p>After converting the gray image to binary, How can we supervise a part of image which is in white to black color</p><p>I have attached image which is a binary image. I want to supervise the highlighted part image which is in red to the green line. I want to supervise by changing white color to black.</p><img src = "/matlabcentral/answers/uploaded_files/73796/binary.jpg">ABDUL WAHID MOHAMMEDhttps://au.mathworks.com/matlabcentral/profile/authors/8816058-abdul-wahid-mohammedtag:au.mathworks.com,2005:Question/2717952016-03-06T21:42:40Z2017-03-30T07:54:00ZHow 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 Desokyhttps://au.mathworks.com/matlabcentral/profile/authors/6688823-ahmed-desokytag:au.mathworks.com,2005:Question/3327012017-03-30T07:53:45Z2017-03-30T07:53:45ZAn error occurred while running the simulation and the simulation was terminated<p>Trouble solving algebraic equations in differential-algebraic system. Singular iteration matrix encountered with step size 3.3730961873744423E-9 at time 0.0. Consider providing more accurate initial conditions. If the problem persists, check the model structure and values of parameters.</p><p>what should I do ?</p>Selahattin Öztürkhttps://au.mathworks.com/matlabcentral/profile/authors/7329755-selahattin-ozturktag:au.mathworks.com,2005:Question/3320872017-03-27T07:55:45Z2017-03-30T07:50:27Zdividing an image in quadrants and find position of origin in different images<p>I have a ball which moves from one position to another. the problem i have is i have to divide the image into four quadrants taking the centroid as origin And Thanks in Advance.</p>Tasneem Tabassumhttps://au.mathworks.com/matlabcentral/profile/authors/9128595-tasneem-tabassumtag:au.mathworks.com,2005:Question/3327002017-03-30T07:49:21Z2017-03-30T07:49:21Zwhat is the significance of learning rate parameter in running average background update procedure?<pre> background(g,h)=(1-alpha)*background_frame(g,h)+alpha*current_frame(g,h);
alpha is the learning rate parameter, chosen between 0 to 1.</pre>Bibhu Prasad Dashttps://au.mathworks.com/matlabcentral/profile/authors/9088446-bibhu-prasad-dastag:au.mathworks.com,2005:Question/3326992017-03-30T07:47:25Z2017-03-30T07:47:25ZCan I change sampling time of block (in Simulink Model) Dynamically?<p>I am using 'Delay' block from 'Discrete' library. I want to change its sampling time dynamically, Is there any way I can do it?</p>Manish Tathodehttps://au.mathworks.com/matlabcentral/profile/authors/9728370-manish-tathodetag:au.mathworks.com,2005:Question/3311052017-03-21T16:44:03Z2017-03-30T07:47:15ZApplication compiler command line<p>Hello,</p><p>is there a possibility to use the application compiler just by command line?
I want to automate the build of an executable using the application compiler. I have to use that compiler because of its nice features: installer, splash screen, Icon, include a lot of files in the deployment etc.</p><p>It would be great if there's any possibility to automate that.</p><p>Regards,</p><p>Christian</p>Christian Dhttps://au.mathworks.com/matlabcentral/profile/authors/7904459-christian-dtag:au.mathworks.com,2005:Question/3297902017-03-14T13:14:08Z2017-03-30T07:41:36ZA function that computes the sum of a geometric series.<p>A FUNCTION that computes the sum of a geometric series 1 + r + r^2 + r^3 + r^4 + ... + r^n, for a given r and N. THe input to the function must be 'r' and 'n'</p><p>Not sure what I am doing wrong, but I was trying to take baby steps and work it into a function but that didn't execute.</p><pre class="language-matlab">% create a vector with n elements all identical to r
v = r*ones(1,n);
% calculate [r r^2 r^3….r^n]
v = cumprod(v);
% sum and add one
geoSum = 1 + sum(v);
</pre>Patrick Bradfordhttps://au.mathworks.com/matlabcentral/profile/authors/9734645-patrick-bradfordtag:au.mathworks.com,2005:Question/2823902016-05-03T17:28:55Z2017-03-30T07:36:22ZHow can I plot y-z plane slices in a 3D volume?<p>I have a series of plots representing the vorticity field behind an aircraft wing, at various downstream distances. Each is a 2D plot, and I would like to display them in 3D, one behind the other, in order to get a full 3D sense of the vorticity field behind the wing. In my first attempt, I made a 3D meshgrid, set it to zero, and filled in 4 z-slices with 4 vorticity plots, and that worked. However, I could not get it to the viewpoint that I wanted. Here is the plot that resulted:</p><img src = "/matlabcentral/answers/uploaded_files/51367/zslices.jpg"><p>This is rather confusing because in this plot, the wing is <b>beneath</b> the plot, and therefore is more likely to confuse the intended audience than do any good. Further, in attempting to change the viewing angle with Matlab's view command, I was not able to get to the desired viewing angle.</p><p>So then I made a second attempt, where instead of plotting z-slices I plot x-slices. This does indeed give me the desired viewing angle, as seen here (where the slices are just zeros):</p><img src = "/matlabcentral/answers/uploaded_files/51366/xslices.jpg"><p>Here, the wing is to the left of the plot, and it's much easier for the audience to get a sense of the full 3D vorticity field. However, I am unable to get the vorticity plots to display. Here is my code:</p><pre class="language-matlab">FullVectorField = zeros(200,14,13);
[x,y,z] = meshgrid(1:1:14, 1:1:200, 1:1:13);
FullVectorField(50,:,:) = vorticity70;
FullVectorField(100,:,:) = vorticity80;
FullVectorField(150,:,:) = vorticity90;
FullVectorField(200,:,:) = vorticity100;
zslice = [];
xslice = [50,100,150,200];
yslice = [];
A = FullVectorField(50,:,:);
figure
slice(x,y,z,FullVectorField,xslice,yslice,zslice);
pbaspect([3 1 1])
axis([0, 200, 0, 14, 0, 13])
colormap jet
colorbar
xlabel('x axis (cm)')
ylabel('y axis (cm)')
zlabel('z axis (cm)')
</pre><p>vorticity70, vorticity80, etc are the matrices containing the data points I would like to plot. Any help in getting the vorticity plots to display along the xslices?
Thanks!</p>Nathan Lauerhttps://au.mathworks.com/matlabcentral/profile/authors/4276425-nathan-lauertag:au.mathworks.com,2005:Question/3315902017-03-23T19:17:21Z2017-03-30T07:36:00ZEnabling a subsystem in a multi rate Simulink model at specific time or with a delay<p>I have a multi rate model in Simulink with 3 rates. A (0.1), B (0.2) and C (0.8). This is meant to run in real-time and the rates are specified based on how long each the Subsystems take to execute.</p><p>The base rate of the model is 0.1. I have 3 subsystems, each running at the separate rates. I am using Enabled Subsystems to control when I execute each one. I have a drawing of what I am attempting to do.</p><img src = "/matlabcentral/answers/uploaded_files/73211/Timing.png"><p>A has a pulse that is sampled at 0.1, 1 sample wide and 12 samples long with 0 delay. This lets it execute once every 1.0 seconds.</p><p>B takes 0.2 seconds to complete and I use a pulse that is sampled at 0.2, 1 sample wide and 6 samples long.</p><p>The problem is with C. I can't figure a way to enable C to start at 0.2. I want the periodic rate of C to be delayed by 0.2. So I tried using a pulse sampled at 0.1, 8 samples wide, 10 samples long, 2 sample delay. The pulse works but the system doesn't get enabled correctly. It enables at 0.8.</p><p>So the question is how do I get Subsystem C to execute with a delayed start?</p>Thomas Marullohttps://au.mathworks.com/matlabcentral/profile/authors/1142235-thomas-marullotag:au.mathworks.com,2005:Question/3326832017-03-30T06:01:16Z2017-03-30T07:33:34ZI tried to implement an algorithm as part of my project using Matlab. But, there are some errors in my coding , Could anyone please correct my code?<pre class="language-matlab">clc;
edges = dlmread('twitnet.csv');
edges(all(edges == 0, 2), :) = [];
[uedges, ~, erow] = unique(edges.', 'stable'); %transpose and stable to give the same output as graph
X = full(sparse(erow(1:2:end), erow(2:2:end), 1, numel(uedges), numel(uedges)));
X = X + X.';
</pre><ul><li>error after this *</li></ul><pre class="language-matlab">for j=X(:,1): X(:,:) %to predict the unknown links through association
x=find(X(:,j)==0);
for k=X(:,2):X(:,:)
[j,k]=CN;
CN=find(X(j,1)==X(j,k)); %consistency calculation
U(j)=X(sum(:,X == 1) ); %no: of linked nodes of jth column
CD=max(CN/U(j));%consistency degree calculation
end
end
</pre><p>Thanks in advance</p>SUNANNA S Shttps://au.mathworks.com/matlabcentral/profile/authors/9869601-sunanna-s-stag:au.mathworks.com,2005:Question/3298872017-03-14T22:06:30Z2017-03-30T07:25:55Zpcshow() in gui<p>Hi all,
I am using the Computer Vision toolbox to visualize point cloud data in a gui, and I keep on running into an error as follows. I call pcshow() and it works one time, but on the second call to pcshow(), I get the very long error</p><pre class="language-matlab">Property assignment is not allowed when the object is empty. Use subscripted assignment to create an array element.
</pre><pre class="language-matlab">Error in vision.internal.pc.initializePCSceneControl>localRotateStopMode (line 79)
btn.State = 'off';
</pre><pre class="language-matlab">Error in hgfeval (line 62)
feval(fcn{1},varargin{:},fcn{2:end});
</pre><pre class="language-matlab">Error in matlab.uitools.internal.uimode/modeControl (line 22)
hgfeval(hThis.ModeStopFcn);
</pre><pre class="language-matlab">Error in matlab.uitools.internal.uimode/set.Enable (line 173)
obj.Enable = modeControl(obj,value);
</pre><pre class="language-matlab">Error in matlab.uitools.internal.uimodemanager>localSetMode (line 173)
set(currMode,'Enable','off');
</pre><pre class="language-matlab">Error in matlab.uitools.internal.uimodemanager/set.CurrentMode (line 111)
obj.CurrentMode = localSetMode(obj,value);
</pre><pre class="language-matlab">Error in activateuimode (line 27)
set(hManager,'CurrentMode',hMode);
</pre><pre class="language-matlab">Error in rotate3d>setState (line 316)
activateuimode(fig,'Exploration.Rotate3d');
</pre><pre class="language-matlab">Error in rotate3d (line 226)
setState(hTarget,arg2,rotatestyle)
</pre><pre class="language-matlab">Error in vision.internal.pc.initializePCSceneControl>initUIMode (line 134)
rotate3d(hFigure,'on');
</pre><pre class="language-matlab">Error in vision.internal.pc.initializePCSceneControl (line 13)
initUIMode(hFigure);
</pre><pre class="language-matlab">Error in pcshow (line 132)
vision.internal.pc.initializePCSceneControl(hFigure, currentAxes, vertAxis,...
</pre><p>This error does not appear when I use pcshow() in contexts other than GUI (eg, direct successive calls to pcshow() with hold on, multiple subplots, etc).</p><p>If anyone has any thoughts I'd appreciate a tip!
Thanks
Yoni</p>Yonatan Chatzinoffhttps://au.mathworks.com/matlabcentral/profile/authors/4331020-yonatan-chatzinofftag:au.mathworks.com,2005:Question/3322472017-03-28T04:22:22Z2017-03-30T07:25:24ZPassing a pointer from Matlab to C<p>I am attempting to pass a matrix from a class in Matlab to a code in C. The code in C cannot be changed and requires a double* to be passed in as an argument. I am trying to use libpointer(...) to modify the matrix into something that can be passed to the C code through a calllib(...) function.</p><p>I cannot post all of the code because it is quite extensive.
The function of the Matlab code reads:</p><pre class="language-matlab">function obj = set.RP(obj, vals)
rho = vals{1};
pres = vals{2};
if strcmp(rho,'None')
rho = obj.R;
end
if strcmp(pres, 'None')
pres = obj.P;
end
disp(rho)
disp(pres)
idxptr = libpointer('doublePtr',[rho, pres]);
disp(idxptr)
calllib('canteraLib', 'thermo_set_RP', obj.thermo, idxptr)
end
</pre><p>The function in the C code reads:</p><pre class="language-matlab">int thermo_set_RP(int n, double* vals)
{
try{
ThermoCabinet::item(n).setState_RP(vals[0], vals[1]);
return 0;
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}
</pre><p>Thank you for your time</p><p>-Emil</p>Emil A Atzhttps://au.mathworks.com/matlabcentral/profile/authors/4567969-emil-a-atztag:au.mathworks.com,2005:Question/3326032017-03-29T18:29:55Z2017-03-30T07:23:01Zargument in function from class<p>I have a question about the function in the class.
I have main.m and my_class.m .
my_class has following function,</p><pre class="language-matlab">classdef my_class
...
function
[x,y,z,w] = get_File(pathname,filename)
completename = fullfile(pathname,filename);
data = load(completename);
x = data(:,1);
y = data(:,2);
.....
end
end
</pre><p>here simply trying to load the file from pathname and filename as input.
But when main.m tries to include this function by</p><pre class="language-matlab">pathname = 'my pathname';
filename = 'my filename';
obj = my_class;
[a,b,c,d] = obj.get_File(pathname,filename);
</pre><p>error shows up as follows</p><pre class="language-matlab">Error using my_class/get_File
Too many input arguments.
</pre><pre class="language-matlab">Error in Untitled (line 4)
[a,b,c,d] = obj.get_File(pathname,filename);
</pre><p>Seems this error will disappear if I set the function as</p><pre class="language-matlab">function
[x,y,z,w] = get_File(~,~) %<--- here its changed
pathname = 'my pathname';
filename = 'my filename';
completename = fullfile(pathname,filename);
data = load(completename);
x = data(:,1);
y = data(:,2);
.....
end
</pre><p>and include in main.m like</p><pre class="language-matlab">obj = Tomography_Tool;
[a,b,c,d] = obj.get_File;
</pre><p>can anybody explain why I got the error and disappear by this modification?</p><p>thank you for your help,</p>kentaro miharahttps://au.mathworks.com/matlabcentral/profile/authors/8110662-kentaro-miharatag:au.mathworks.com,2005:Question/3326982017-03-30T07:15:02Z2017-03-30T07:22:07ZHow to show max and min function of two variables in the figure plot?<p>Hello I have a question, how can I see videos on the figure the max and min Function (with end uses of the Hessian and gradient)? for now use this code to plot the graph</p><pre class="language-matlab">[x,y] = meshgrid(-2:.2:2);
z=(x-1).^2+y.^2
surf(x,y,z)
</pre>riki devhttps://au.mathworks.com/matlabcentral/profile/authors/10051282-riki-devtag:au.mathworks.com,2005:Question/3323892017-03-28T18:56:18Z2017-03-30T07:18:38ZDifferences between the executing environment of mex functions and s functions<p>Hi all,</p><p>I have a problem that has stumped me for nearly two weeks. I have a library that presents a C interface, for the purpose of sending Google protobuf serial information across a network socket. The library works great when called via a C driver program. It also works great when I encapsulate it as a MEX file. And it reliably segfaults when called from a type 2 S function file (but only on Linux - calling it on a Mac as an S function also works beautifully).</p><p>The only information from the stack trace is that the segfault occurs in libstdc++.so.6, in a library call that is name mangled as "resizeEmc". It seems to occur even before any of the code in the S function is actually executed - it's happening during the load or library initialization process. And it happens even if I comment out all of the code in the S Function that actually calls the library code; all that is required for the crash is for there to be a linker dependency on the library in the compiled .mexa64 file.</p><p>So, my question: what is the difference between the executing environment of a plain vanilla MEX file and a Simulink S Function? Does one handle dynamically allocated memory, or global static variables in the library, or something, differently from the other? Is there a difference in how dynamic library dependencies get resolved?</p>Glenhttps://au.mathworks.com/matlabcentral/profile/authors/31653-glentag:au.mathworks.com,2005:Question/3133332016-11-21T19:24:47Z2017-03-30T07:17:03ZCommand window corruption bug in Linux<p>Hi,</p><p>The following code seems to corrupt the user-terminal: background changes color, and characters meld into each other when scrolling.</p><pre class="language-matlab">for i=1:1000,'x',drawnow('update'),pause(0.0001),end
</pre><p>The corruption is repaired, by issuing a clc command.</p><p>The code may look rather pointless, but is in fact an abstraction of what with software project we are working on. We have a C++ codebase with a mex interface. The C++ methods we call can take a long while to compute, and intermediate results are being "mexPrintf"-printed. We issue a 'drawnow('update'),pause(0.0001)' after each newline to have the effect of updating the Command Window, while the C++ code is being run.</p><p>Best regards,
Joris</p>Joris Gillishttps://au.mathworks.com/matlabcentral/profile/authors/6657109-joris-gillistag:au.mathworks.com,2005:Question/3326602017-03-30T01:13:09Z2017-03-30T07:06:47ZIs there an efficient storage/access method for very large cell arrays?<p>I have a large mixed variable excel file (~180MB). I successfully import it into the workspace using xlsread to create a large cell array, C. This takes a long time to import so I thought it might be more efficient to store the data as a .mat file. Running save('filename.mat','C','-v7.3') creates a 21GB file, an expansion from the original by a factor of over 100! The save also takes a very long time. What is going on and is there a more efficient way to store and access large cell arrays?</p>Tom Rhttps://au.mathworks.com/matlabcentral/profile/authors/1530849-tom-rtag:au.mathworks.com,2005:Question/3326672017-03-30T02:58:31Z2017-03-30T07:00:38ZCan't get my Maclaurin Series function to use symsum properly?<p>Here is the code I'm working with currently:</p><pre class="language-matlab">function [ output_args ] = MaclaurinSeries( f,a,tol )
syms x k;
y = subs(f,a)
disp(f)
i=1
error = 1;
while error > tol
f1 = symsum(diff(f,x,k) * (x^k)/(factorial(k)),k,0,i)
error = y - subs(f1,a)
q = subs(f1,a)
i=i+1
end
</pre><p>Every time I run it, no matter how many times I tweak it, I manage to get f1 = 0 every time (which just isn't true). It calculates the derivative properly and everything, but I just don't know why it's returning zero. Any help?</p>Cole Butlerhttps://au.mathworks.com/matlabcentral/profile/authors/8616493-cole-butlertag:au.mathworks.com,2005:Question/3324642017-03-29T06:45:28Z2017-03-30T07:00:34ZWhy function gradmag isn´t working for me?<p>Dear all,</p><p>I have this code:</p><pre class="language-matlab">%addpath('/Applications/MATLAB_R2015b.app/toolbox/dip/common/dipimage')
% dip_initialise
%dipsetpref('imagefilepath','/Applications/MATLAB_R2015b.app/toolbox/dip/images')
%addpath /Applications/MATLAB_R2015b.app/toolbox/dip/common/dipimage/demos
</pre><pre class="language-matlab">img1 = imread('2_ct_bw150.png');
img = rgb2gray(img1);
</pre><pre class="language-matlab">x = 350+350*cos(0:0.1:2*pi)';
y = 350+350*sin(0:0.1:2*pi)';
</pre><pre class="language-matlab">imshow(img1);
hold on
plot([x;x(1)],[y;y(1)],'g')
</pre><pre class="language-matlab">alpha = 0.001;
beta = 0.9;
gamma = 100;
iterations = 50;
</pre><pre class="language-matlab">N = length(x);
a = gamma*(2*alpha+6*beta)+1;
b = gamma*(-alpha-4*beta);
c = gamma*beta;
P = diag(repmat(a,1,N));
P = P + diag(repmat(b,1,N-1), 1) + diag( b, -N+1);
P = P + diag(repmat(b,1,N-1),-1) + diag( b, N-1);
P = P + diag(repmat(c,1,N-2), 2) + diag([c,c],-N+2);
P = P + diag(repmat(c,1,N-2),-2) + diag([c,c], N-2);
P = inv(P);
</pre><pre class="language-matlab">f = gradient(gradmag(img,30));
</pre><pre class="language-matlab">for ii = 1:iterations
% Calculate external force
coords = [x,y];
fex = get_subpixel(f{1},coords,'linear');
fey = get_subpixel(f{2},coords,'linear');
% Move control points
x = P*(x+gamma*fex);
y = P*(y+gamma*fey);
if mod(ii,5)==0
plot([x;x(1)],[y;y(1)],'b')
end
end
plot([x;x(1)],[y;y(1)],'r')
</pre><pre class="language-matlab">hold off
</pre><p>for segmentation, but this error appears:</p><pre class="language-matlab">Undefined function or variable 'gradmag'.
</pre><pre class="language-matlab">Error in ct_snakes (line 32)
f = gradient(gradmag(img,30));
</pre><p>Can you advise me, where is mistake?
Thank you for your answers.</p>Veronikahttps://au.mathworks.com/matlabcentral/profile/authors/5886404-veronikatag:au.mathworks.com,2005:Question/3326872017-03-30T06:27:27Z2017-03-30T06:54:56Zhow can i connect matlab with server<p>how to connect or install matlab on server
and how to get or fetch datas from server using matlab</p>djsparkhttps://au.mathworks.com/matlabcentral/profile/authors/9737981-djsparktag:au.mathworks.com,2005:Question/3326952017-03-30T06:53:17Z2017-03-30T06:53:17ZSimulate autonomous robot with distance sensors<p>I would like to simulate a robot with obstacle detect sensors(ultrasonic or infrared) as in the below video:
https://www.youtube.com/watch?v=dDgJFtziJRQ</p><p>or this:
https://www.youtube.com/watch?v=x57SXD2xl5E</p><p>I have seen some papers and see that lots of people using MATLAB as simulator for autonomous robot controlling task. However I didn't find any distance sensors in Simulink or MATLAB functions. There are some third side tools developed sensors, but what I want to do is design my own robot as in the video, which I can determine the number and position of sensors on the robot.</p><p>I bet MATLAB have support this functions, for so many people select it as prior selection for simulation.</p><p>Does anyone now how to do the simulation task in the video?
Thanks a lot!</p>Lawren Linhttps://au.mathworks.com/matlabcentral/profile/authors/9106749-lawren-lintag:au.mathworks.com,2005:Question/3326942017-03-30T06:53:11Z2017-03-30T06:53:11ZComment reconnaître les code sur Matlab ? How and where do you know all the different types of Matlab code?<p>Bonjour Hello!
Comment et ou peut t'on connaitre tout les différent types de code de Matlab ?
How and where do you know all the different types of Matlab code?</p>Joseph Rasteirohttps://au.mathworks.com/matlabcentral/profile/authors/10009707-joseph-rasteirotag:au.mathworks.com,2005:Question/3326932017-03-30T06:51:53Z2017-03-30T06:54:35Zserial communication using dSpace microautobox II<p>I am using the serial line of the dSpace microautobox II 1401/1511 for serial communication. I have 5 bytes of data that is to be received by the dSpace hardware and these 5 bytes are to be assigned to 5 variables in my simulink model. The bytes are given by me through another device that is connected to the dSpace. The problem is when I run the simulink model only the first variable is getting assigned with the data. I want all the 5 bytes to be received at once . Can someone help me with the SW FIFO buffer in dSpace that takes the data from the transmitter and copies to RXBytes of dSpace ? I am using this for the first time.
Thanks in advance.</p>KEERTHITHEJA SChttps://au.mathworks.com/matlabcentral/profile/authors/6285974-keerthitheja-sctag:au.mathworks.com,2005:Question/3326382017-03-29T21:49:58Z2017-03-30T06:50:27Zcan you give me any idea about how to use "find" command without using nested loops in matlab in this case??<p>I have a 3d matrix and I want to set a single value for <b>specific ranges</b> of values without using nested loops. how to Use "find" command to find that values inside that matrix which is 500*500*3 size and if we supposed that the values in the original matrix are between 0 and 100 I want to divide it to 10 ranges so values from (0 to 10) will be set to be as (5) ... can you give me any idea about how to use " <b>find</b>" command <b>without using nested loops</b> in this case..??</p>Hasan Gencohttps://au.mathworks.com/matlabcentral/profile/authors/9849263-hasan-gencotag:au.mathworks.com,2005:Question/3247132017-02-13T07:40:42Z2017-03-30T06:45:06ZIs it possible to combine SURF and LBP feature vector? Thanks...<p>I want to know whether is it possible to combine SURF and LBP face feature vector.. If so please do help me out how can i do?</p>S J Jhttps://au.mathworks.com/matlabcentral/profile/authors/9630227-s-j-jtag:au.mathworks.com,2005:Question/3326502017-03-29T22:31:51Z2017-03-30T06:43:55ZEncoder position derivative Simulink<p>Hi, I'm new of simulink and I'm doing some test on a DC motor connected, through a servomechanism, to a disk.The position of the disk is given by an encoder. A block in Simulink gives me out the number of rounds of the disk. How could I derivate this data to obtain velocity? I know the sample time of the encoder; but I do not manage to:
-save (online measuraments) the samples,
-make a difference between the new sample and the previous one
-at the end devide by sample time.
What kind of block could I use to save a sample each sample interval?
Thank you very much every one.</p>Marcohttps://au.mathworks.com/matlabcentral/profile/authors/5829125-marcotag:au.mathworks.com,2005:Question/3326432017-03-29T22:12:21Z2017-03-30T06:43:14Zhow to save edges in vector<p>I'm trying to save the edges in vector in .mat file how can i do that?</p>Dina Basudanhttps://au.mathworks.com/matlabcentral/profile/authors/8833451-dina-basudantag:au.mathworks.com,2005:Question/3326912017-03-30T06:42:22Z2017-03-30T06:42:22Zbayesian network toolbox 설치 방법<p><a href = "mailto:kija1234@naver.com">kija1234@naver.com</a>로 Bayesian Network Toolbox 설치 파일을 보내주십시오. 설치 사이트가 막혔습니다.</p>jeongan kimhttps://au.mathworks.com/matlabcentral/profile/authors/8722023-jeongan-kimtag:au.mathworks.com,2005:Question/1163552014-02-16T15:54:43Z2017-03-30T06:34:28Zmatlab code for simple LSB audio steganography<p>hi
need a simple code for simple LSB audio steganography</p>Mamathahttps://au.mathworks.com/matlabcentral/profile/authors/5067750-mamathatag:au.mathworks.com,2005:Question/3318222017-03-25T00:28:06Z2017-03-30T06:34:05Zpeak width classification by width<p>In this plot peak 2,4 have different widths than other peaks . is there is a way to find peaks widths and classify them according to that ?</p><img src = "/matlabcentral/answers/uploaded_files/73316/image.jpeg">sarmad mhttps://au.mathworks.com/matlabcentral/profile/authors/6551379-sarmad-m