https://www.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions20170922T15:28:42Ztag:www.mathworks.com,2005:Question/35792220170922T13:55:31Z20170922T15:28:42ZNested for loops using vectorization in MATLAB<p>I currently have two national instrument devices hooked up to MATLAB and have this nested for loop:</p><pre class="languagematlab">for i=1: 5
removeChannel(session, 7)
if i == 1
addAnalogInputChannel(session,'cDAQ1Mod8','ai1','Voltage');
elseif i == 2
addAnalogInputChannel(session,'cDAQ1Mod8','ai2','Voltage');
elseif i == 3
addAnalogInputChannel(session,'cDAQ1Mod8','ai3','Voltage');
elseif i == 4
addAnalogInputChannel(session,'cDAQ1Mod8','ai4','Voltage');
else
addAnalogInputChannel(session,'cDAQ1Mod8','ai5','Voltage');
end
for j=1: 5
signal = [in(i,:) out(j,:)];
outputSingleScan(session, signal);
measurements(6j,6i) = session.inputSingleScan;
end
end
</pre><p>Basically what this does is removes the last channel in the session and adds a new one from the DAQ depending on the iteration. A signal is then sent from the NI USB device and then another measurement is read from the DAQ. How do I use vectorization for this nested for loop?</p>Ahmad Lakhanihttps://www.mathworks.com/matlabcentral/profile/authors/10957650ahmadlakhanitag:www.mathworks.com,2005:Question/35585520170909T13:33:18Z20170922T15:28:39ZHow to read text files from each subfolder<p>Hi,</p><p>I have a main folder which contains several sub folders, now I want to read text files from each subfolder, save the data into ".xlsx" of each subfolders data by its subfolder name. For example read data from subfolder1 and save the data as "subfolder1.xlsx", and subfolder2 data as "subfolder2.xlsx".</p><p>Read text files, and extract the data as mentioned below:</p><p>1. Above the first dotted () line, extract the information:
RainFallID, IINT, Rain Result, Start Time</p><p>2. Between two dotted lines(), the first column and 3rd column, in 3rd column if the data is mixed only keep the first part (for example 0.67 mm> 0.67, 60.67+34e %>60.67+34e, and if it is text like "False End">False End).</p><p>Please help some one kindly,</p>Mekala balajihttps://www.mathworks.com/matlabcentral/profile/authors/5786945mekalabalajitag:www.mathworks.com,2005:Question/35789620170922T12:02:49Z20170922T15:28:18ZTrouble with plotting different symbols and colors indexed by a matrix in an mfile. How do I make the mfile handle color and symbol strings that work on command line?<p>I have an mfile where I am trying to dynamically plot different indexed parts of a data set with different symbols and colors. The idea is to plot blank contamination data performed by different analysts and being able to see what analysts plot out where in the contamination field so I can adapt my training to analysts who repeatedly register a high blank. The data set is constantly changing, so I have an mfile that reads the data file and creates a Color Array and a Symbol Array based on the number of different analysts in a single data set. These arrays are of different sizes so that color and symbol pairs will not reproducible for quite some time.</p><p>I tested some code on the command line, and it worked. However, in the mfile it doesn't work. I get the error message:</p><pre class="languagematlab">ans =
'v'
Error using matlab.graphics.chart.primitive.Line/set
While setting the 'Marker' property of 'Line':
Invalid enum value. Use one of these values: '+'  'o'  '*'  '.'  'x'  'square'  'diamond'  'v'
 '^'  '>'  '<'  'pentagram'  'hexagram'  'none'.
</pre><pre class="languagematlab">Error in LiveBlankDeterm (line 168)
set(ss,'Marker',symbols{k(1)});
</pre><p>The "answer: 'v'" line is a probe I put in the code to see exactly what the the mfile is trying to insert into the plot command line. With or without the single quotes, this error message is generated, but you can see that the string ('v' or v, in this case, is the first symbol in the symbol array) fails to register in the plot command. Furthermore, if I tweak the order and specify the color array first, before the symbol array, it generates the error message the color must be in numeric form (3element vector, 01 for each element).</p><p>The mfile code that is generating this error looks like this:</p><pre class="languagematlab">hold on
for nn=1:max(abbcounter)
k=find(namecode==nn);
symbols{k(1)}
ss=plot(D(min(k):max(k),1)/1000,D(min(k):max(k),2));
set(ss,'Marker',symbols{k(1)});
end
</pre><p>From the "set" line, I can add or alternate the color array. The namecode is simply an integer in the data corresponding to the analysts' abbreviations used to generate the legend.</p><p>In command line, similarly written code (in this case not using the set command, but addressing the linespec properties directly) like </p><pre class="languagematlab">plot(nn,b(min(k):max(k)),'Marker',symbols{nn})
</pre><p>works just fine. But not in the mfile.</p><p>Any ideas on how I can improve this code to make it work  from a modest tweak to a complete change in program flow?</p><p>Thanks,
Brad</p>Brad Rosenheimhttps://www.mathworks.com/matlabcentral/profile/authors/2389839bradrosenheimtag:www.mathworks.com,2005:Question/35794120170922T15:27:34Z20170922T15:27:34ZIphone Video and Inertial Sensors Acquisition<p>Hi,</p><p>I am wondering if it is possible to simultaneously record a video and inertial sensor data with and Iphone and Matlab or Simulink. The video and the data need to be synchronized.</p><p>I successfully installed the IOS support packages (matlab & simulink) and I took time to read some projects which usually didn't use the camera, the gyroscope and the accelerometer in the same time.
Maybe someone has ever heard about a similar project or has any suggestion?</p><p>Thank you in advance,
Pm</p>Damon PierreMariehttps://www.mathworks.com/matlabcentral/profile/authors/7236308damonpierremarietag:www.mathworks.com,2005:Question/520020110410T22:43:30Z20170922T15:27:32ZUndefined function or method '...' for input arguments of type 'double'.<p>I'm getting the following error when I try to run some function mfiles:
??? Undefined function or method '[name of function]' for input arguments of type 'double'.</p>
<p>I know this usually happens when the file isn't in the working directory, but that's not the case here.</p>
<p>When I was running these mfiles in a different directory on my computer, it worked fine. I moved them to another directory on my laptop, and they're still fine, but I get this error on two of my desktops.</p>
<p>Thank you.</p>Dhttps://www.mathworks.com/matlabcentral/profile/authors/1466466dtag:www.mathworks.com,2005:Question/35790820170922T12:55:09Z20170922T15:26:00ZHelp on a problem<p>I have this problem and I'm wondering if anyone can help me to figure it out. It goes as follows:
write a program to iteratively generate points in twodimensional space using the following rules:</p><pre> (x_{n+1},y_{n+1}) = </pre><pre class="languagematlab">/ (0.5,0.27*y_n), with 2% probability;

 (0.139*x_n + 0.263*y_n + 0.57, 0.246*x_n + 0.224*y_n  0.036), with 15% probability;
