https://www.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2017-02-28T14:32:09Ztag:www.mathworks.com,2005:Question/3273332017-02-28T14:29:22Z2017-02-28T14:29:22ZThe code metrics for each and every metric after a Polyspace verification run have the same value. In the image attached, all the function metrics gave the same value, 653. Is this normal and if so what should be done to obtain the correct value?<img src = "/matlabcentral/answers/uploaded_files/71024/CodeMetrics.PNG">Sudarshan Sureshhttps://www.mathworks.com/matlabcentral/profile/authors/9109873-sudarshan-sureshtag:www.mathworks.com,2005:Question/3272882017-02-28T09:54:49Z2017-02-28T14:32:09ZSum if value in other column > 0 until next 0<p>How can i achieve the following:
I have a matrix containing:</p><pre class="language-matlab">A B
346.2 0
1.5 1
1.2 2
2.3 2
1.2 2
1.4 2
1.5 1
217.3 0
2.9 1
1.3 2
0.9 2
1.2 2
1.9 1
92.9 0
</pre><p>How do i calculate the sum of values from A when B > 0, only until the next 0.
Then do the same calculation for the values after the second 0.</p><p>The result should be: A1 = 1.5 + 1.2 + 2.3 + 1.2 + 1.4 + 1.5 = 9.1</p><p>A2 = 2.9 + 1.3 + 0.9 + 1.2 + 1.9 = 8.2</p>Arashidushttps://www.mathworks.com/matlabcentral/profile/authors/9793581-arashidustag:www.mathworks.com,2005:Question/3273322017-02-28T14:05:23Z2017-02-28T14:27:13ZGenerate trajectories with same tangent in a specific point<p>Hi,</p><p>I want to simulate the movements of 3 robots/agents in space and I would like to generate 3 different trajectories which have one constraint: in a certain time T the all the trajectories must have the same tangent.</p><p>I want something like in the following picture:</p><img src = "/matlabcentral/answers/uploaded_files/71022/Screenshot%20from%202017-02-28%2008:59:30.png"><p>Could you please help me figuring out how to do that? I can use MATLAB and also SIMULINK.</p><p>Thanks a lot.</p>Fabrizio Schianohttps://www.mathworks.com/matlabcentral/profile/authors/2627116-fabrizio-schianotag:www.mathworks.com,2005:Question/3273172017-02-28T12:08:48Z2017-02-28T14:22:26Zhow to save output of for loop<p>Hi, I have a matrix A=54×100. For some specific condition I perform an operation on each row of “A” with the help of for loop. now I need to save the output of this for loop. I tried like</p><pre> S=zeros(54,100);
for i=1:54;
Ri=A(i,:);
answer=mean(reshape(Ri,5,20),1);
S(i)=answer;
end</pre><p>but not succeed.</p>Safi ullahhttps://www.mathworks.com/matlabcentral/profile/authors/9541530-safi-ullahtag:www.mathworks.com,2005:Question/3272722017-02-28T08:21:41Z2017-02-28T14:21:02ZMatlab workspace window: Focus to variable by pressing a key<p>Hello,</p><p>several applications (e.g. Windows explorer) provide a function which focuses on a certain list entry if a key is pressed. E.g. if Key 'k' is pressed, the list selection and focus jump to the first list element beginning with 'k' or 'K'. I am missing this functionality in Matlab especially in the Matlab workspace window.</p><p>Is it planned to implement this functionality in coming Matlab versions?</p><p>wewa</p>wewahttps://www.mathworks.com/matlabcentral/profile/authors/6390821-wewatag:www.mathworks.com,2005:Question/3271662017-02-27T16:52:48Z2017-02-28T14:17:38ZHow to minimize the 12th norm of a difference vector?<p>Hi everybody,
I have two vectores, lets say x and y.
I calculate the difference vector d=x-y;
I want to minimize d through the 12-norm of the difference (Euclidean distance) vector over 100 iterations.
Is there anyone who could help me?</p><p>Kind regards,
Joaquim</p>Joaquimhttps://www.mathworks.com/matlabcentral/profile/authors/5352352-joaquimtag:www.mathworks.com,2005:Question/2154292015-05-06T18:53:07Z2017-02-28T14:17:01Zhistogram with two sets of data <p>Hello, I want to make an histogram exactly like the image here. Have you an idea ?</p><img src = "/matlabcentral/answers/uploaded_files/30464/hist.png">Alexandre Williothttps://www.mathworks.com/matlabcentral/profile/authors/6260269-alexandre-williottag:www.mathworks.com,2005:Question/3273192017-02-28T12:46:57Z2017-02-28T14:13:03ZSearch path changes to default when I run script (ubuntu)<p>I'm running R2016b on ubuntu and when I run a script the search path changes back to default. I have added a startup.m to add the desired path so it is correct when I start MATLAB.</p><p>I have also changed the initial working folder in preferences but when I restart MATLAB that reverts back to what it was. Also, I have deleted the default folder (/Docs/MATLAB) but when I start MATLAB it remakes it.</p><p>It seems that every time I make a change to any preferences at all on MATLAB they are never recorded and disappear when I restart.</p><p>Thanks for your help,
Jasper</p>Jasper Jameshttps://www.mathworks.com/matlabcentral/profile/authors/8728597-jasper-jamestag:www.mathworks.com,2005:Question/3273292017-02-28T13:45:08Z2017-02-28T14:05:22ZLogin an Encrypted Website From Created User Interface <p>I created a simple login page (Graphical User Interface). I need to login to a website with username and password from typing on this GUI. Which code & syntax could help me?</p>bekir aydinhttps://www.mathworks.com/matlabcentral/profile/authors/9821526-bekir-aydintag:www.mathworks.com,2005:Question/3273312017-02-28T14:04:59Z2017-02-28T14:09:04ZCalculating bivariate polynomial coefficients in Matlab!<p>Hello all,</p><p>I have the following bivariate polynomial system:</p><p>Xa= ax1 + ax2*X + ax3*Y + ax4*X^2 + ax5*Y^2 + ax6*XY</p><p>and</p><p>Ya= ay1 + ay2*X + ay3*Y + ay4*X^2 + ay5*Y^2 + ay6*XY</p><p>This system acts as a distortion model in pixel coordinate to real world coordinate camera system.
I know the pixel coordinates and the actual distances of the calibration pattern from the camera and I need to extract the coefficients (ax1 ... ax6) (ay1 ... ay6) of the bivariate polynomial system using least squares. Since I have not find any ready made function for bivariate polynomial fitting, could you please have any ideas on how to do that?</p><p>Thank you in advance!</p>Polychronishttps://www.mathworks.com/matlabcentral/profile/authors/282788-polychronistag:www.mathworks.com,2005:Question/3273262017-02-28T13:20:21Z2017-02-28T14:03:35ZSubtracting elements within constraints<p>Hi all,</p><p>I have a vector and I subtract each element from the previous one using the cumsum function like this</p><p>B=bsxfun(@minus, A(1,:), cumsum(A(2:end,:)));</p><p>However, the values should be within some particular range (min=1.3 and max=11.7).</p><p>So I used this command:
B = max(1.3, min(11.7,(B));</p><p>The results before and after the constraint are:</p><pre class="language-matlab">if true
8.896388843 8.896388843
8.896388843 8.896388843
8.896388843 8.896388843
8.896388843 8.896388843
8.896388843 8.896388843
8.896388843 8.896388843
8.896388843 8.896388843
8.896388843 8.896388843
8.896388843 8.896388843
8.896388843 8.896388843
8.896388843 8.896388843
8.896388843 8.896388843
8.896388843 8.896388843
8.896388843 8.896388843
8.896388843 8.896388843
8.896388843 8.896388843
8.896388843 8.896388843
8.899933525 8.899933525
8.899933525 8.899933525
9.315786868 9.315786868
9.743121832 9.743121832
10.41242251 10.41242251
10.8175055 10.8175055
10.83527583 10.83527583
10.84671199 10.84671199
10.92675208 10.92675208
11.31588974 11.31588974
11.7 11.7
11.7 11.7
11.7 11.7
11.74200832 11.7
11.98760913 11.7
12.63688627 11.7
13.29973854 11.7
14.17196338 11.7
14.57395341 11.7
15.06132339 11.7
14.64806384 11.7
14.65909789 11.7
14.67088601 11.7
14.39082286 11.7
13.95882417 11.7
13.52282417 11.7
13.09282417 11.7
12.54482417 11.7
12.00682417 11.7
11.52282417 11.52282417
11.01882417 11.01882417
end
</pre><p>My problem is that When the value in the vector goes up I dont have a problem as I get the maximum value. However, when the vector start decreasing I want something different:</p><pre class="language-matlab">if true
15.06132339 11.7
14.64806384 11.7 (I want the value 11.7-(15.06132339-14.64806384)= 11.27
end
Same thing for all the values when decreasing
</pre><p>is there any way to do this?</p><p>I don't know if you get my question</p><p>thanks anyway!</p>Nikolas Spiliopouloshttps://www.mathworks.com/matlabcentral/profile/authors/9122757-nikolas-spiliopoulostag:www.mathworks.com,2005:Question/3273302017-02-28T13:57:48Z2017-02-28T14:04:19Z Im trying to find the summation from k=1 to 25, with the equation being k^2. This is my code, how do i get it do only display the final number only, not the ones in between?<p>I tried disp(Sum) at the end, but tells me that index exceeds matrix dimensions.
Sum=0;</p><p>for k=1:25;</p><p>Sum = Sum + k.^2</p><p>end</p>Danielhttps://www.mathworks.com/matlabcentral/profile/authors/9531684-danieltag:www.mathworks.com,2005:Question/3273272017-02-28T13:39:46Z2017-02-28T13:57:02ZDelete empty rows from Cell array <p>Hi, I have this Cell array and i want to remove all the [] rows from all pages. I have tried almost everything related to this topic but nothing worked
Thank you in advance for your help.</p><p>val(:,:,1) =</p><pre> [44]
[33]
[]
[]
[]
[]
[]
[]
[]
[]</pre><p>val(:,:,2) =</p><pre> [44]
[33]
[]
[]
[]
[]
[]
[]
[]
[]</pre><p>val(:,:,3) =</p><pre> []
[]
[11]
[44]
[33]
[]
[]
[]
[]
[]</pre><p>val(:,:,4) =</p><pre> []
[]
[11]
[44]
[33]
[]
[]
[]
[]
[]</pre><p>val(:,:,5) =</p><pre> []
[]
[11]
[44]
[33]
[]
[]
[]
[]
[]</pre><p>val(:,:,6) =</p><pre> []
[]
[]
[]
[]
[44]
[22]
[]
[]
[]</pre><p>val(:,:,7) =</p><pre> []
[]
[]
[]
[]
[44]
[22]
[]
[]
[]</pre><p>val(:,:,8) =</p><pre> []
[]
[]
[]
[]
[]
[]
[11]
[22]
[33]</pre><p>val(:,:,9) =</p><pre> []
[]
[]
[]
[]
[]
[]
[11]
[22]
[33]</pre><p>val(:,:,10) =</p><pre> []
[]
[]
[]
[]
[]
[]
[11]
[22]
[33]</pre>Farah Saleemhttps://www.mathworks.com/matlabcentral/profile/authors/7135267-farah-saleemtag:www.mathworks.com,2005:Question/2669882016-02-07T12:54:49Z2017-02-28T13:56:21Zhow to flip a segmented image along the major axis<p>I and my friends are doing project on skin cancer detection using image processing, We completed upto segmentation, now we have to find area of non overlapped region of the segmented image.For this we have to flip the image along its major axis andminor axis. so please help us in this matter.</p><p>Advance thanks.</p>narayana reddyhttps://www.mathworks.com/matlabcentral/profile/authors/7363732-narayana-reddytag:www.mathworks.com,2005:Question/3272682017-02-28T08:09:29Z2017-02-28T13:53:50ZHow can I label contour lines in meshc 3D-plot?<p>I have made a 3D-plot using meshc. I want to add labels to the contour lines. The handle return by the meshc is</p><pre class="language-matlab">h =
2x1 graphics array:
</pre><pre> Surface
Contour</pre><p>So I have tried to edit the properties using following command but it didn't work.</p><pre> h.ShowText='on';</pre><p>What is the right way to do it?
Thanks</p>Ibrahim Wasiqhttps://www.mathworks.com/matlabcentral/profile/authors/5158144-ibrahim-wasiqtag:www.mathworks.com,2005:Question/3272922017-02-28T10:08:54Z2017-02-28T13:53:40ZStop button (GUI)<p>Hi,</p><p>I have this code below(except for a few beginning lines) and I have problems because I want the measurement to stop when I click on the Stop button, but it doesn't work. Any idea of the problem?</p><pre> % --- Executes just before Medida_Serial_hcsr04 is made visible.
function Medida_Serial_hcsr04_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Medida_Serial_hcsr04 (see VARARGIN)</pre><pre> % Choose default command line output for Medida_Serial_hcsr04
handles.output = hObject;</pre><pre> set(handles.guardar,'Enable','off'); </pre><pre> handles.stop=false;
% Update handles structure
guidata(hObject, handles);</pre><pre> % UIWAIT makes Medida_Serial_hcsr04 wait for user response (see UIRESUME)
% uiwait(handles.figure1);</pre><pre> % --- Outputs from this function are returned to the command line.
function varargout = Medida_Serial_hcsr04_OutputFcn(hObject, eventdata, handles) </pre><pre> varargout{1} = handles.output;</pre><pre> % --- Executes on button press in Medir.
function Medir_Callback(hObject, eventdata, handles)
% hObject handle to Medir (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.Abrir,'Enable','off');
%handles.stop=0;
cla reset; %Limpiar la grafica cada vez que se hace click</pre><pre> s = abrir_puerto();</pre><pre> handles.x=1:100;
handles.h=animatedline('Marker','o','LineWidth',1,'Color','b');
xlabel('Number of samples');
ylabel('Distance (cm)');</pre><pre> i=0; %Hay que recoger aqui el valor del que le pasa el stop button
while handles.stop==false
handles.distancia(i)=fscanf(s,'%d');
addpoints(handles.h,i,handles.distancia(i));
drawnow;
i=i+1;
end</pre><pre> set(handles.guardar,'Enable','on');
set(handles.Abrir,'Enable','on');
guidata(hObject,handles);
cerrrar_puerto(s);</pre><pre> % --- Executes on button press in guardar.
function guardar_Callback(hObject, eventdata, handles)
% hObject handle to guardar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
dist = handles.distancia;
guardar_archivo(dist);</pre><pre> % --- Executes on button press in Abrir.
function Abrir_Callback(hObject, eventdata, handles)
% hObject handle to Abrir (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Abrir_fichero();</pre><pre> % --- Executes on button press in stop.
function stop_Callback(hObject, eventdata, handles)
% hObject handle to stop (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)</pre><pre> % Hint: get(hObject,'Value') returns toggle state of stop
handles.stop=true;
guidata(hObject,handles);</pre><p>Thank you</p>Itziar Uzquedahttps://www.mathworks.com/matlabcentral/profile/authors/9763198-itziar-uzquedatag:www.mathworks.com,2005:Question/3273202017-02-28T12:53:56Z2017-02-28T13:51:58Zi want to use my system webcam as input to the videoinput but unable to fine the adaptors on the matlab list so please tell me to find. i am using matlab2016a <p>Error using videoinput (line 233)
There are no devices installed for the specified ADAPTORNAME. See IMAQHWINFO.</p><p>Error in webcamera_dct (line 5)
vid = videoinput('qimaging',1);</p>sujai phttps://www.mathworks.com/matlabcentral/profile/authors/9813500-sujai-ptag:www.mathworks.com,2005:Question/3269472017-02-26T13:20:15Z2017-02-28T13:50:29ZHow to optimize a non linear single objective function constrained with only integer variables using genetic algorithm? <p>For my problem which is a single objective, I am using genetic algorithm. In my problem, I have
five different variables (all integer values) and their values are listed
below.</p><p>Variable 1= 1500, 2000, 2500, 3000 and 3500.</p><p>Variable 2= 50, 55, 60, 65,.....100.</p><p>Variable 3= 5, 6, 7,...15.</p><p>Variable 4= 5, 6, 7,...15.</p><p>Variable 5 = 5, 6, 7,...15.</p><p>I want to use binary GA (not real GA), but I am facing an issue in
their representation using binary bits due to the precision factor.</p>Ripunjoy Gogoihttps://www.mathworks.com/matlabcentral/profile/authors/3767918-ripunjoy-gogoitag:www.mathworks.com,2005:Question/3273212017-02-28T12:59:52Z2017-02-28T13:46:47ZSlice the fingerprint image into equal size patches <pre class="language-matlab">if true
% code
end
</pre>HARI PRASAD GUDITIhttps://www.mathworks.com/matlabcentral/profile/authors/9701028-hari-prasad-gudititag:www.mathworks.com,2005:Question/3269452017-02-26T13:16:38Z2017-02-28T13:44:08ZHi all, i get this error at using GA optimtool " error running optimization. matrix dimensions must agree" so kindly can any one explain what is the problem.<p>I have nonlinear constrained optimization problem (optimum selection of relay settings). when trying to solve it using genetic algorithm (using optimtool box) it generates this error
"error running optimization. matrix dimensions must agree"
although it is solvable using fmincon with the same objective and constraints functions.</p>mohamed afifihttps://www.mathworks.com/matlabcentral/profile/authors/7550295-mohamed-afifitag:www.mathworks.com,2005:Question/3273282017-02-28T13:43:44Z2017-02-28T13:43:44ZC2000 Support Package - Can't get CLA code to inline parameters<p>Hi - I am trying to use the CLA on a F2035 development board with DRV8321 and am having issues. Some background:
1) The CLA example model c28035pmsmfoc_cla.slx builds and runs perfect my hardware.
2) I have read all the documentation I can find. As a result, I made sure that "Inline" parameters option was checked at the highest level (and all levels underneath).
3) All inputs to CLA function block are of object class tic2000demospkg.Signal and CpuToCla1MsgRAM and the outputs are Cla1MsgToCpuRAM.
4) I did notice there are 2 instances of the object class tic2000demospkg.Signal in the pull down menu, not sure if this is related.</p><p>It seems that no matter what I do the .cla file generated will reference the Simulink global variables modelname_B and modelname_DWork.</p><p>Help is much appreciated. I need to figure this out quick I have wasted too much time on this.</p><p>Thanks</p>Chris Jablonskihttps://www.mathworks.com/matlabcentral/profile/authors/2939049-chris-jablonskitag:www.mathworks.com,2005:Question/3269902017-02-26T17:57:18Z2017-02-28T13:35:55ZUsing a letter as a case in a switch-case code<p>I'm trying to write a switch-case code that converts degrees and I ask for user input of F or C for determining which temperature to convert to. How do I get the code to accept F or C in the case? I know it has to do something with converting the letter to a string but I can't for the life of me find how to do it anywhere. This is my code right now:</p><pre class="language-matlab">temp = input('Input a temperature: ');
unit = input('Do you want to convert to Fahrenheit or Celsius (F/C): ');
switch unit
case F
temp=temp*1.8+32;
x=['The temperature is ',num2str(temp), ' degrees fahrenheit'];
disp(x)
case C
temp=(temp-32)*5/9;
y=['The temperature is ',num2str(temp), ' degrees celsius']
disp(y)
end
</pre>Michael Fosterhttps://www.mathworks.com/matlabcentral/profile/authors/9571898-michael-fostertag:www.mathworks.com,2005:Question/735392013-04-25T11:51:16Z2017-02-28T13:32:43ZHow can I hide signals in simulink so that they do not show when using xPC Target.<p>Hi,</p><p>I am looking for a way to hide the unneeded signals from simulink, when the model is compiled to xPC target. We use xPC Target C-API with Target PC to connect, dowload and start the model. We also initialize logging through C-API, but the problem is that our models are very large and sometimes it is very hard or even impossible to find the exact signal that we want to log.</p><p>So is it possible to hide signals for example within specific subsystem in Simulink?</p>Anttihttps://www.mathworks.com/matlabcentral/profile/authors/1384538-anttitag:www.mathworks.com,2005:Question/3273242017-02-28T13:13:15Z2017-02-28T13:29:34ZMATLAB GUI Check button and wave bands representation<p>Hi guys,</p><p>I am currently working on a signal processing GUI to create a stress indicator and i have attached my code.
At the moment i am working with a data set from the internet which is attached (testsleep data.csv), however i have not connected my EEG raw data reading code yet to connect the headset to the GUI.</p><p>The data is coming through this code: filename =</p><pre class="language-matlab">'/Users/sufyanpatel/Downloads/eeg/testSleepData.csv';
and is stored in: handles.data = VarName4;
handles.mean = mean(handles.data);
</pre><p>Currently i am working on showing the Alpha, Beta and Theta waves on the graph when they are checked on. I need assistance on the check buttons so when one checkbox is ticked the other two cannot be clicked on, therefore only allowing one checkbox to be ticked at a time.</p><p>Additionally when i click the start button, the raw data is continuously running but the bar graphs shows the mean of all three data bands as the same number which is incorrect. They should be different and i cannot figure out what code is needed. The problem is in this lines of code:</p><pre class="language-matlab">set(handles.axes2,'XTickLabel',{'Alpha'});
bar(handles.axes2, [mean(ctr+1:ctr+100) mean(ctr+1:ctr+100) mean(ctr+1:ctr+100)]);
set(handles.axes2,'XTickLabel',{'Beta','Theta','Alpha'});
</pre><p>I know crt+1:ctr+100 is incorrect but i put it just to test the bar graph.</p><p>Please do not mind the beta code that i have placed a %, this is just to test the alpha band.</p>sufyan patelhttps://www.mathworks.com/matlabcentral/profile/authors/9170995-sufyan-pateltag:www.mathworks.com,2005:Question/3272362017-02-28T04:31:57Z2017-02-28T13:26:07ZHow to use binary bits in genetic algorithm for integer constraints?<p>I have five different integer constraints. But when I select bit string option in matlab ga toolbox, I get the below error:</p><p>Optimization running.
Error running optimization.
Problem has integer constraints. PopulationType must be set to 'doubleVector'.</p><p>Also, I am not allowed to use single point/two point crossover. By default matlab is using scattered crossover when there are integer constraints. If it is possible to use binary bits for integer constraints in matlab ga toolbox, where may I set the size of the binary bits? Please help.</p>Ripunjoy Gogoihttps://www.mathworks.com/matlabcentral/profile/authors/3767918-ripunjoy-gogoitag:www.mathworks.com,2005:Question/227442011-12-01T04:52:36Z2017-02-28T13:23:06ZHow to bold, italics sentence using fprintf in matlab?<p>How to bold , italics sentence using fprintf in matlab</p>komal Bhandarihttps://www.mathworks.com/matlabcentral/profile/authors/3085461-komal-bhandaritag:www.mathworks.com,2005:Question/3273162017-02-28T12:03:36Z2017-02-28T13:20:18ZHow to separate string data and convert it to number?<p>I have a problem to separate this data
BE1234U1234
which B is the begin of counting real time count for sensor, i.e. encoder motor and ultrasonic distance, E for encoder, and U for ultrasonic distance.</p><p>I'm using Altera to acquired data and read it to MATLAB. But I can only separate the data from B1234E for encoder only. How can I read and separate the data into 1234 for encoder and 1234 for ultasonic distance respectively?</p><p>Thank You,</p><p>Setiawan</p>Setiawan Putra Hendratnohttps://www.mathworks.com/matlabcentral/profile/authors/8726118-setiawan-putra-hendratnotag:www.mathworks.com,2005:Question/3273252017-02-28T13:13:54Z2017-02-28T13:15:30Zbatch process images on Linux Ubuntu<p>Hi,
I'm a Matlab rookie and I successfully managed to run a code in Matlab for superpixels creation. Now I am trying to batch process the same code for multiple images (respectively left.jpg and right.jpg and I'm hitting a wall.</p><p>I am using Matlab in no java mode as follow:
TERMINAL></p><pre> matlab -nojvm -nodisplay </pre><p>Then I am trying to type in this which gives me an error (input character is not valid)</p><pre class="language-matlab">> PairModel$Img1"_"$Img2.out << EOF
</pre><p>Img1 and Img2 should be the following images I want to batch process: left.jpg and right.jpg but how do I tell that to Matlab?</p><p>Then I would like to call in the first task that generated the superpixels using the following code:</p><pre class="language-matlab">Fdir ='/works/scratch/TestMultipleImage/$Task';
WlrName = [ '$Task' '_' '$Img1' '_' '$Img2'];
PairList = [];
PairList = [ PairList; {'$Img1','$Img2'}];
</pre><p>The '$Task' is that the one I used to generate the superpixels? If yes, do I write the name of that function
instead of '$Task'?</p><p>Thanks for any help,</p><p>Than you.</p>Joe Levyhttps://www.mathworks.com/matlabcentral/profile/authors/9723250-joe-levytag:www.mathworks.com,2005:Question/3267072017-02-24T10:01:24Z2017-02-28T13:10:02ZActivation still required after silent activation succeeded (MATLAB r2016b)<p>I have recently performed a silent install of MATLAB r2016b on a remote computer that does not run any X server. I used the file installation key provided by Mathworks website.</p><p>The installation process ended just fine and, afterwards, I ran</p><pre class="language-matlab">activate_matlab.sh -propertiesFile activate.ini
</pre><p>Getting a "Silent activation succeeded" message. Everything looks just fine, however when I run</p><pre class="language-matlab">matlab -nodisplay
</pre><p>I just get this output:</p><pre class="language-matlab">---------------------------------------------------------------------------
Error: Activation cannot proceed. You may either:
1. Set an X11 display, and restart the activation process
2. Use the silent activation feature
3. Activate using the license center
---------------------------------------------------------------------------
</pre><p>as if the activation was not successful. My license is the Academic - Total Headcount. Where did I go wrong?</p><p>In my activation.ini file I specified the following directives:</p><pre class="language-matlab">isSilent=true
activateCommand=activateOffline
licenseFile=/full/path/to/license/file.lic
installLicenseFileDir=/full/path/to/license/install/folder
installLicenseFileName=license.lic
</pre>Giuseppe Maria D'Aucellihttps://www.mathworks.com/matlabcentral/profile/authors/7179319-giuseppe-maria-d-aucellitag:www.mathworks.com,2005:Question/3273232017-02-28T13:09:41Z2017-02-28T13:09:41Zquestion in optical flow for video tracking <p>q1 - why w need to compute the mean in optical flow , when we trying to tracking cars in video</p><p>q2- i need some one to help me in tracking object in matlab version 2010 , urgently</p><p>thanks for all</p>samir mohamdhttps://www.mathworks.com/matlabcentral/profile/authors/9577910-samir-mohamdtag:www.mathworks.com,2005:Question/3272752017-02-28T08:36:47Z2017-02-28T13:08:15ZHow to make a curve smooth in spline block<p>Hi, i need to make a cam model in simulink so i use a spline block to model the curve.Here is my code:</p><pre class="language-matlab">clear
clc
s=0:0.005:1;i=0;
for t1=0:0.005:0.125;
i=i+1;
s(i)=(pi*t1-0.25*sin(4*pi*t1))/(pi+4);
end
for t2=0.130:0.005:0.875;
i=i+1;
s(i)=(2+pi*t2-(9/4)*sin((pi+4*pi*t2)/3))/(pi+4);
end
for t3=0.880:0.005:1
i=i+1;
s(i)=(4+pi*t3-0.25*sin(4*pi*t3))/(pi+4);
end
T=0:0.005:1;
% plot(T,s);
r=1:1:21;n=0;
for m=1:5:201
n=n+1;
r(n)=(232^2+264.2^2-2*232*264.2*cos(deg2rad(20.69+18.5*s(m))))^(1/2);
end
th=60:(110/40):170;
x1=r.*cos(deg2rad(th));
y1=r.*sin(deg2rad(th));
% figure(2);
th2=170:0.5:190;
x2=169.*cos(deg2rad(th2));
y2=169.*sin(deg2rad(th2));
th3=300:(-110/40):190;
x3=r.*cos(deg2rad(th3));
y3=r.*sin(deg2rad(th3));
x3=fliplr(x3);
y3=fliplr(y3);
th4=-60:5:60;
x4=94.55.*cos(deg2rad(th4));
y4=94.55.*sin(deg2rad(th4));
x=[x1,x2,x3,x4];
x=x';
y=[y1,y2,y3,y4];
y=y';
% subplot(5,3,1);
% plot(x,y);
% axis([-150,150,-150,150]);
CAM=[x,y];
</pre><img src = "/matlabcentral/answers/uploaded_files/70988/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202017-02-28%20%E4%B8%8B%E5%8D%884.34.45.png"><p>But the curve is not smooth,please tell me what is the problem.</p>dk2507https://www.mathworks.com/matlabcentral/profile/authors/8037061-dk2507tag:www.mathworks.com,2005:Question/3269252017-02-26T09:11:15Z2017-02-28T13:04:35Zerror in nlparci in MatlabR2016b: The number of observations must exceed the number of parameters.<p>I have an error in nlparci in MatlabR2016b:</p><pre class="language-matlab">Error using nlparci (line 34)
The number of observations must exceed the number of parameters.
</pre><p>The syntax I use:</p><pre> ci=nlparci(Y1pars,res1,'jacobian',J1);</pre><p>It worked fine in Matlab R2015a.</p><p>when debugging, it seems that in nlparci in</p><pre class="language-matlab">line 32: [m,n] = size(J);
</pre><p>J should refer to J1 but it refers to the string 'jacobian'. is this a bug?
I realized nlparci in R2015a is different.</p>Efrat Sassonhttps://www.mathworks.com/matlabcentral/profile/authors/4205505-efrat-sassontag:www.mathworks.com,2005:Question/3273222017-02-28T13:00:03Z2017-02-28T13:00:03ZUsing encoder to trigger a sensor (Data Acquisition Toolbox)<p>I am using a 64bit version of Matlab and therefore the session based interface. The HW consists of an NI 9205 module. I have an encoder, which provides a number of impulses per revolution and I want to use it to extract a sample from the displacement sensor every time the encoder gives me a signal.</p><p>I reckon I have to use a listener and a callback function, however I cannot really figure it out. Maybe LabView is more suitable in this case, but I wanted to try with Matlab first.</p><p>My code for setting up the channel and the trigger:</p><pre> s = daq.createSession('ni');
% Add analog input channels
ch = s.addAnalogInputChannel('cDAQ9184-196940DMod4','ai0', 'Voltage');
% add Trigger
tr = addTriggerConnection(s,'External','cDAQ9184-196940DMod4/PFI0', 'StartTrigger');
s.TriggersPerRun = 10;</pre><p>Any piece of advice is appreciated.</p>Gabrielhttps://www.mathworks.com/matlabcentral/profile/authors/9785215-gabrieltag:www.mathworks.com,2005:Question/3269922017-02-26T18:27:16Z2017-02-28T12:59:49ZSlow to get value (z) out of z=surface(x,y), how can this be faster?<p>In my code, I have anywhere in a for loop:</p><p>p=surface(x,y)</p><p>This surface has been created using cubic interpolation. But it takes a lot of time to fetch surface(x,y). Is there a way to make this faster? It would take ages if the for loop is 1:10^6 (just not doable)</p>Emihttps://www.mathworks.com/matlabcentral/profile/authors/2133683-emitag:www.mathworks.com,2005:Question/3273052017-02-28T10:58:13Z2017-02-28T12:28:43ZGraphics problem when zooming<img src = "/matlabcentral/answers/uploaded_files/71013/figure_problem.png"><p>I am encountering troubles when I try to zoom into graphics or figures. Several details and elements are not cropped correctly but instead completely removed from the picture. I attached two screenshots, first the original and the second when I zoomed into the right edge of the circle in the middle. The grid and several points are suddenly not visible anymore.
I am running MatLab 2016b on Windows 8.1 64bit, Graphics: Intel HD 4600.</p>Clemens Gebhardthttps://www.mathworks.com/matlabcentral/profile/authors/6955683-clemens-gebhardttag:www.mathworks.com,2005:Question/3273182017-02-28T12:22:44Z2017-02-28T12:22:44ZHow to extract rows from a text file with a specific start?<p>$GNRMC,083059.00,A,2948.16655,N,12133.72003,E,0.018,,280217,,,D*69
$GNVTG,,T,,M,0.018,N,0.034,K,D*36
$GNGGA,083059.00,2948.16655,N,12133.72003,E,4,12,0.90,5.0,M,10.9,M,1.0,0790*64
$GNGSA,A,3,23,27,16,14,26,31,,,,,,,2.00,0.90,1.78*19
$GNGSA,A,3,80,73,82,83,70,81,71,,,,,,2.00,0.90,1.78*1C</p><p>For example I have this kind of text file (it continues on for very long) and I want to extract only the rows starting with $GNGGA and write them all to another text file</p>Michael Limhttps://www.mathworks.com/matlabcentral/profile/authors/9778234-michael-limtag:www.mathworks.com,2005:Question/3272532017-02-28T06:33:38Z2017-02-28T12:18:20ZMATLAB Versions 1 through 13<p>Back in the old days with DOS, PC-MATLAB, AT-MATLAB, 386 MATLAB and early versions for Windows (MATLAB 4, MATLAB 5, etc.) nobody could care less whether the .m extension is UPPER CASE or lower case. Versions after 2010 (or so) do. Anybody have a clue how to "rename" over 6500 m-files in one easy swoop?</p><p>C:\> rename *.M *.m doesn't seem to work to well in the Windows "DOS" prompt. :)</p><p>Case sensitive variables are great. Case sensitive m-files? Not so much. Picky, picky, picky.</p><p>Thanks.</p>Chris Conanthttps://www.mathworks.com/matlabcentral/profile/authors/5019284-chris-conanttag:www.mathworks.com,2005:Question/3272982017-02-28T10:25:11Z2017-02-28T12:09:06ZHow can I draw vector of function in 3-D space(Fr and Fx vector sum)<p>How can I draw vector((Fr and Fx vector sum)) of function in 3-D space.
Fr=10*sin(θ)-5*cos(α).
Fx=10*cos(θ).
the angle is showed as follows:</p><img src = "/matlabcentral/answers/uploaded_files/70997/111.jpg">RP Chttps://www.mathworks.com/matlabcentral/profile/authors/9819931-rp-ctag:www.mathworks.com,2005:Question/3273152017-02-28T12:01:04Z2017-02-28T12:01:04Zi am not able to calculate a power of given signal over interval through this function anyone can help?<p>function [ P ] = calcPower( x,a,b )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
syms t
P= (int((x)^2,t,a,b))/(b-a);
end</p><p>can anyone suggest anwer</p>Muhammad Alihttps://www.mathworks.com/matlabcentral/profile/authors/9396538-muhammad-alitag:www.mathworks.com,2005:Question/3273032017-02-28T10:41:58Z2017-02-28T11:56:52ZEXECUTING POPUP MENU SELECTION ON PUSH BUTTON PRESS<p>i have a list of modes in popup menu. i want to select a mode from there.
then there should be a push button, on pressing this button, the selected mode should execute.
i.e. only the selection will be made in popup menu, the execution of that selection would be by a push button. how should i code this?</p>saqib anwaarhttps://www.mathworks.com/matlabcentral/profile/authors/9330362-saqib-anwaartag:www.mathworks.com,2005:Question/3272712017-02-28T08:16:16Z2017-02-28T11:56:20ZHaving Fun Yet?<p>Reverse compatibility for MATLAB is not very impressive.</p><pre class="language-matlab">>> fwave1
Warning: PACK can only be used from the MATLAB command line.
> In fwave1 (line 335)
</pre><p>Oh getting all these 20-30 year old programs to work with this "new and improved" version is going to be time consuming. Good thing I'm retired, and still have AT-MATLAB with gpp on a DOS machine. Hey, it'll keep me out of trouble. Probably should wait till I have a campfire and a beer. :-)</p>Chris Conanthttps://www.mathworks.com/matlabcentral/profile/authors/5019284-chris-conanttag:www.mathworks.com,2005:Question/2175482015-05-19T10:54:51Z2017-02-28T11:54:56Zhow do i optimize weights of neural network using GA in MATLAB(need codes to achieve that), again how do i call this function that optimzes the neural network weights in GA GUI so i can work with it from the interface<p>i need to train a neural network(a feedforward network and also a narx network) using genetic algorithm.and i need to do this by using GA to search for weights that will make the network learn very well.</p>Donatushttps://www.mathworks.com/matlabcentral/profile/authors/4714239-donatustag:www.mathworks.com,2005:Question/3273142017-02-28T11:53:02Z2017-02-28T11:53:02ZSymbolic matrix problem, how to take out the arrays of a symbolic matrix?<p>Hi,</p><p>I have a matrix 5X1 as a Symfun data, where I want to take out the 5 elements seperately and do more calculations on them. The problem is the matrix is to be a 1X1 matrix as long as it's a Symfun and I can not choose the arrays seprately. I can not transform the marix to double or single, because each time I recieve an error. What can be other solution?</p><p>best regards,</p>Hosseinhttps://www.mathworks.com/matlabcentral/profile/authors/4875387-hosseintag:www.mathworks.com,2005:Question/1445332014-08-03T12:19:11Z2017-02-28T11:52:34ZHow can I increase the memory allocated to Matlab R2014a on 64-bit Windows 8?<p>My machine had a 4 GB RAM and I recently installed an extra 8 GB,now having a total of 12 GB RAM. When I go to Computer-> Properties it also shows that I have an available 12 GB RAM. However, when running my program I get an OUT OF MEMORY error. After typing memory in the MATLAB prompt I got the following:
Maximum possible array: 17588 MB (1.844e+10 bytes) *
Memory available for all arrays: 17588 MB (1.844e+10 bytes) *
Memory used by MATLAB: 1597 MB (1.675e+09 bytes)
Physical Memory (RAM): 12163 MB (1.275e+10 bytes)</p><ul><li>Limited by System Memory (physical + swap file) available.</li></ul><p>So, it seems that the memory used by MATLAB is limited and does not take full advantage of the system’s memory..
Is some way to determine the memory allocated to MATLAB?
I am using a 64-bit Windows 8.
Many thanks!</p>Effrosynihttps://www.mathworks.com/matlabcentral/profile/authors/5405126-effrosynitag:www.mathworks.com,2005:Question/3272912017-02-28T09:57:55Z2017-02-28T11:51:02ZImage axis label reshape<p>I have an (mxn) image. When I use interpolation and display the image to the original size (mxn), the X and Y ticks are off. How do I fix it?</p><p>For example:
1.) I is an (mxn) image.
2.) [mp, np] = size( interp2(I, 4) );
3) How do I do this part?
imageSizeRadial is the size of the object in radial direction. Let's say it is 0.7 mm.</p><p>ax.XTick = (where_to_start : .35 : imageSizeRadial) * floor(np/imageSizeRadial);
ax.XTickLabel = {10, 360, 710};</p><p>we record the image at 10 micro-meter. Hence the first tick should be 10 micrometer.The problem is that he tick is below the surface.</p><p>Same applies to the Y label</p><p>Please see the attached figure.</p><p><<</p><img src = "/matlabcentral/answers/uploaded_files/70993/reconstructedObjectMonteCarlo10.jpg"><p>>></p><p>I would like to place a tick in .010 mm, 0.36 mm, 0.71 mm.</p>Golam Chowdhuryhttps://www.mathworks.com/matlabcentral/profile/authors/4835040-golam-chowdhurytag:www.mathworks.com,2005:Question/3273062017-02-28T11:07:05Z2017-02-28T11:49:27ZHow can I solve this problem ? <p>Hello to everyone. I need help with the attached code.
Why Matlab tell me : " Index exceeds matrix dimensions. Error in Texture_tris (line 186) , phi2A(j+1) = phi2A(j+1) + dnA; "</p><p>I wrote some other programs with the same script and that one never gave me an error? How this can be possible ? Thanks in advance.</p>Giuseppe Napolihttps://www.mathworks.com/matlabcentral/profile/authors/6547113-giuseppe-napolitag:www.mathworks.com,2005:Question/3273132017-02-28T11:47:31Z2017-02-28T11:47:31Zis there a way to detect arrows in an image <p>I have scanned copy of engineering drawing which is a combination of different geometrical patterns like circle lines etc and arrows addition to this it has alphabets & some numeric values. I want to extract patterns as well as the alphabets. Is there a way by which I can extract these information & patterns from the figure. Thanks in advance.</p>Ayushi Saxenahttps://www.mathworks.com/matlabcentral/profile/authors/7396635-ayushi-saxenatag:www.mathworks.com,2005:Question/3273042017-02-28T10:53:51Z2017-02-28T11:47:10ZRemove duplicate values, but keep the initial<p>For example, i have</p><p>x = [0 0 0 1 1 0 0 0 1 0 1 0]</p><p>I want the index of the first zero or one, but not the duplicates.</p><p>So the vector should become:</p><p>0 1 0 1 0 1 0</p><p>Where the indices would be '1 4 6 9 10 11 12'</p><p>Thanks</p>James Boylehttps://www.mathworks.com/matlabcentral/profile/authors/8291374-james-boyletag:www.mathworks.com,2005:Question/3273122017-02-28T11:45:17Z2017-02-28T11:45:17ZWhere I can get libgstinterfaces-0.10.so.0 ?<p>Hello,</p><p>I want to use my Built-in Webcam (BisonCam NBpro Acer, Inc.) but when I click on Add Images > From Camera I get this error:</p><img src = "/matlabcentral/answers/uploaded_files/71012/Bildschirmfoto%20vom%202017-02-28%2012-39-49.png"><p>Could not open Shared-Object-File: File or Folder isn´t found</p><p>I have Ubuntu 16.10, all packages are updated/upgraded. The Shared-Object-File isn´t in the official Repositories and no found with</p><pre class="language-matlab">sudo apt-file search libgstinterfaces
</pre><p>So how I can use my Webcam yet with MatLab? And where I can get this Shared-Object-File?</p><p>Best wishes,
Jakob Krieger</p>Jakob Michael Kriegerhttps://www.mathworks.com/matlabcentral/profile/authors/8351438-jakob-michael-kriegertag:www.mathworks.com,2005:Question/3272132017-02-27T23:51:28Z2017-02-28T11:42:55ZTrouble with ODE45 for an array of values<p>Hi,</p><p>I have an equation udC/dx=R, where C and R are arrays. I've written a code but its giving a linear plot. Need help</p><pre class="language-matlab">% Solve ODE for Multi-Species Isothermally
% Constants
u = 1.5;
A = 2.2e10;
Ea = 130;
Ru = 8.3145;
T = 750;
L = 0.12;
N = 39;
</pre><pre class="language-matlab">% Initial Conditions
</pre><pre class="language-matlab">Cco(1) = 0.52;
Co2(1) = 0.99;
Ch2o(1) = 0;
delx = L/(N-1);
x = 0:delx:0.12;
C0 = [Cco(1) Co2(1) Ch2o(1)];
C = zeros(3,1);
</pre><pre class="language-matlab">Rco = -A * (exp(-Ea / (Ru*T))) * Cco * sqrt(Co2);
Ro2 = 0.5 * Rco;
Rh2o = -Rco;
dC = [Rco Ro2 Rh2o] / u;
R = [Rco Ro2 Rh2o];
R = zeros(3,1);
</pre><pre class="language-matlab">% ODE45 solver
[x,C] = ode45(@(x,C) R/u, x, C0);
</pre><pre class="language-matlab">plot(x,C,'-+')
title('Molar Concentration vs. Distance');
legend('CO','O2','CO2');
xlabel('Axial(x) Direction [m]');
ylabel('Concentrations [mol/m3]');
</pre><p>I am getting the following plot</p><img src = "/matlabcentral/answers/uploaded_files/70966/Screenshot_8.png"><p>While the correct plot is this.</p><img src = "/matlabcentral/answers/uploaded_files/70967/Screenshot_9.png"><p>Thank you.</p>DIPhttps://www.mathworks.com/matlabcentral/profile/authors/7881208-dip