<
 (0.17*x_n  0.215*y_n + 0.408, 0.222*x_n + 0.176*y_n + 0.0893), with 13% probability;

\ (0.781*x_n + 0.034*y_n + 0.1075, 0.032*x_n + 0.739*y_n + 0.27), with 70% probability.
</pre><p>Start from an initial point (x_1,y_1)=(0.5,0.0). Carry out the iteration at least 30,000 times</p>Gaëtan Poirierhttps://www.mathworks.com/matlabcentral/profile/authors/10836714gaetanpoiriertag:www.mathworks.com,2005:Question/35794020170922T15:25:10Z20170922T15:25:10ZProblem with a lab<p>I have a lab problem. It says to write a program to iteratively generate points in twodimensional space using the following rules:</p><pre> (x_{n+1},y_{n+1}) = </pre><pre class="languagematlab">/ (0.5,0.27*y_n), with 2% probability;

 (0.139*x_n + 0.263*y_n + 0.57, 0.246*x_n + 0.224*y_n  0.036), with 15% probability;
<
 (0.17*x_n  0.215*y_n + 0.408, 0.222*x_n + 0.176*y_n + 0.0893), with 13% probability;

\ (0.781*x_n + 0.034*y_n + 0.1075, 0.032*x_n + 0.739*y_n + 0.27), with 70% probability.
</pre><p>[Click for pdf version of this problem, where you may find the equation easier to read.]</p><p>Start from an initial point (x_1,y_1)=(0.5,0.0). Carry out the iteration at least 30,000 times and plot all the data you obtain (as points) in an xy plot.</p><p>I have written:
for iter = 1: 30000
r = rand();
x = 0.5;
y = 0;
if r < 0.02
y = y * 0.27*r;
elseif r < 0.02 + 0.15
x = x 0.139 * r + 0.246 * r;
y = y + 0.263 * r + 0.224 * r  0.036;
elseif r < 0.02 + 0.15 + 0.13
x = x + 0.17 * r  0.032 * r;
y = y + 0.034 * r + 0.739 * r + 0.27;
elseif r < 0.02 + 0.15 + 0.13 + 0.70
x = x + 0.781 * r  0.032 * r;
y = y + 0.034 * r + 0.1075 + 0.739 * r + 0.27;
end
end</p><p>...doesn't seem to work; only outputs one x, y, and r value without repeating 30000 times. What's the issue?</p>Gaëtan Poirierhttps://www.mathworks.com/matlabcentral/profile/authors/10836714gaetanpoiriertag:www.mathworks.com,2005:Question/35793720170922T15:08:27Z20170922T15:25:07ZWhy is my plot not showing a line?<p>I am not seeing the line on my plot. I am trying to plot the distance traveled by a projectile when launched. Thank You.</p><pre class="languagematlab">if true
% code
Planet=menu('Chose a Planet','Mercury','Venus','Earth','Mars','Jupiter','Saturn','Uranus','Neptune','Pluto');
Gravities = [3.59 8.87 9.81 3.77 25.95 11.08 10.67 14.07 0.42];
g = Gravities(Planet);
V=input('Enter the Velocity=');
Angle=input('Enter the angle=');
timpact=((2*V).*sind(Angle))./g;
fprintf('Time to Impact= %0.2f\n',timpact);
maxheight=(V.^2).*sin(deg2rad(Angle)).^2./(2.*g);
fprintf('Maximum height= %0.2f\n',maxheight);
t=timpact;
x0=0;
y0=0;
xt=V.*cosd(Angle).*t+x0 ;
yt=(1./2).*g.*t.^2+(V.*sind(Angle).*t)+y0;
fprintf('Distance= %0.2f\n', xt);
</pre><p>plot(timpact,maxheight,xt,yt);</p><pre class="languagematlab">end
</pre>Sulav Bhandarihttps://www.mathworks.com/matlabcentral/profile/authors/10759303sulavbhandaritag:www.mathworks.com,2005:Question/35792520170922T14:11:37Z20170922T15:21:03ZBug in Copy FIgure clips out part of figure<p>I've recently installed Matlab (R2017a on Windows 10 Home) on a new laptop and just noticed that the Copy Figure button results in only part of the figure being pasted. Specifically, the upperleft portion of the figure is preserved, but the rest is lost. I've not done any adjustments to the figure dimensions nor axes bounds, nor am I using any specialized plotting software, so this appears to be the default behavior. I've tested pasting into several MS Office products and MS Paint, all showing the same behavior. Below is a sample of what gets pasted into MS Paint for reference.</p><img src = "/matlabcentral/answers/uploaded_files/88724/failedpaste1.png"><p>Manually resizing the figure axis bounds so that the axis is located in the upperleft section of the figure window (shown in the second plot below) results in the entire figure being copypasteable. This seems to imply the issue is related to Matlab's perception of the figure bounding box.</p><img src = "/matlabcentral/answers/uploaded_files/88725/20170922%2011_16_59Figure%2053.png"><p>I noticed this link: <a href = "https://www.mathworks.com/matlabcentral/answers/197305possiblebugincopyingfigures">https://www.mathworks.com/matlabcentral/answers/197305possiblebugincopyingfigures</a>
which alludes to a similar issue, though it was R2015a. Thanks in advance for any help.</p>T Ahttps://www.mathworks.com/matlabcentral/profile/authors/9482949tatag:www.mathworks.com,2005:Question/35793920170922T15:18:38Z20170922T15:18:38Zplot graph with dates for different years<p>Hi everyone,</p><p>For my work, I am asked to plot graphs production for every year.</p><p>I have a daily production for every year since 2012. I am trying to find a way to compare the production of every year for the same dates.</p><p>I also have another difficulty : if I have a 0 for some days, it must not be represented on the graph (and they don't always show at the same period...)</p><p>Thanks in advance</p>Alex Chttps://www.mathworks.com/matlabcentral/profile/authors/10961124alexctag:www.mathworks.com,2005:Question/35793820170922T15:18:18Z20170922T15:18:18ZLegend text looks washed out<p>When generating figures on my desktop, the text in all of my legends look washed out and gray instead of black. But the text is not washed out when I run the same exact code on my laptop. Does anyone know of a way to fix this issue?</p>Paul Carvalhohttps://www.mathworks.com/matlabcentral/profile/authors/4800427paulcarvalhotag:www.mathworks.com,2005:Question/35723220170918T18:58:38Z20170922T15:18:13Zupdate SQLite database using insert<p>Hello I am trying to update my SQLite database using the following command</p><p>insert(conn, 'ClosePriceTable', {'Dates','AUD_CAD', 'AUD_CHF'}, Table_New_datax(2:end,:))</p><p>However I rather want to update only if new records are different to current records. Thus I do not want duplicate records in my SQLite database. If the new records are the same as current records then I merely wish to overwrite and not insert the same record again.</p><p>The key variable differentiating records is the date.</p><p>How can I avoid duplication of records? What command can I use?</p>Charleshttps://www.mathworks.com/matlabcentral/profile/authors/5506466charlestag:www.mathworks.com,2005:Question/35789920170922T12:24:24Z20170922T15:16:47ZFigure do not render in GUI<p>Figures do not appear in GUI but plot OK off the command line. (Works pefectly off some PC's but not on others so code must be OK)</p>Anthony Fisherhttps://www.mathworks.com/matlabcentral/profile/authors/17711anthonyfishertag:www.mathworks.com,2005:Question/30969020161028T20:49:53Z20170922T15:15:02ZImproving performance of X = A \ B.<p><b>Last edit: section "EDIT 11/08/2016"</b></p><p>Dear all,</p><p>How would you improve the performance in the computation of:</p><pre> X = A \ B ;</pre><p>where <tt>A</tt> is a <tt>n x n</tt> nonsymmetric sparse matrix, <tt>B</tt> a <tt>n x m</tt> array, and <tt>X</tt> a <tt>n x m</tt> array? It represents <tt>m</tt> solutions corresponding to <tt>m</tt> emission scenarios in my model (compartmental model of size <tt>n</tt>). Typical values for <tt>n</tt> are in the range <tt>1e51e6</tt>, and <tt>m</tt> can be adjusted: I have e.g. <tt>1e4</tt> scenarios that I solve by group/block. I provide an example with <tt>n~1e5</tt> and <tt>m=50</tt> which is good for profiling (~3s on my laptop): <a href = "http://www.euriskoresearch.org/matlab/AB.mat">MATFile</a>, stored externally because it is slightly larger than 5MB.</p><p>Array <tt>B</tt> is generally dense, and matrix <tt>A</tt> has a density of <tt>~6.5e5</tt> and the following structure:</p><img src = "/matlabcentral/answers/uploaded_files/62191/Spy_A.png"><p> </p><p>Given the size in memory of these arrays (~11MB for <tt>A</tt> and 1KB for <tt>B</tt>), I thought that they could be transferred to the GPU and gathered at little cost, but when I try I get:</p><pre> Error using \
Sparse gpuArrays are not supported for this function.</pre><p>I saw other threads that mention that \ is not <i>yet?</i> supported for sparse arrays (e.g. <a href = "https://www.mathworks.com/matlabcentral/answers/107642backslashoperatorongpu">ref1</a>, <a href = "http://www.mathworks.com/matlabcentral/answers/107642backslashoperatorongpu?s_tid=answers_rc12_p2">ref2</a>).</p><p>I tried using TomLab TLSQR but with little success (TomLab may have another tool for this, but I didn't find it).</p><p>I also tried using Tim Davis' SuiteSparse UMFPACK. I think that MATLAB implemented part of this code, so I wasn't surprised to see the same performance between MATLAB MLDIVIDE and UMFPACK. I saw that SuiteSparse can be compiled with GPU support, but I wanted to ask here before going this way.</p><p>I didn't explore other, maybe more algebraic options, transformations, etc yet. Does anything jump to your mind? The <tt>A</tt> matrix is defined by block (6 x 6, not delineated here but "somehow visible"). The filling of each block can vary, but the density is rather stable.</p><p>Thank you,</p><p>Cedric</p><p>(MATLAB 2016b Windows/Linux)</p><p> </p><p><b>EDIT 10/31/2016</b></p><p>I have to add that I implemented explicitly a parallel approach working with cell arrays of blocks of both <tt>X</tt> and <tt>B</tt>, i.e. something like:</p><pre> X_blocks = cell( size( B_blocks )) ;
parfor k = 1 : numel( B_blocks )
X_blocks{k} = A \ B_blocks{k} ;
end</pre><p>but I thought that, given what is implemented in MLDIVIDE is a Multifrontal method, the parallelization could happen at a much lower level using either/both a parallel pool or/and a GPU device(?) Or is it possible to use <tt>distributed</tt> ( <a href = "https://www.mathworks.com/matlabcentral/answers/40578sparsematrixinversioninparallel">ref</a> ) in some way to avoid repeated factorization of <tt>A</tt> ( <a href = "https://www.mathworks.com/matlabcentral/answers/40578sparsematrixinversioninparallel">ref</a> )?</p><p> </p><p><b>EDIT 11/02/2016</b></p><p>After giving a try to iterative solvers (see Sean part of the thread), I went on trying direct approaches. I am attaching a test script that profiles MLDIVIDE, MLDIVIDE parallel by block, <a href = "http://www.mathworks.com/matlabcentral/fileexchange/24119dontletthatinvgopastyoureyestosolvethatsystemfactorize">FACTORIZE (by Tim Davis)</a>, FACTORIZE parallel by block, and an explicit implementation of what factorize does for nonsymmetric sparse matrices ( <tt>LU ></tt> <tt>L</tt>, <tt>U</tt>, <tt>P</tt>, <tt>Q</tt>, <tt>R</tt> and then relevant series of MLDIVIDE). I obtain the following results:</p><pre> Test simple MLDIVIDE (\) on large B ..
 Total time : 14.5s
 Max rel. residual: 6.6e16</pre><pre> Test parallel MLDIVIDE (\) on cell B ..
 Total time : 11.0s
 Max rel. residual: 6.6e16</pre><pre> Test simple FACTORIZE on large B ..
 Time factorize : 1.0s
 Total time : 10.5s
 Max rel. residual: 3.1e15</pre><pre> Test parallel FACTORIZE on cell B ..
 Time factorize : 1.0s
 Total time : 9.0s
 Max rel. residual: 3.1e15</pre><pre> Test simple LU, etc on large B ..
 Time factorize : 0.9s
 Total time : 10.2s
 Max rel. residual: 3.1e15</pre><pre> Test parallel LU, etc on cell B ..
 Time factorize : 0.9s
 Total time : 8.9s
 Max rel. residual: 3.1e15</pre><p>where the rational for using FACTORIZE and the explicit formula (LU, etc) is that matrix <tt>A</tt> is the same for all blocks (when parallelized), and should not be repeatedly factorized. This approach works best (especially with my real, much larger, <tt>B</tt> arrays), but I'd still be interested to know if it is possible to do better with iterative approaches and possibly on GPU(?)</p><p> </p><p><b>EDIT 11/08/2016</b></p><p>I performed quick tests overnight that I am summarizing here. I observed that the block/parallel approach ( <tt>X{k}=Q*(U\(L\(P*(R\B_cell{k}))))</tt> in a <tt>PARFOR</tt> loop, after explicitly factorizing <tt>A</tt> ) is almost always more time efficient than direct <tt>MLDIVIDE</tt> ( solving <tt>X=A\B</tt> in one shot), and I wanted to test it as a function of the system size and the number of columns in <tt>B</tt>. My test script loops through system sizes from 100 to 90,000, and through numbers of columns of blocks of B from 1 to 100 ( <tt>B</tt> itself has 200 columns). For each system size, I measure the time for solving <tt>X=A\B</tt> in one shot, and the time for solving it by block for the aforementioned block sizes. The code for solving by block is as follows:</p><pre> B_cell = mat2cell( B, B_nRows, Bblock_nCols ) ;
X = cell( size( B_cell )) ;
parfor k = 1 : numel( B_cell )
X{k} = Q * (U \ (L \ (P * (R \ B_cell{k})))) ;
end
X = [X{:}] ;</pre><p>where factors of <tt>A</tt> were obtained as follows outside of the loop that iterates through block sizes:</p><pre> [L, U, P, Q, R] = lu( A ) ;</pre><p>I obtain the following results:</p><img src = "/matlabcentral/answers/uploaded_files/62829/Contour20161108b.png"><p> </p><p>Aside from the fact that it is a valid, lengthy approach for generating a sunset landscape, it strikes me that there is no clear pattern with block size. I thought that I would observe something function of the size of the cache, because the maximum block size is ~9e4*100*8/1e6 <tt>></tt> 72MB > 8MB Xeon 1505M cache. The second interesting point is that direct solving is almost always slower than an explicit block/PARFOR approach (plot on the right). Finally, it seems that overall "PARFORing" a lot with small bock sizes is most efficient (bottom plot: for each system size, I compute times/max(times), and I plot the mean over all system sizes).</p><p>This result is a bit counterintuitive to me; I thought that I would get a pattern that would allow me to determine the maximum block size for each system size, as a function of the amount of cache in the CPU, and that this max block size would be optimal regarding time efficiency of the block/PARFOR approach.</p><p>Any thoughts/insights?</p><p> </p><p><b>OTHER REFERENCES</b></p><ul><li><a href = "http://www.mathworks.com/matlabcentral/answers/686541whyfordensematricesitsnotusefultosplitb2whatarethefactorsthatdeterminethespe?s_tid=answers_rc11_p1">Ref</a> : Jill mentions factorization of A.</li><li><a href = "https://www.mathworks.com/matlabcentral/answers/40578sparsematrixinversioninparallel">Ref</a> : Jill mentions <tt>distributed.speye</tt>.</li><li><a href = "https://www.mathworks.com/help/matlab/ref/spparms.html">Ref</a> : Doc of SPPARMS, with mention of the UMFPACK parameter (60 times slower than default in my case).</li><li><a href = "https://www.jstor.org/stable/2132786?seq=1#page_scan_tab_contents">Ext ref</a> :
The Multifrontal Method for Sparse Matrix Solution: Theory and Practice, Joseph W. H. Liu, SIAM Review, Vol. 34, No. 1 (Mar., 1992), pp. 82109.</li></ul>Cedric Wannazhttps://www.mathworks.com/matlabcentral/profile/authors/1078046cedricwannaztag:www.mathworks.com,2005:Question/35777620170921T17:32:51Z20170922T15:10:43ZIs it possible to speedup solving Ax=b for multiple b's by precomputing the Cholesky factorization of A?<p>I'm currently working with large (15000x15000), sparse matrices that are not triangular nor banded, but are real, symmetric, Hermitian, and have all positive values.
Following the flow chart for the mldivide function for sparse matrices, it would appear that the Cholesky solver would be used. I solve Ax=b for multiple b's, so I thought that if I precomputed the Cholesky factorization once, that then solving the equation would be faster, so I decided to do some tests.
These were the times I got for each step, and comparison to the usual mldivide time</p><pre class="languagematlab">>> tic; A_factor = chol(A, 'lower'); toc; %use 'lower' for speed boost with sparse matrices
Elapsed time is 51.273020 seconds.
</pre><pre class="languagematlab">>> tic; x = A_factor\b; toc; % precomputed solution time
Elapsed time is 0.186439 seconds.
</pre><pre class="languagematlab">>> tic; x = A\b; toc; % not precomputed solution time
Elapsed time is 3.275133 seconds.
</pre><p>It is clear that precomputing the factorization helps (0.18s < 3.28s), but my question is why does the initial precomputation of the Cholesky factorization take so long (~50s) when the mldivide call without the precomputation takes only 3s and would be performing the same factorization. Wouldn't we expect the Cholesky factorization to take < 3s? Any ideas?</p>David DeVrieshttps://www.mathworks.com/matlabcentral/profile/authors/10249074daviddevriestag:www.mathworks.com,2005:Question/35793620170922T15:03:46Z20170922T15:03:46ZHow to read text file with mixed data types <p>I've been searching everywhere for ways of doing this, and have tried multiple ways to read this data file in (textscan, dlmread,importdata, etc), but I can't figure how to handle the data types correctly. The data in the file looks like this:</p><p>2.13796208950223e001 (2.38759502723354e002dB,1.79999770619446e+002°)</p><p>I want to parse this into three columns, time, magnitude (without the dB), and phase (without the degrees).
Thanks for the help.
Jorge</p>Jorge Rivéhttps://www.mathworks.com/matlabcentral/profile/authors/1395106jorgerivetag:www.mathworks.com,2005:Question/35793520170922T14:57:55Z20170922T15:02:05ZHow do I add 1 arrays elements into another array <p>I would like to amend 1 matrix into another matrix of the same size that would double the array in length. For instance I have a 1 x 1001 matrix that I would like to add to another matrix of 1 x 1001 to make 1 1 x 2002 matrix</p>Tyler Jacobsonhttps://www.mathworks.com/matlabcentral/profile/authors/10968196tylerjacobsontag:www.mathworks.com,2005:Question/35789020170922T11:33:57Z20170922T14:57:52ZHow to extract columns from two different matrices and create a new one (Loop)<p>Hi,</p><p>I have two <b>3xL</b> matrices <b>A_plus</b> and <b>A_minus</b>.</p><p>Now I want to create with the one column of each matrix a new 3x2 matrix. Therefore the code for the first of L matrix would look like:</p><pre class="languagematlab">A_left = A_minus(:,1);
A_right = A_plus(:,1);
A = [ a_left , a_right ];
</pre><p>So I want to repeat this procedure L times. Therefore I would get L matrices.</p><pre> 1. A_1 = [ first column of A_minus , first column of A_plus]
2. A_2 = [ second column of A_minus, second column of A_plus]
...and so on!</pre><p>Can u pls tell me how I can implement this procedure in my code?</p><p>Thank you.</p>Stefanos Kapetanidishttps://www.mathworks.com/matlabcentral/profile/authors/3088478stefanoskapetanidistag:www.mathworks.com,2005:Question/35745120170919T22:15:36Z20170922T14:56:41ZProblem Matlab/Simulink IOS device data acquisition<p>Hi,</p><p>I am working on a project which requires to record simultaneously the camera, gyroscope and accelerometer data of my Iphone. I would like to use Matlab/Simulink.</p><p>Maybe I am wrong but I just saw the option to record video with Simulink?</p><p>Finally, I properly set up my IOS with Simulink device and I tried the predefined examples.
I get into trouble since I didn't find a way to acquire the data into Matlab/Simulink.
For example when I add an accelerometer block into Simulink and I display the data on the IOS device it works perfectly but as soon as I add a scope the program can not run anymore.</p><p>I tried to use the UDP send/receiver provided in the examples but I didn't receive any data.</p><p>Maybe someone has ever had a similar problem?</p><p>Thank you in advance,
Pm</p>Damon PierreMariehttps://www.mathworks.com/matlabcentral/profile/authors/7236308damonpierremarietag:www.mathworks.com,2005:Question/26772020160211T18:49:38Z20170922T14:52:34ZDatetime with variable format<p>I have an output file that has timestamps in the form of 'yyyyMMdd HH:mm:ss.S' or 'yyyyMMdd HH:mm:ss'. I would like a clean way to convert them from date strings into an array of date time format.</p><p>Example code:</p><pre class="languagematlab">a={'20160209 10:28:00';'20160209 10:28:01.5'}
out=datetime(a,'InputFormat','yyyyMMdd HH:mm:ss.S','InputFormat','yyyyMMdd HH:mm:ss','Format','yyyyMMdd HH:mm:ss.S');
</pre><p>Actual output:</p><pre class="languagematlab">out =
20160209 10:28:00.0
NaT
</pre><p>Desired output:</p><pre class="languagematlab">out =
20160209 10:28:00.0
20160209 10:28:00.5
</pre>Winston Blackhttps://www.mathworks.com/matlabcentral/profile/authors/5581662winstonblacktag:www.mathworks.com,2005:Question/35793420170922T14:51:55Z20170922T14:51:55ZHow do i solve this boundary value ode?<p>Hello,</p><p>I am trying to solve an ode with two boundary conditions, one of which is applied to the first derivative of the function. The differencial equation is: <b>u''=b/A(x)</b> ; and the boundary conditions are: <b>[u(0)==0, u'(1)==1/A(1)]</b>.
I haven't seen how to solve this problem, just the initial value problem and essential boundary conditions, so help will be appreciated.</p>Javier Mongehttps://www.mathworks.com/matlabcentral/profile/authors/9733089javiermongetag:www.mathworks.com,2005:Question/35793320170922T14:49:22Z20170922T14:49:22ZHow to make a computergenerated sketch of the path of a fluid element (tornado)?<p>Problem statement:</p><p>In a plane parallel to and near the ground, the velocity components of a tornado centered at the origin are</p><p>V_r = (a/r), V_theta = (b/r)</p><p>where a = 100 m^2/s and b = 1000 m^2/s. These equations are valid for r > r_eye = 20 m. For r < r_eye, in the eye of the tornado, assume that the air rotates as a rigid in the plane parallel to the ground and that it has a constant vertical (z) velocity upwards.</p><p>What I have found through calculations:</p><p>I know the circulation rate of the tornado for Radius R > r_eye 2000*pi m/s^2 and that the flow is irrotational and incompressible.</p><p>I know at time t=0, a fluid element is located at (x,y) = (0,100m) and that it will take 48 seconds for the fluid element to reach the outer part of the eye of the tornado.</p><p>I know that the location of the fluid element when it first reaches the tornado eye is theta = 17.67 rad.</p><p>The final part tells me that I must provide a computergenerated sketch of the patch of the fluid element in the previous parts. This seems like a very easy task but I am having trouble combining everything I have found to sketch a circular path. Is there some kind of sketch path function?</p><p>Any help will be greatly appreciated. Thanks in advance!</p>Kenny Greenehttps://www.mathworks.com/matlabcentral/profile/authors/7055816kennygreenetag:www.mathworks.com,2005:Question/35719220170918T14:41:03Z20170922T14:49:19ZDetect Edge in picture with low contrast<p>Hi, i need to detect a specific edge in a variaty of pictures which follow the same pattern.</p><p>i have tried using an averaging and then a sobel and laplacian filter but didnt get satisfying results.
please use attached file as example. The edge that i am looking for is the dark one from the top more or less in the middle of the picture. Thanks for answers in advance</p><img src = "/matlabcentral/answers/uploaded_files/88311/WHL_20mm.PNG">Oliver Stilzhttps://www.mathworks.com/matlabcentral/profile/authors/4332238oliverstilztag:www.mathworks.com,2005:Question/35776220170921T15:29:20Z20170922T14:47:53ZHow can I make figure title and annotations selectable?<p>I have a figures which contains annotations with hyperlinks to other figures. I want the viewer of the figure to be able to just select the hyperlink and copy it to clipboard. How can I do this?</p>Pal Szabohttps://www.mathworks.com/matlabcentral/profile/authors/9015404palszabotag:www.mathworks.com,2005:Question/35792320170922T13:55:36Z20170922T14:47:50ZLoad data.mat with changing file name<p>Hello,
I have multiple database stored in a file as :
DB201706.mat
DB201707.mat
DB201708.mat</p><p>I want to creat a function that allows me to call the database that i want and use it in my calculation :</p><p>function [Output] = testbd()</p><p>load 'C:\MYFILE\test\DB20170730.mat'</p><p>gama = A(1);</p><p>Output = gama;</p><p>end</p><p>Is there a way to set the name of the database as an Input to the function in order to avoid entering the name manually.</p><p>function [Output] = testbd( <b>Name</b>)</p><p>load 'C:\MYFILE\test\ <b>Name</b>.mat'</p><p>gama = A(1);</p><p>Output = gama;</p><p>end</p><p>Thank you for your help</p>RHedfihttps://www.mathworks.com/matlabcentral/profile/authors/10039276rhedfitag:www.mathworks.com,2005:Question/35793220170922T14:42:26Z20170922T14:42:26ZInterferometric image processing/enhancing image quality<p>Hello All,</p><p>I believe it will be long shot but this is a call for some Image processing experts.</p><p>Problem: Need to enhance/improve the quality of images.</p><p>Details: I am working with a data set containing 1024 interferometric images from a camera. To put simply, images showing interference pattern. The sample taken is three glass slides. And, as a final result I should see three different lines separated by a distance. The things I have done:
1. Took all 1024 and stacked them in a matrix as a volume of images.
2. Made two loops which are user entered numbers and can cut the Cube/Volume of images in any row and column crosssection to see it from a different angle/perspective. E.g Think of it as a cardboard cube box which I am seeing from top view but if I need to see the different layers of the box then I will take a knife and cut it from top in half and seeing it from front which will show me the layers of the box.
3. After doing this, I simply applied the hilbert transform to demodulate the images as they are taken in time domain and supposed to be demodulated.</p><p>Result: Yayy....I got some results. See attached, you'll understand what I am mentioning it too. The image attached shows three different lines on the cross sectional image but to see those HORIZONTAL lines(sample) clearly, I need to remove the noise(vertical) lines shown in the image. It will enhance the quality of the image and probably produce much clearer image of it.</p><p>Question: Any idea on I can improve this image?</p><p>Thanks</p>Rahul Thakurhttps://www.mathworks.com/matlabcentral/profile/authors/5757086rahulthakurtag:www.mathworks.com,2005:Question/35791220170922T13:08:36Z20170922T14:42:14Zhow to plot ecdf with > 0 value in a subplot?<p>Hello all,
I am biased correcting climate data. In Figure below subplot (a) and (b) are fine as data is less or greater than zero, however, subplot (c) due to a lot of zero values, the bias correction doesn't appear very clear. Is there anyway, I can plot only data that correspond to values greater > 0. Here is my code and the sample figure</p><pre class="languagematlab">subplot(1,3,1)
[f,x]=ecdf(BMinT_his_EC);
plot(x,f,'r','LineWidth',1)
hold on
[f,x]=ecdf(BMinT_his_RRCM5);
plot(x,f,'k','LineWidth',1)
[f,x]=ecdf(BMinT_his_CRCM5);
plot(x,f,'b','LineWidth',1)
hold off
text(40,0.95,'$\textcircled{\bf a}$', 'Interpreter', 'latex','color','k','FontSize',20);
axis tight
ylabel('Cumulitive frequency');
xlabel('Temperature (\circC)')
</pre><pre class="languagematlab">subplot(1,3,2)
[f,x]=ecdf(BMaxT_his_EC);
plot(x,f,'r','LineWidth',1)
hold on
[f,x]=ecdf(BMaxT_his_RRCM5);
plot(x,f,'k','LineWidth',1)
[f,x]=ecdf(BMaxT_his_CRCM5);
plot(x,f,'b','LineWidth',1)
hold off
text(40,0.95,'$\textcircled{\bf b}$', 'Interpreter', 'latex','color','k','FontSize',20);
axis tight
ylabel('Cumulitive frequency');
xlabel('Temperature (\circC)')
</pre><pre class="languagematlab">subplot(1,3,3)
[f,x]=ecdf(BPrec_his_EC);
plot(x,f,'r','LineWidth',1)
hold on
[f,x]=ecdf(BPrec_his_RRCM5);
plot(x,f,'k','LineWidth',1)
[f,x]=ecdf(BPrec_his_CRCM5);
plot(x,f,'b','LineWidth',1)
hold off
text(60,0.95,'$\textcircled{\bf c}$', 'Interpreter', 'latex','color','k','FontSize',20);
ylabel('Cumulitive frequency');
xlabel('Precipitation (mm)')
</pre><pre class="languagematlab">set(gcf,'NextPlot','add');
axes;
set(gca,'Visible','off');
h = title('Bias correction of Regional Climate Modem (RCM) ver 4','fontweight','b','fontSize',16);
set(h,'Visible','on');
</pre><img src = "/matlabcentral/answers/uploaded_files/88714/bias_correction.png">Hydrohttps://www.mathworks.com/matlabcentral/profile/authors/5628601hydrotag:www.mathworks.com,2005:Question/35750720170920T09:11:55Z20170922T14:41:07ZHow to explain the difference of the simulation result between Matlab neural network function and simulink model?<p>Hi Guys,
I use matlab neural network toolbox to generate a NN, using gensim to get simulink model and using genFunction to get matlab function of the closed net. I use the generated matlab neuralnetworkfunction to built a subsystem in simulink (as NN model) runing parallel in simulink to make the comparison
The result is a little bit different, can anyone explain me what I have done wrong?</p><img src = "/matlabcentral/answers/uploaded_files/88509/abc.JPG"><p>this is my model</p><img src = "/matlabcentral/answers/uploaded_files/88510/abc1.JPG"><p>this is the result, the yellow line is of simulink model, the blue one is of matlab function model</p><p>Thanks</p>DANG NGOC DANHhttps://www.mathworks.com/matlabcentral/profile/authors/10209149dangngocdanhtag:www.mathworks.com,2005:Question/35793120170922T14:40:02Z20170922T14:40:02Zhow do i put this code in button GUI I = imread('cameraman.tif'); J = imcomplement(I); imshowpair(I,J,'montage')<p>how do i put this code in button GUI I = imread('cameraman.tif');
J = imcomplement(I);
imshowpair(I,J,'montage')</p>John jerrick Pulmanohttps://www.mathworks.com/matlabcentral/profile/authors/11040347johnjerrickpulmanotag:www.mathworks.com,2005:Question/35793020170922T14:39:50Z20170922T14:39:50Zhow can i write a matlab code for lte handover ?<pre> any help in source code examples in handover writing in matlab</pre>marwa khashabahttps://www.mathworks.com/matlabcentral/profile/authors/11012438marwakhashabatag:www.mathworks.com,2005:Question/35773320170921T12:54:59Z20170922T14:37:43ZAttempting to find a fit to this data<p>Hi there,</p><p>Looking to find a curve fit to this data as shown (and attached) in this post. The catch is that it's 3D data, not 2D...</p><p>I am aware of the Kriging function, however I require a function where I know the form of the resulting function so that I can analytically find its derivative.</p><img src = "/matlabcentral/answers/uploaded_files/88629/Screenshot%20from%2020170921%20085427.png"><p>Any thoughts would be appreciated...</p>bsquaredhttps://www.mathworks.com/matlabcentral/profile/authors/3903365bsquaredtag:www.mathworks.com,2005:Question/35740120170919T15:19:09Z20170922T14:37:29ZHow can I find the angle between a cubic smoothing spline and a line ?<p>Hello everyone,</p><p>As I started my internship in researching, I started using Matlab in some much more difficult way that I used to in my school, which explain my appearance on your forum.</p><p>Here is my problem:</p><p>I need to program something which allows me to detect the contact angle of a droplet on a surface.
I have already programmed a part which allows me to detect the sides of the droplet, to mark it with some markers, and to get the coordinates of each markers,
Then, I used the cubic smoothing spline function in order to get an approximated curve of my sides:</p><pre class="languagematlab">sz2 = size(tabl2);
Size2 = sz2(1);
for it = 1:Size2
Xg(it) = tabl2{it}(1);
Yg(it) = tabl2{it}(2); % Minus added because of the axis direction
end
Smooth = csaps (Xg,Yg,0.05); % Xg and Yg are basically the coordinates of the left side of my droplet.
</pre><p>I also used a basic polyfit in order to model the contact line.</p><p>Here is a picture of the curves I get :</p><img src = "/matlabcentral/answers/uploaded_files/88447/Plot.png"><p>The blue line is my cubic spline, which represent the side of my droplet.</p><p>The red line represents the surface, which isn't perfectly straight.</p><p>Now I need to get the contact angle between my cubic spline and my contact line, but I am stuck on it,
Do you have any ideas?</p><p>Thank you very much for you help.</p>Clement Prunierhttps://www.mathworks.com/matlabcentral/profile/authors/11009130clementpruniertag:www.mathworks.com,2005:Question/35792920170922T14:31:54Z20170922T14:31:54Zproblem in glcm graycomatrix code???<p>hi
when i use this code
I = imread('circuit.tif');
glcm = graycomatrix(I,'Offset',[2 0])</p><p>i get this error Error in graycomatrix (line 167)
[I, Offset, NL, GL, makeSymmetric] = ParseInputs(varargin{:});</p><p>Error in Untitled56 (line 2)
GLCM = graycomatrix(I,'Offset',[2 0;0 2]);
can help me
and thank you</p>aliah aljohanihttps://www.mathworks.com/matlabcentral/profile/authors/11016570aliahaljohanitag:www.mathworks.com,2005:Question/35792720170922T14:13:58Z20170922T14:28:43ZWhat is parametric analysis?<p>What is parametric analysis?</p>Will Husahttps://www.mathworks.com/matlabcentral/profile/authors/11040379willhusatag:www.mathworks.com,2005:Question/35724320170918T20:08:21Z20170922T14:28:22ZPassing a 2D array from Matlab to a .NET function<p>I am working on a Matlab program in which I need to pass a 2D array (uint8, 128X128) to a .NET method.</p><p>I used Matlab function, zeros(128,128), to create this array and passed it to the .NET method. The method was supposed to write image data (bitmap) into this array. However, the array remained unchanged (i.e., all zeros) after calling the .NET method several times.</p><p>I greatly appreciate if you can provide me some suggestions regarding this issue.</p>Will Lhttps://www.mathworks.com/matlabcentral/profile/authors/1227060willltag:www.mathworks.com,2005:Question/6591120130305T08:08:45Z20170922T14:25:23ZImage processing GLCM gray level cooccurance matrix<p>In function graycomatrix,the output is always 8x8 matrix,i am not getting why its 8x8 ,can anybody help me out</p>NAhttps://www.mathworks.com/matlabcentral/profile/authors/4121809natag:www.mathworks.com,2005:Question/35754020170920T11:48:03Z20170922T14:23:00ZHow to generate Optimization toolbox functions(like fmincon )code for Raspberrypi ?<p>Is it possible to generate raspberry pi code for MATLAB optimization functions like fmincon? Is any dedicated toolboxes (like embedded coder)needed for this( apart from the raspberry pi addon)?</p>venkatasundarakumar t shttps://www.mathworks.com/matlabcentral/profile/authors/10716587venkatasundarakumartstag:www.mathworks.com,2005:Question/35782620170922T00:30:46Z20170922T14:18:35ZHow Can I replace specific lines in a text file<p>I'm dealing with text files and I want to replace certain lines in the text. I do not know their location but I know the text in an above and a later line to those lines.</p><p><b>Example for that text</b></p><p>TABLE: "LINK PROPERTY DEFINITIONS 02  LINEAR"
Link="Rails Pinned" DOF=U1 Fixed=Yes
Link="Rails Pinned" DOF=U2 Fixed=Yes</p><p>TABLE: "MASS SOURCE"
MassSource=MSSSRC1 Elements=Yes Masses=Yes Loads=No IsDefault=Yes</p><p>TABLE: "MATERIAL PROPERTIES 04  USER STRESSSTRAIN CURVES"
Material="Timber Ties" Strain=0.00078125 Stress=1</p><p>I would like to replace the line/lines after <b>TABLE: "MASS SOURCE"</b> and before the following word <b>TABLE:</b>
The word table repeats many times in the original text and because of that I need the following word <b>TABLE:</b>
Is it possible?</p><p>Thank you</p>Ahmed Ragehhttps://www.mathworks.com/matlabcentral/profile/authors/6833051ahmedragehtag:www.mathworks.com,2005:Question/35756120170920T13:35:15Z20170922T14:17:50ZMy matlab gets an error when trying to plot anything<p>As the title says, this only happened recently and I'm not sure what triggered it.</p><p>I'm using Windows 64.
This comes up every time I plot something:</p><p>Error using gca
Can't load 'C:\Program
Files\MATLAB\R2017a\bin\win64\osgserver.dll': C:\Program
Files\MATLAB\R2017a\bin\win64\osgserver.dll is not a valid
Win32 application.</p>Ye Chenhttps://www.mathworks.com/matlabcentral/profile/authors/10788943yechentag:www.mathworks.com,2005:Question/35792820170922T14:15:02Z20170922T14:15:02ZHow to start the image recognition in Mat lab?<p>Hi everyone,
I want to create a mobile application that can detect the tree disease. I'm focusing on the oil palm tree disease and want to detect the Basal Stem Root disease. The idea are:
1. User can take the picture of the tree.
2. The application will detect either it has been infected or not by the disease.</p><p>So, I need to use Mat Lab to recognize the picture. Can anybody help me what should i start first cause i have no idea about it.</p><p>Thank you.</p>Nazatul Nadhirah Mohd Zainudiinhttps://www.mathworks.com/matlabcentral/profile/authors/10958610nazatulnadhirahmohdzainudiintag:www.mathworks.com,2005:Question/35792620170922T14:13:09Z20170922T14:13:09ZSuggest of any image effects or image transformation using button GUI need for project<p>thanks for the suggestion and maybe there's a suggestion thanks to everyone god bless</p>John jerrick Pulmanohttps://www.mathworks.com/matlabcentral/profile/authors/11040347johnjerrickpulmanotag:www.mathworks.com,2005:Question/35790220170922T12:43:44Z20170922T14:10:34Zhwo to normalise the points with matlab command<p>i am using this command for normalising [p1,t1] = Normalise2DPts(p1);
[p2,t2] = Normalise2DPts(p2);
when i am running this in matlab it gives me this error Undefined function or variable 'Normalise2DPts'
can any one help me what command should i use or i am doing error
p1 and p2 are p1 and p2 are 2xN matrix</p>praveen raihttps://www.mathworks.com/matlabcentral/profile/authors/8574409praveenraitag:www.mathworks.com,2005:Question/47220110127T00:06:29Z20170922T14:07:44ZCan I run a bat file with Matlab?<p>Hi! I have a bat file created to kill process:</p>
<p>taskkill /IM excel.exe</p>
<p>Can I run it with Matlab?</p>
<p>Thanks</p>Jorgehttps://www.mathworks.com/matlabcentral/profile/authors/2707159jorgetag:www.mathworks.com,2005:Question/35788220170922T10:13:02Z20170922T14:06:24ZHow to solve integral numerically in Matlab?<p>if R=integral(10*exp(60/{T(t)*Ni(x)}*Ni(x)),
integral limit, x=0 to x=10
Ni(x) is 1D interpolation function as used in finite element method, T is function of time, shape function is function of length.
How to solve integral in Matlab if using "Gauss quadrature rule" or if there some command guidance to be written in code.
Please I need guidance.</p><p>Thank you</p>Qudsiya Irumhttps://www.mathworks.com/matlabcentral/profile/authors/9760047qudsiyairumtag:www.mathworks.com,2005:Question/35693820170916T03:25:16Z20170922T14:02:17Zdata acquisition toolbox DTI daq modules with external clock<p>I have been using dti9816s modules to collect analog signals using the data acquisition toolbox. This worked very well until I tried to use an external clock to set the sample rate. I see a message that addClockConnection isn't supported for the dt devices. Is there any way to overcome this problem?</p>Lawrence Karrhttps://www.mathworks.com/matlabcentral/profile/authors/143169lawrencekarrtag:www.mathworks.com,2005:Question/35792420170922T14:01:48Z20170922T14:09:09ZHow to extract nonsequential cells/numbers in multiple text files?<p>I have tried using importdata, textscan, and dlmread to import data from my text file (which is attached) so I can extract certain values at a set interval into an array, then compiled in another text file. I think I have come to the realisation that the problem is the text file. The file is full of letters and numbers, and not in an easy format to just extract data. I am wondering if there is another way, instead of writing lines and lines of formatSpec, to obtain the data. The process in words below:
1. Import text files that are nonsequential (i.e. RK1.txt, FK4.txt, etc...)
2. Pick out the data I want from the file
3. Put data into an array or matrix
4. Convert that matrix or array from that file into another .txt file.</p><p>The numbers I use are under "Principal directions" column, rows "Specimen D" and "system I" (group of 6 values). There should be 18  25 groupings of these values in one text file that all need to be imported.
If there is no way to do this without lines of formatSpec, than so be it, but does anyone have a simpler solution to a scattered .txt file problem?</p>Matthew Warbrittonhttps://www.mathworks.com/matlabcentral/profile/authors/8672808matthewwarbrittontag:www.mathworks.com,2005:Question/35791720170922T13:30:57Z20170922T13:58:31ZError using ^ One argument must be a square matrix and the other must be a scalar. Use POWER (.^) for elementwise power.<p>Hi, I'm Trying to write minimization function from this function,</p><pre class="languagematlab">(42.1*x1^2+x1^4/3)*x1^2+x1*x2+(4+4*x2^2)*x2^2
</pre><p>where,</p><pre> 10 <= x1 <= 10 and 10 <= x2 <= 10.</pre><p>this what I'm writing, is this right?</p><pre class="languagematlab">min = 10;
max = 10;
x1 = min+max*rand();
x2 = min+max*rand();
</pre><pre class="languagematlab">T = 1.0;
Tmin = 0.0000001;
refresh = 0.9;
</pre><pre class="languagematlab">finalMin = (42.1*x1^2+x1^4/3)*x1^2+x1*x2+(4+4*x2^2)*x2^2;
finalCoordinate=[x1,x2];
</pre><pre class="languagematlab">while(T>Tmin)
i=0;
while(i<=300)
x1= min+max*rand(1,1);
x2= min+max*rand(1,1);
newMin = (42.1*x1^2+x1^4/3)*x1^2+x1*x2+(4+4*x2^2)*x2^2;
delta1 = finalMinnewMin;
if(newMin < finalMin)
finalMin=newMin;
finalCoordinate=[x1,x2];
elseif(2.71828^(delta/T))>(0+(rand(1)*1))
finalCoordinate=[x1,x2];
end;
i=i+1;
end;
T = T*refresh;
end;
</pre><p>But why, at</p><pre class="languagematlab">elseif(2.71828^(delta/T))>(0+(rand(1)*1))
</pre><p>Error using ^
One argument must be a square matrix and the other must be a scalar. Use POWER (.^) for elementwise power.</p><p>And how to obtain 100% accuracy from that coordinate?</p>Hafiizh Sukandarhttps://www.mathworks.com/matlabcentral/profile/authors/11015366hafiizhsukandartag:www.mathworks.com,2005:Question/35779020170921T19:22:45Z20170922T13:57:02Ztimer causes drawing problem when loading a figure<p>When running a GUI that has a timer callback, I notice that loading other GUI figures often fails (incorrect rendering). Is this known behavior? Are there any workarounds? I assume that the code loading the figures isn't immune to a timer spontaneously injecting code ... (e.g. updating the current figure or axes).</p><p><b>Edit:</b>
I'm using Matlab 2016a or newer (need to check specific version) on Windows 7. The code to load the figure is:</p><pre class="languagematlab">fig = openfig(fig_path);
</pre><p>After running this line the figure is rendered incorrectly. The figure is the wrong size and components are not where they are supposed to be.</p><p>The loaded figures have been created by GUIDE with no code generation (just figure layout). The remaining code (not shown) only adds callbacks and updates display strings; no components are created or positions/sizes changed.</p>Jim Hokansonhttps://www.mathworks.com/matlabcentral/profile/authors/937359jimhokansontag:www.mathworks.com,2005:Question/35743820170919T20:33:12Z20170922T13:54:25ZGetting array size error when using plotIGESentity?<p>I'm using the function plotIGESentity from IGES toolbox as follow.</p><pre class="languagematlab">for i=1:length(ParameterData);
plotIGESentity(ParameterData,i);
view(60,42)
grid on
end
</pre><p>It used to work fine before I compile the C files and run the makeIGESmex.
but now when i run it with the same IGES file I get the following error!!!</p><pre> Error using nrbSrfRegularEvalIGES
Requested 12884903802x480 (23040.0GB) array exceeds maximum array size preference. Creation of arrays greater than
this limit may take a long time
and cause MATLAB to become unresponsive. See array size limit or preference panel for more information.</pre><pre> Error in retSrfCrvPnt (line 54)
[P,UV,TRI]=nrbSrfRegularEvalIGES(ParameterData{ind}.nurbs,ParameterData{ind}.u(1),ParameterData{ind}.u(2),nu,ParameterD
ata{ind}.v(1),ParameterData{ind}.v(2),nv); </pre><pre class="languagematlab">Error in plotIGESentity (line 137)
[P,isSCP,isSup,TRI]=retSrfCrvPnt(1,ParameterData,0,i,subd);
</pre><p>And when i run the code one another PC it works fine !!!</p><p>Any help is appreciated</p>Faez Alkadihttps://www.mathworks.com/matlabcentral/profile/authors/3644876faezalkaditag:www.mathworks.com,2005:Question/35792120170922T13:53:31Z20170922T13:53:31ZIs there a way to have access to a large 5D matrix inside a Simulink model without loading it to the Matlab workspace?<p>I have a model which uses a 5D look up table which is called from the work space when the Simulink model is solved (from work space block). Now I have to share this model but I do not want to share the look up table data. Is there a way to get that 5D look up table somehow stored in the Simulink model (so that the model can be solved on another laptop without having access to the LUT)? After that I would only have to protect the Simulink model itself but that is not a problem.</p>Florian Verbelenhttps://www.mathworks.com/matlabcentral/profile/authors/4970562florianverbelen