https://de.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2017-05-29T11:18:41Ztag:de.mathworks.com,2005:Question/3423492017-05-29T09:47:27Z2017-05-29T11:18:41ZSawtooth wave, using complex fourier transform find first 7 harmonic<p>There is a sawtooth wave with period T=1s and equation x(t)=t in the interval 0<=t<=T . Using the complex form of fourier transform , define the real amplitudes of the first 7 harmonic, without finding the phases. Could anyone help me do this in matlab ?</p><img src = "/matlabcentral/answers/uploaded_files/79041/help.bmp">Stanislav Kotzevhttps://de.mathworks.com/matlabcentral/profile/authors/10399365-stanislav-kotzevtag:de.mathworks.com,2005:Question/3423512017-05-29T10:01:41Z2017-05-29T11:14:23ZReference to non-existent field error occurring <p>Matlab is generating the 'reference to non-existent field' error for my code. It is refering to one of my handles. Online it appears that this occurs if the field does not exist in the structure at the time the callback is set. This is not true for the offending field in my code as it is declared in the opening function and I have used guidata to update the handles structure. Is there another reason why this error should be occurring?</p><pre class="language-matlab">Error while evaluating uicontrol Callback
</pre><pre class="language-matlab">Reference to non-existent field 'verticalBin'.
</pre><pre class="language-matlab">Error in new_window_2>pushbutton4_Callback (line 190)
set(handles.verticalBin, 'enable', 'on');
</pre><pre class="language-matlab">Error in gui_mainfcn (line 96)
feval(varargin{:});
</pre><pre class="language-matlab">Error in new_window_2 (line 42)
gui_mainfcn(gui_State, varargin{:});
</pre><pre class="language-matlab">Error in @(hObject,eventdata)new_window_2('pushbutton4_Callback',hObject,eventdata,guidata(hObject))
</pre><pre class="language-matlab">Error while evaluating uicontrol Callback
</pre>Aaron Smithhttps://de.mathworks.com/matlabcentral/profile/authors/9670029-aaron-smithtag:de.mathworks.com,2005:Question/3423592017-05-29T10:52:27Z2017-05-29T11:09:36ZHow to seperate a String at different positions?<p>Hallo MatLab-Pros,</p><p>I have a string which looks like this:
"DAT00000706LR0106700000100000002+000000194018602202101-0002-00010+000+0000000000+000+000+071+072008009000600000000000+00000+206+2060230000000000402+0000+000+001"</p><p>I'm trying to seperate it into little pieces, which are defined by length from a seperate Array. The DAT in the start can be ignored.</p><p>exp.: A = ( 4 2 2 1 1 5 6 4 4 ... and so on</p><p>So the new Array should somehow look like this:</p><p>0000 07 06 L R 01067 000001 0000 0002 ... and so on</p><p>Thanks</p><p>Mike</p>Michael Steinbuechlerhttps://de.mathworks.com/matlabcentral/profile/authors/10398570-michael-steinbuechlertag:de.mathworks.com,2005:Question/3423072017-05-29T02:07:08Z2017-05-29T11:06:41ZHow do you copy an mxArray to a char buffer<p>Hello,</p><p>I am pretty new to the data structures and memory manipulation of data.
I have a problem that is stumping me.</p><p>I create an mxArray from a char buffer. How do you go the other way from an mxArray to
a char buffer.</p><pre> memset(buffer,0,length);
memcpy(buffer, jsonBuffer.str().c_str(), length);</pre><pre> // mxCreateNumericMatrix 1xsize of data of class mxUNINT8_Class type of Real
mxArray * bufferMatrix=mxCreateNumericMatrix(1, length, mxUINT8_CLASS, mxREAL);</pre><pre> // Copy the char data buffer to the mmArray
memcpy(mxGetData(bufferMatrix), buffer, length*sizeof(char));
Big Thanks for any help,
Gary C</pre><pre> // How do you go the other way</pre>gary clarkhttps://de.mathworks.com/matlabcentral/profile/authors/10397789-gary-clarktag:de.mathworks.com,2005:Question/3423582017-05-29T10:48:13Z2017-05-29T10:55:40ZPlotting a 2D Heat map for a square?<p>Hi,</p><p>I have 9 Data points corresponding to temperatures within a 2d square, distributed as a 3 x 3 grid. I would like to create a colour plot whereby I have blue (cold) and red (hot) regions respectively. But I would like to have it blended such that intermediate temperatures are orange and slowly transition to red or blue. Basically if predicting the temperature at all locations. Treat the square as a 5 x 5 where the 3 x 3 inner points are known and the temperature along the boundaries are constant and known.</p><p>Please let me know if this makes sense.</p>Kulwinder Basutahttps://de.mathworks.com/matlabcentral/profile/authors/7784612-kulwinder-basutatag:de.mathworks.com,2005:Question/3416622017-05-24T06:58:39Z2017-05-29T10:44:45ZHow to detect " V " shape ? can any one help me?<p>How to detect " V " shape</p><img src = "/matlabcentral/answers/uploaded_files/78592/v_sahpe.jpg">Selva Karnahttps://de.mathworks.com/matlabcentral/profile/authors/4733665-selva-karnatag:de.mathworks.com,2005:Question/3423572017-05-29T10:44:39Z2017-05-29T11:01:17Zpick only the first element of elements within range<p>I would really appreciate some help on this.
I have data like these (in the form of column vectors):</p><pre> 152.500000000000
166.500000000000
169
172.500000000000
174
179
184.500000000000
188
189.500000000000
191.500000000000
193
199.500000000000
203</pre><p>and I want to start from the first one, find if there are following values that are within a range of 10, if there are keep the value of the checked element and delete the rest (within the range) and continue working downwards like that; if there are not following values within the range of 10 keep the value of the checked element.
For instance in this dataset as an output I want to have 152.5 (no other values within range 10), 166.5 (delete 169, 172.5, 174), 179 (delete 184.5, 188), 189.5 (delete 191.5, 193, 199.5), 203.
Thank you in advance</p>MARIANNA.KIhttps://de.mathworks.com/matlabcentral/profile/authors/8017321-marianna-kitag:de.mathworks.com,2005:Question/3423502017-05-29T10:00:40Z2017-05-29T10:38:01ZI can not get my workstation to run as fast as I expect for the cores frquency and memory it has?<p>My workstation with 32 cores runs much slower than a single core (same frequency) PC when I run a serial code with many iterations? With the large memory the workstation has I expect at least similar performance?</p>Bashar Issahttps://de.mathworks.com/matlabcentral/profile/authors/3564713-bashar-issatag:de.mathworks.com,2005:Question/2413742015-09-09T05:49:46Z2017-05-29T10:35:34ZlibGL error persists, and I've tried everything<p>and I mean I've tried EVERYTHING.</p><p>I try starting matlab (2015a, 2014b did the same), and I get this:</p><pre class="language-matlab">$ matlab
libGL error: unable to load driver: radeonsi_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: radeonsi
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 154 (GLX)
Minor opcode of failed request: 3 (X_GLXCreateContext)
Value in failed request: 0x0
Serial number of failed request: 36
Current serial number in output stream: 39
MATLAB is selecting SOFTWARE OPENGL rendering.
</pre><p>From within matlab, I get only software openGL:</p><pre class="language-matlab">>> opengl info
Version: '2.1 Mesa 7.2'
Vendor: 'Brian Paul'
Renderer: 'Mesa X11'
MaxTextureSize: 2048
Visual: 'Visual 0x9a, (RGBA 32 bits (8 8 8 8), Z depth 16 bits, Hardware acceleration, Double buffer, Antialias 0 samples)'
Software: 'true'
SupportsGraphicsSmoothing: 0
SupportsDepthPeelTransparency: 1
SupportsAlignVertexCenters: 0
Extensions: {114x1 cell}
MaxFrameBufferSize: 4096
</pre><p>I'm not the first to get this, and I've tried every fix I can think of and duckduckgo can find.</p><ul><li>Firstly, I've assumed that it was a problem with my installation and/or graphics drivers and/or card. See https://forums.gentoo.org/viewtopic-t-1012914.html for some of the other things I've tried, including recompiling my entire system a dozen times, I've tried hardened and non-hardened kernels. I've tried both official and open-source graphics drivers, I've even bought a new card to see if the other was faulty. I've tried different versions / releases, I've tried git sources of latest releases. I've chased down problems in mesa, in X, in KDE, tried wayland and gles to see if they help.</li></ul><p>Nothing.</p><p>Absolutely no difference.</p><ul><li>So I've tried other things, like linking libGL in the matlab directory to my system libGL from the official support-team answer here: https://www.mathworks.com/matlabcentral/answers/94805-why-does-my-linux-hardware-opengl-not-work-properly. To start, I did as written and linked just the libGL and not the libGLU:</li></ul><pre class="language-matlab">/usr/local/MATLAB/R2015a/sys/opengl/lib/glnxa64 $ ls -l
lrwxrwxrwx 1 rjs rjs 19 Sep 9 10:30 foolibGL.so.1 -> libGL.so.1.5.070200 % (these were copied so I didn't lose them)
-r-xr-xr-x 1 rjs rjs 3200281 Dec 29 2014 foolibGL.so.1.5.070200 % (these were copied so I didn't lose them)
-r--r--r-- 1 rjs rjs 1377 Dec 29 2014 libGL.rights
lrwxrwxrwx 1 rjs rjs 23 Sep 9 13:59 libGL.so.1 -> /usr/lib/libGL.so.1.2.0
lrwxrwxrwx 1 rjs rjs 23 Sep 9 13:58 libGL.so.1.5.070200 -> /usr/lib/libGL.so.1.2.0
-r--r--r-- 1 rjs rjs 1780 Dec 29 2014 libGLU.rights
lrwxrwxrwx 1 rjs rjs 20 Sep 9 10:29 libGLU.so.1 -> libGLU.so.1.3.070200
-r-xr-xr-x 1 rjs rjs 630382 Dec 29 2014 libGLU.so.1.3.070200
-r--r--r-- 1 rjs rjs 1319 Dec 29 2014 libMesa.rights
</pre><p>No change.</p><ul><li>I've tried linking the libGLU in the matlab path to my system libGLU as well, that also doesn't work. Actually, it makes it worse, both methods start the same but linking the libGL and not the libGLU gives me errors within matlab whenever I try to plot a graph:</li></ul><pre class="language-matlab">javax.media.opengl.GLException: X11GLXDrawableFactory - Could not initialize shared resources for :0
at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:317)
at jogamp.opengl.SharedResourceRunner.run(SharedResourceRunner.java:295)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.media.opengl.GLException: Startup Class Loader-SharedResourceRunner: Error making temp context(1) current: display 0x7f7de0000e10, context 0x7f7de00bd060, drawable X11OnscreenGLXDrawable[Realized true,
Factory jogamp.opengl.x11.glx.X11GLXDrawableFactory@a17b90b,
</pre><p>and a whole lot of other debug crap I can post if anyone thinks it's useful. Leaving libGL and libGLU both as default to use the matlab-supplied versions actually results in the least errors.</p><ul><li>I've tried linking my radeon drivers into various directories:</li></ul><pre class="language-matlab">/usr/local/MATLAB/R2015a $ ls */*/*dri* -l
lrwxrwxrwx 1 rjs rjs 29 Sep 9 09:53 bin/glnxa64/radeon_dri.so -> /usr/lib/mesa/radeonsi_dri.so
lrwxrwxrwx 1 rjs rjs 31 Sep 9 09:53 bin/glnxa64/swrast_dri.so -> /usr/lib/mesa/kms_swrast_dri.so
-r--r--r-- 1 rjs rjs 23551 Feb 3 2015 help/compiler/deploying-a-standalone-application-on-a-network-drive-windows-only.html
lrwxrwxrwx 1 rjs rjs 29 Sep 9 09:46 runtime/glnxa64/radeonsi_dri.so -> /usr/lib/mesa/radeonsi_dri.so
lrwxrwxrwx 1 rjs rjs 31 Sep 9 09:52 runtime/glnxa64/swrast_dri.so -> /usr/lib/mesa/kms_swrast_dri.so
</pre><pre class="language-matlab">/usr/local/MATLAB/R2015a $ ls */*/*/*dri* -l
lrwxrwxrwx 1 rjs rjs 29 Sep 9 09:56 bin/glnxa64/graphicssystems/radeon_dri.so -> /usr/lib/mesa/radeonsi_dri.so
lrwxrwxrwx 1 rjs rjs 31 Sep 9 09:56 bin/glnxa64/graphicssystems/swrast_dri.so -> /usr/lib/mesa/kms_swrast_dri.so
lrwxrwxrwx 1 rjs rjs 29 Sep 9 09:50 sys/os/glnxa64/radeon_dri.so -> /usr/lib/mesa/radeonsi_dri.so
lrwxrwxrwx 1 rjs rjs 29 May 26 13:20 sys/os/glnxa64/radeonsi_dri.so -> /usr/lib/mesa/radeonsi_dri.so
lrwxrwxrwx 1 rjs rjs 31 Sep 9 09:51 sys/os/glnxa64/swrast_dri.so -> /usr/lib/mesa/kms_swrast_dri.so
lrwxrwxrwx 1 rjs rjs 28 May 26 13:20 sys/os/glnxa64/swrastg_dri.so -> /usr/lib/mesa/swrastg_dri.so
</pre><p>and so forth. Again, no difference.</p><ul><li>I've also read that it can be a missing libstdc++ problem. For a start, my matlab or whatever toolboxes I've got installed a libstdc++ for me, so I didn't need to link to my system libstdc++. But I tried it anyway:</li></ul><pre class="language-matlab">/usr/local/MATLAB/R2015a/sys/os/glnxa64 $ ls -l *stdc*
lrwxrwxrwx 1 rjs rjs 21 May 26 13:44 foolibstdc++.so.6 -> ./libstdc++.so.6.0.17 % (again, just so I don't lose them)
-r-xr-xr-x 1 rjs rjs 6345639 Dec 29 2014 foolibstdc++.so.6.0.17 % (again, just so I don't lose them)
lrwxrwxrwx 1 rjs rjs 27 Sep 9 15:00 libstdc++.so -> /usr/lib/libstdc++.so.5.0.7
lrwxrwxrwx 1 rjs rjs 27 Sep 9 15:00 libstdc++.so.5 -> /usr/lib/libstdc++.so.5.0.7
lrwxrwxrwx 1 rjs rjs 27 Sep 9 15:00 libstdc++.so.5.0 -> /usr/lib/libstdc++.so.5.0.7
lrwxrwxrwx 1 rjs rjs 27 Sep 9 15:00 libstdc++.so.5.0.7 -> /usr/lib/libstdc++.so.5.0.7
lrwxrwxrwx 1 rjs rjs 27 Sep 9 15:01 libstdc++.so.6 -> /usr/lib/libstdc++.so.5.0.7
lrwxrwxrwx 1 rjs rjs 27 Sep 9 15:01 libstdc++.so.6.0 -> /usr/lib/libstdc++.so.5.0.7
lrwxrwxrwx 1 rjs rjs 27 Sep 9 15:01 libstdc++.so.6.0.17 -> /usr/lib/libstdc++.so.5.0.7
</pre><p>That opens up a whole lot of new errors on startup, along the lines of:</p><pre class="language-matlab">$ matlab
/usr/local/MATLAB/R2015a/bin/glnxa64/need_softwareopengl: /usr/local/MATLAB/R2015a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by /usr/local/MATLAB/R2015a/bin/glnxa64/need_softwareopengl)
/usr/local/MATLAB/R2015a/bin/glnxa64/need_softwareopengl: /usr/local/MATLAB/R2015a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/local/MATLAB/R2015a/bin/glnxa64/need_softwareopengl)
</pre><p>and about 100 more. So I'm not even going to try to link every single one of those to my system libraries.</p><ul><li>Finally, I've also tried changing my LD_LIBRARY_PATH from within matlab to just point to my /lib and /usr/lib first:
setenv('LD_LIBRARY_PATH','/lib:/usr/lib:/usr/local/MATL<snip>') % The rest as copied from getenv.</li></ul><p>And that won't even hold a value, when I setenv it, quit and restart matlab, getenv is as before, with no /lib nor /usr/lib values.</p><p>So, I can't think of anything else. There really is no way, it seems, to get any sort of openGL working on this system through any fix that someone's had before. Anyone know anything else to try, what more info is needed, etc?</p>a1077793https://de.mathworks.com/matlabcentral/profile/authors/6232956-a1077793tag:de.mathworks.com,2005:Question/3423562017-05-29T10:35:11Z2017-05-29T10:35:11ZExecute a .exe in Simulink<p>Hello,</p><p>I have to execute a .exe in a Simulink model.</p><p>I already tried via Matlab Function Block and the <i>system</i> function, but that won't work, because <i>system</i> is not code-generateable.
Is there another way to do this easily?</p><p>Thanks in advance.</p><p>Hasenearl</p>Hasenearlhttps://de.mathworks.com/matlabcentral/profile/authors/9482151-hasenearltag:de.mathworks.com,2005:Question/3423552017-05-29T10:33:47Z2017-05-29T10:33:47ZRaspberry Pi 3 SPI - Blocks. How to start the SPI Communication?<p>Hello, I can´t implement the Matlab Simulink SPI Block for Raspberry Pi 3. I wan´t to connect the Pi with an Arduino Mega. I can´t measure any Signal on the Ports.
Is there an example?</p><p>Thank you.
Best Regards, Daniel</p>Danielhttps://de.mathworks.com/matlabcentral/profile/authors/10215365-danieltag:de.mathworks.com,2005:Question/3418962017-05-25T11:36:44Z2017-05-29T10:28:31ZHelp urgent ! Error while evaluating uicontrol Callback<p>Hi !
Any idea why this is happening and how to fix it?</p><p>Thanks,</p><img src = "/matlabcentral/answers/uploaded_files/78748/proiect1.bmp"><img src = "/matlabcentral/answers/uploaded_files/78749/proiect.bmp"><img src = "/matlabcentral/answers/uploaded_files/78750/proiect2.bmp"><img src = "/matlabcentral/answers/uploaded_files/78751/proiect0.bmp">andrei cosminhttps://de.mathworks.com/matlabcentral/profile/authors/7886432-andrei-cosmintag:de.mathworks.com,2005:Question/3423542017-05-29T10:24:29Z2017-05-29T10:24:29ZWhere do I get the theory for the multiobjective genetic algorithm and hybrid function fgoalattain?<p>I have solved the multiobjective optimization problem using gamultiobj in optimization tool box. I used fgoalattain as a hybrid function. But I want detail theory for multiobjective genetic algorithm and fgoalattain hybrid function which is used in MATLAB.</p>ravindrahttps://de.mathworks.com/matlabcentral/profile/authors/2833502-ravindratag:de.mathworks.com,2005:Question/3423442017-05-29T08:31:09Z2017-05-29T10:20:51Zconvert base to base <p>Hallo guys i want convert base N to base M , i can convert that now , but my problem , i can not convert input to base i want couse like A = 10, B = 11,etc string but the other nummber. i know i am dummy to ask something like that. i already read another post about it but i cant find a solution of my problem .</p>Mohammad Imam Malikhttps://de.mathworks.com/matlabcentral/profile/authors/9865796-mohammad-imam-maliktag:de.mathworks.com,2005:Question/3423532017-05-29T10:19:20Z2017-05-29T10:24:45ZSimilar Command to This Coding<pre class="language-matlab">flag1=0;flag2=0;flag3=0;
</pre><pre class="language-matlab">setappdata(0,'flag1',num2str(flag1))
</pre><pre class="language-matlab">setappdata(0,'flag2',num2str(flag2))
</pre><pre class="language-matlab">setappdata(0,'flag3',num2str(flag3))
</pre><pre class="language-matlab">Numbers=randi(100,1,12);
</pre><pre class="language-matlab">N=num2str(Numbers);
</pre><pre class="language-matlab">setappdata(0,'Number',N);
</pre><pre class="language-matlab">set(handles.listnum,'string',num2str(Numbers));
</pre><pre class="language-matlab">for j=1:3
</pre><pre> c=combntns(Numbers,3);</pre><pre> target=sum(c,2);</pre><pre> u = unique(target);</pre><pre> X =u(histc(target,u)==1);</pre><pre> realtarget(j)=datasample(X,1);</pre><pre> threeans(j,:)=c(target==realtarget(j),:);</pre><pre> for i=1:3</pre><pre> Numbers(find(Numbers==threeans(j,i),1))=[];</pre><pre> end
end</pre><pre class="language-matlab">set(handles.answer1,'string',num2str(realtarget(1)));
</pre><pre class="language-matlab">set(handles.answer2,'string',num2str(realtarget(2)));
</pre><pre class="language-matlab">set(handles.answer3,'string',num2str(realtarget(3)));
</pre><pre class="language-matlab">Choose1=threeans(1,:);
</pre><pre class="language-matlab">Choose2=threeans(2,:);
</pre><pre class="language-matlab">Choose3=threeans(3,:);
</pre><pre class="language-matlab">setappdata(0,'Answer1',num2str(Choose1));
</pre><pre class="language-matlab">setappdata(0,'Answer2',num2str(Choose2));
</pre><pre class="language-matlab">setappdata(0,'Answer3',num2str(Choose3));
</pre><pre class="language-matlab">disp([Choose1 realtarget(1)])
</pre><pre class="language-matlab">disp([Choose2 realtarget(2)])
</pre><pre class="language-matlab">disp([Choose3 realtarget(3)])
</pre><pre> tic;</pre><p>How can I write this to different command but still have the same output when Im running this code. Thank you.</p>Alice Jacobhttps://de.mathworks.com/matlabcentral/profile/authors/10398711-alice-jacobtag:de.mathworks.com,2005:Question/3423252017-05-29T06:07:31Z2017-05-29T10:11:36ZHello guys. Please help me :)<p>I have 12 list of numbers and I was asked to find the summation for only three numbers. What is the command for that particular question? Here I attached the command that I have done. This actually related to GUI.</p><pre class="language-matlab">Numbers=randi(100,1,12);
N=num2str(Numbers);
setappdata(0,'Number',N);
set(handles.listnum,'string',num2str(Numbers));
</pre><pre class="language-matlab">realtarget=zeros(1,3);
set(handles.ans1,'string',num2str(realtarget(1)));
set(handles.ans2,'string',num2str(realtarget(2)));
set(handles.ans3,'string',num2str(realtarget(3)));
</pre>Suzy Amyrahttps://de.mathworks.com/matlabcentral/profile/authors/10398424-suzy-amyratag:de.mathworks.com,2005:Question/3418992017-05-25T12:05:31Z2017-05-29T10:02:54ZData returned by Audioread<p>I have a question regarding the audioread function in Matlab. Audioread('file.wav') will return a normalized data of -1 to 1 that represents the amplitude of the sound.
My question is, Are sensors (ex. Mica2) when acquire a sound signal and after doing the AD sampling will give me the same samples data that i'll get using Audioread?</p>Afnan H.https://de.mathworks.com/matlabcentral/profile/authors/8036168-afnan-htag:de.mathworks.com,2005:Question/3423522017-05-29T10:02:43Z2017-05-29T10:02:43Zhow to display precision and recall rates for an image?<p>sir, we are developed a code to salient region detection. in that we want to display precision and recall values for the final extracted image. please help me out. thanks in advance</p>Manyam Pavanihttps://de.mathworks.com/matlabcentral/profile/authors/9232212-manyam-pavanitag:de.mathworks.com,2005:Question/3413212017-05-22T09:30:32Z2017-05-29T09:57:41ZHow to convert engine cylinder pressure data (bar) to frequency (Hz) using FFT or STFT?<p>I need to convert incylinder pressure data (bars) to frequnecy (Hz) using time-frequency analysis. The pressure is obtained from 0-720 crank angle degrees.</p>Sandeep297https://de.mathworks.com/matlabcentral/profile/authors/5265577-sandeep297tag:de.mathworks.com,2005:Question/3423242017-05-29T05:57:52Z2017-05-29T09:39:13Zfind corresponding elements in a vector<p>Hello everyone! Let's assume we have the vectors U and V:</p><p>U=[6 6 18 18 3 19 12 18 24 24 10 22 11 27 28 18 12 12];</p><p>V=[5 7 10 10 21 2 21 10 23 7 1 13 2 19 10 1 13 21];</p><p>The length of the vectors usually ranges from 9 to 20. We are trying to correspond each element of U to one element in V which
satisfies certain conditions. For example, the right answer satisfies either U(j) = V(i) + abs(i-j) or U(j) = V(i) - abs(i-j)</p><p>The problem is using perms for length>9 goes to memory error. Any help is appreciated. I am running on a 32Bit. Thanks!</p>Alihttps://de.mathworks.com/matlabcentral/profile/authors/3543682-alitag:de.mathworks.com,2005:Question/3423392017-05-29T08:07:26Z2017-05-29T09:19:33ZDeclare contents of string variable as an explicit type without formatting them<p>Good day,</p><p>I try to convert a .hex file to a desired format using Matlab.</p><p>Up to now, i have managed to read the file and store its components to a cell string array ( Nx1 size, with N being the lines of the original file )</p><p>Now, what i try to do is read each element of the above mentioned cell array and break it into meaningful parts ( number of data bytes included in the line, target address, checksum etc ... ).</p><p><b>All these info are already included in each of the elements, so it is a matter of reading the correct characters to do that.</b></p><p>My question: At some point, i will need to do some manipulation of the data ( specifically, divide the address [ in hex format ] by 2 ).</p><p>How can i make Matlab understand that the specific string variable ( let's say 'Address' for the sake of argument ) includes data that is originally in hex format, and should be treated as such?</p>Dimitrios Paraskevashttps://de.mathworks.com/matlabcentral/profile/authors/8023449-dimitrios-paraskevastag:de.mathworks.com,2005:Question/1213162014-03-13T06:20:08Z2017-05-29T09:18:59Zhow to estimate Moving average(MA) model parameters<p>I just want to know is there any function available in matlab to estimate MA model parameters. Or else what are the other way to estimate it. Please let me know as soon as possible.
Thank you</p>Santhosh kumarhttps://de.mathworks.com/matlabcentral/profile/authors/4586180-santhosh-kumartag:de.mathworks.com,2005:Question/3422142017-05-27T22:48:51Z2017-05-29T09:18:35ZPlot Security Market Line<p>Hello,</p><p>I want to plot a Security Market Line. It should look like in the picture. My code so far:</p><pre class="language-matlab">load FundMarketCash
Returns = tick2ret(TestData);
Fund = Returns(:,1);
Market = Returns(:,2);
Cash = Returns(:,3);
MeanFund = mean(Fund)
MeanMarket = mean(Market)
</pre><pre class="language-matlab">[MM, aMM] = portalpha(Fund, Market, Cash, 'MM')
[GH1, aGH1] = portalpha(Fund, Market, Cash, 'gh1')
[GH2, aGH2] = portalpha(Fund, Market, Cash, 'gh2')
[SML, aSML] = portalpha(Fund, Market, Cash, 'sml')
</pre><pre class="language-matlab">efficient = plot ([SML, aSML])
set(gca,'XTickLabel','')
set(gca,'YTickLabel','')
title('SML','Fontsize',25)
set(gca,'Fontsize',16)
ylabel('Return')
xlabel('Beta')
</pre><p>But I need the dotted lines and the description. I guess this is quite simple, but I cannot find a answer.</p><p>Thank you very much in advance</p><p>Best regards</p><p>Ben</p>Benjamin Stegmannhttps://de.mathworks.com/matlabcentral/profile/authors/8939470-benjamin-stegmanntag:de.mathworks.com,2005:Question/3119432016-11-13T08:42:11Z2017-05-29T09:06:11ZHow to send Matlab socket using a loop?<p>I have a school project that requires letting Matlab send real-time data to Unity3D. I used the code from <a href = "http://stackoverflow.com/questions/35976685/how-unity-can-read-data-from-matlab-socket">this question</a> using Unity as the server. So far all worked well until I tried placing it in a loop.</p><p>For testing purposes I just tried it in a small while loop :</p><pre class="language-matlab">tcpipClient = tcpip('127.0.0.1',55001,'NetworkRole','Client');
set(tcpipClient,'Timeout',30);
c = 0;
while(c < 10)
fopen(tcpipClient);
fwrite(tcpipClient,num2str(c));
fclose(tcpipClient);
c = c+1;
end
</pre><p>It properly sends the data to Unity up to 5 times but on the 6th it gives the following error:</p><pre class="language-matlab">Error using icinterface/fopen (line83)
Unsuccessful open: Connection refused: connect
Error in connectUnity (line 8) fopen(tcpipClient);
</pre><p>However, when I tried entering</p><pre class="language-matlab">fopen(tcpipClient);
fwrite(tcpipClient,num2str(c));
fclose(tcpipClient);
</pre><p>in the command window multiple times, it gives no such error.</p><p><b>How can I properly send these sockets to Unity using a loop?</b></p><p>BTW, our school project/thesis is a real-time emotion recognition system. The emotion detected per frame should be sent to Unity3D that's why it should be in a loop.
Thank you!</p>Isabela Marie Rosaladohttps://de.mathworks.com/matlabcentral/profile/authors/7763155-isabela-marie-rosaladotag:de.mathworks.com,2005:Question/3423342017-05-29T07:31:25Z2017-05-29T09:01:48Zhow to place a image on a specific coordinates of figure<img src = "/matlabcentral/answers/uploaded_files/79028/place%20image%20in%20specific%20coordinate%20of%20figure.png"><p>I wants to place a image on a specific coordinates of figure. Refer the attached image for more understanding</p>Stalin Samuelhttps://de.mathworks.com/matlabcentral/profile/authors/5200170-stalin-samueltag:de.mathworks.com,2005:Question/3422852017-05-28T20:19:01Z2017-05-29T09:01:30ZWhy I cannot plot anything?<p>I just installed the trial /linux version/ and every time I try to plot something, eg.</p><pre class="language-matlab">Trial>> x=0:20/pi:2*pi;
y=sin(x);
plot(x,y)
</pre><p>What's wrong?</p><p>program hangs up.</p>Olga Lisowskahttps://de.mathworks.com/matlabcentral/profile/authors/10395772-olga-lisowskatag:de.mathworks.com,2005:Question/3423172017-05-29T04:43:44Z2017-05-29T08:58:50ZCan't retrieve array content, just metadata<p>Hi everyone!</p><p>I have a task where I need to open a csv file and extract and manipulate the data. I have now tried with the comands: <b>importdata</b>, <b>fopen</b>, <b>load</b> and several others. However, I keep only getting info about the data aray, but can't actually access the data i.e. I get lines like: [8x1 double] but never the actual content. What am I doing wrong? Here's an example:</p><pre class="language-matlab">filename = 'efhk_weather_data_14_15.csv';
delimiterIn = ',';
headerlinesIn = 1;
A = importdata(filename,delimiterIn,headerlinesIn);
A
</pre><p>As a result I get the text:
A =</p><pre> data: [398x1 double]
textdata: {399x23 cell}</pre><p>Thanks a lot!</p>Makhttps://de.mathworks.com/matlabcentral/profile/authors/4866251-maktag:de.mathworks.com,2005:Question/3423432017-05-29T08:31:06Z2017-05-29T08:57:29ZPLOT from excel data<p>Hallo,
How can i plot the data from an excel sheet. I don't want to read the data of excel every time. Instead i want to store the data locally and call it once.
For example i want to plot data from excel sheet with respect to multiple random cells a= C48:W48, b= C50:W50 c=C34:D34 d=B82:C82.....
Plot(a,b,c,d..)</p><p>my code:</p><pre class="language-matlab">b = xlsread('abc.xlsm','Sheet1','C48:W48')
a = xlsread('abc.xlsm','Sheet1','C50:W50')
c = xlsread('abc.xlsm','Sheet1','C34:D34')
d = xlsread('abc.xlsm','Sheet1','B82:C82') %%eigen_1.............
..
plot(a,b,c,d...)
</pre><p>This takes lot of time because it reads excel file every time. PLease help since i am new to this...</p>aiyappa macharanda ganeshhttps://de.mathworks.com/matlabcentral/profile/authors/5917166-aiyappa-macharanda-ganeshtag:de.mathworks.com,2005:Question/3423472017-05-29T08:56:25Z2017-05-29T08:56:25Zfunction with multiple datasets<p>I have been asked to make af function which calculates the total and average tax payed in 15 different states.
My data is imported from excel and looks like:</p><p>1 (5000x4 cell)</p><pre> 'Serialnumber' 'Name' 'Gender' 'State'
'4654194314624' 'Sara ' 'M' [ 14.00]
'4565196234864' 'Michael Sims ' 'M' [ 4.00]
'6548197914565' 'Mazon Watt ' 'M' [ 7.00]</pre><p>2 (5000x2 cell)</p><pre class="language-matlab">'Serialnumber' 'Income'
'4567456766023' [ 76500.00]
'2567467775130' [ 90750.00]
</pre><p>3 (16x4 cell):</p><pre> 'State' 'lower tax' 'tax limit' 'higher tax'
'7' [27.00] [ 55900.00] [51.00]
'8' [25.00] [ 55100.00] [45.00]
'9' [26.00] [ 56000.00] [45.00]
'10' [28.00] [ 54000.00] [43.00]</pre><p>To calculate the average and total tax i need all three files, but i haven't been able to see through it yet. I thought about creating a new cell containing all relevant data.
I also tried the following, but that would only give me the total for a single state. Any simple ways to go about it?</p><pre> for i=2:length(Income)
if strcmp(Income(i,1),Citizens(i,1))
personalIncome = Income{i,2};
region = Citizens{i,4};
end
if Citizens{i,4}==1
personalincome=Income{i,2};
incomesum=incomesum+personalincome;
people=people+Citizens{i,4};
end
for v=2:length(Taxes)
if strcmp(Taxes(v,1),num2str(region))
tax1=Taxes{v,2};
tax2lim=Taxes{v,3};
tax2=Taxes{v,4};
end
end
if incomesum<=Taxes{v,3}
taxesPaid = incomesum*tax1/100;
else
taxesPaid = taxesPaid+((tax2lim*tax1/100)+((personalincome-tax2lim)*tax2/100))
end
tax=incomesum/people*taxesPaid;
totaltax=totaltax+taxesPaid;</pre>Chrisshttps://de.mathworks.com/matlabcentral/profile/authors/10194517-chrisstag:de.mathworks.com,2005:Question/3423052017-05-29T01:55:51Z2017-05-29T08:55:29ZGA Optimization problem (constraints)<p>a part of constraints like this</p><p>x(1)=2.99*x(2)+3.55(x(3)+4.55x(4)</p><p>x(2)+x(3)+x(4)=1</p><p>x(2),x(3),x(4) binary variables</p><p>I convert above constraints as below...</p><p>x(1)-2.99*x(2)-3.55(x(3)-4.55x(4);</p><p>-x(1)+2.99*x(2)+3.55(x(3)+4.55x(4);</p><p>x(2)+x(3)+x(4)-1;</p><p>1-x(2)-x(3)-x(4);</p><p>if x(2)=1, x(3)=0, x(4)=0 then, x(1)=2.99. right?</p><p>My matlab result are x(2)=1, x(3)=0, x(4)=0, but x(1) is not 2.99.</p><p>why the result is not reasonable?
Is there any reason?</p><p>I attached my m-file.
(Lingo as well)</p>younghyeon yanghttps://de.mathworks.com/matlabcentral/profile/authors/7898943-younghyeon-yangtag:de.mathworks.com,2005:Question/3421592017-05-27T08:48:13Z2017-05-29T08:54:56ZHow do I use a While loop at each point in a matrix<p>I have my code written as</p><pre class="language-matlab">K1 =0.02054;
K2 = 0.1096;
K3 = 0.055;
K4 = 0.2898;
C = 1.0451;
P10 = ((950*6894.76)+101325);
P20 = 101325;
P5 = ((30*6894.76)+101325);
M = 0;
N = (P5-P20)/(P10-P5);
nsamples = 10000;
D1 = 0.001556385+rand(nsamples,1)*0.00016383;
D2 = 0.00979678+rand(nsamples,1)*0.00103124;
A1 = (pi/4)*D1.^2;
A2 = (pi/4)*D2.^2;
R = (D1.^2/1./D2.^2);
a = 2*D1.^2/1./D2.^2;
b = ((2*C*M^2*D1.^2)/1./D2.^2);
c = (1+C*M)*(1+M)*(1+K4+K3)*D1.^4/1./D2.^4;
d = (C*M^2*(1+K2)*D1.^4/1./D2.^4);
b1 = ((D1.^2/1./D2.^2)-1);
d1 = (1-(2*D1.^2/1./D2.^2)+(D1.^4/1./D2.^4));
e = (1+K1);
i = (N-((a+(b/1./b1)-c-(d/1./d1))/1./((e-a-(b/1./b1)+c)))< 0.0001);
Nnew = ((a+(b/1./b1)-c-(d/1./d1))/1./(e-a-(b/1./b1)+c));
---------------------------------------------------------------------
</pre><p>The above code will give the values of Nnew at a constant M for each combination of D1 and D2 in a matrix. But I want value of M for which i satisfies for each combination of D1 and D2. This M should be used to calculate Nnew at each point. So I mean to say that While loop need to be executed at each combination of D1 and D2 to get the value of M as well as Nnew at each point in a matrix.
I have tried but not getting the intended result:</p><pre class="language-matlab">while i
M = M + 0.0001;
Nnew = ((a+(b/1./b1)-c-(d/1./d1))/1./(e-a-(b/1./b1)+c));
end
</pre>Prasant Jhahttps://de.mathworks.com/matlabcentral/profile/authors/4833508-prasant-jhatag:de.mathworks.com,2005:Question/3423462017-05-29T08:53:06Z2017-05-29T08:53:06Zhow can i find simstruct_tag in s-function?<p>i want to change s-function's input ports number and find function ssSetNumInputPorts.</p><p>but it needs simstruct *s, and i don't know what my s-function's simstruct.</p><p>where can i find simstruct?</p>HYUN DONG KIMhttps://de.mathworks.com/matlabcentral/profile/authors/7845740-hyun-dong-kimtag:de.mathworks.com,2005:Question/3420742017-05-26T14:14:42Z2017-05-29T08:46:02ZMatlab comparison of two large matricies<p>I am trying to retrieve the index of exact matches (row-specific) between two large matricies. I have a n x 61 matrix A containing values from 0 to 9 and another n x 61 matrix B , whereas each row here contains values from 0 to 9 but mostly NaN (only 2 to 8 columns in each row of matrix B contain actual numbers). Matrix A can be expected to have between 1.5 million and 3 million rows, whereas matrix B has around 0.2 to 0.5 million rows. Here is an example of the setup:</p><pre class="language-matlab">% create matrix a with random data
</pre><pre class="language-matlab">dataSample = [0 9];
numRows = 1000000;
numCols = 61;
A = randi(dataSample,numRows,numCols);
</pre><pre class="language-matlab">% create matrix B with random data
numRows = 100000;
numCols = 61;
numColsUse = 2:8;
dataRange = 0:9;
B = NaN(numRows,numCols);
for i = 1:size(B,1)
</pre><pre> % randomly selet number of columns to fill
numColsFill = datasample(numColsUse,1);</pre><pre> % randomly select column index from available columns
colIdx = datasample([1:numCols],numColsFill);</pre><pre> % randomly select values from 0 to 9
numFill = datasample([0:9],numColsFill);</pre><pre> % insert numbers at respective column in matrix B
B(i,colIdx) = numFill;</pre><pre class="language-matlab">end
</pre><p>I want to compare every single row of matrix A with the entire matrix B and find exact matches, where the numbers of matrix B match the numbers of matrix A at their respective positions (columns) - hence the NaN in matrix B are to be ignored.</p><p>I can achieve the desired result using cellfun, where I slice matrix A in several subsets and then use a custom function to compare the rows of the subset with each row in matrix B, like so:</p><pre class="language-matlab">% put all rows of matrix B in single cell
cellB = {B};
</pre><pre class="language-matlab">% take subset of matrix A and convert to cell array
subA = A(1000:5000,:);
subA = num2cell(subA,2);
</pre><pre class="language-matlab">% prepare cellB to meet cellfun conditions
cellB = repmat(cellB, [size(subA,1) 1]);
</pre><pre class="language-matlab">% apply cellfun to retrieve index of each exact match
idxContainer = cellfun(@findMatch, cellB, subA, 'UniformOutput', false);
</pre><p>Function findMatch looks as follows:</p><pre class="language-matlab">function [ idx ] = LTableEval( cellB, subA )
</pre><pre> idxCheckLT = lt(cellB, repmat(subA, [size(cellB,1) 1]));
idxCheckGT = gt(cellB, repmat(subA, [size(cellB,1) 1]));
idxCheck = idxCheckLT + idxCheckGT;
idxSum = sum(idxCheck,2);
idx = find(idxSum == 0);</pre><pre class="language-matlab">end
</pre><p>This approach works, but it appears to be very inefficient, especially RAM-wise, as the cellfun requires all inputs to have the same size and hence a multiplication of the same data sets. Any ideas on how to tackle this problem in a more efficient way? Many thanks!</p>Benvaulterhttps://de.mathworks.com/matlabcentral/profile/authors/3960639-benvaultertag:de.mathworks.com,2005:Question/3346862017-04-10T18:33:28Z2017-05-29T08:45:38ZEfficiently update MATLAB App Designer GUI real time from Simulink<p>I have a Simulink model and a GUI made in app designer from which I control said model. So far I have been able to let the GUI and the Simulink model communicate both ways. The GUI sets parameter constant blocks in the model using <tt>set_param</tt> whereas the model updates the GUI through a callback using <tt>add_exec_event_listener</tt>. <b>The GUI object resides in the model workspace.</b></p><p>In the startup callback of the model <tt>StartFcn</tt> I have the following code</p><pre class="language-matlab">set(0,'ShowHiddenHandles','on');
blk = [model '/q-log']; % Block to bind listener to
event = 'PostOutputs'; % Event to bind to (fired at every sample)
app = getVariable(get_param(bdroot,'ModelWorkspace'),'app'); % The GUI
</pre><pre class="language-matlab">% The GUI is passed into the event handler and updated at every timestep
listener = @(obj,event) updategui(obj,event,app);
h = add_exec_event_listener(blk, event, listener);
</pre><p>The problem with this setup is that it is extremely slow. I'm not quite sure how to get it faster and if this is the way to go. I've looked at a lot of examples but none detail my needs.</p><p>So my question is if there is a faster or more efficient way to update the GUI fields and plots? It doesn't have to be hard real time but writing variables to workspace and importing it into the GUI afterwards not is not acceptable.</p>Nickhttps://de.mathworks.com/matlabcentral/profile/authors/3040834-nicktag:de.mathworks.com,2005:Question/950392013-08-06T20:31:00Z2017-05-29T08:45:30ZWhy does the SDK 7.1 installation fail with an "Installation Failed" message on my Windows system?<p>I am working with MATLAB 7.14 (R2012a) 64-bit. I need to setup a compiler configuration for MATLAB on my system.</p><p>When I try to execute the following MATLAB command:</p><pre class="language-matlab">mex -setup
</pre><p>I receive the following error:</p><pre class="error"> </pre><pre> No supported SDK or compiler was found on this computer. </pre><pre> For a list of supported compilers, see </pre><pre> <http://www.mathworks.com/support/compilers/R2012a/win64.html></pre><p>If I try to install Microsoft Windows SDK 7.1, a supported compiler for MATLAB 7.14 (R2012a), on my system, the installation fails with the following error message:</p><img src = "http://www.mathworks.com/matlabcentral/answers/uploaded_files/1481/c0aab23bc74ac422c734752b9ff6ab99.png">MathWorks Support Teamhttps://de.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:de.mathworks.com,2005:Question/3423452017-05-29T08:35:08Z2017-05-29T08:40:43ZSetting plot data on a colormapped axes<p>Hi all. I usually find what I'm looking for here, but this problem was too specific I guess. I am using MATLAB R2014a.
When plotting (or scattering) data, one can use the plot handle to apply:
"set(h,'XData',x,'YData',y,'ZData',z)". But, when I use scatter3 with a colormap argument (i.e. h=scatter3(x,y,z,markerSize,colorMapping)), then the handle h gets it's 'Children' field become an array with more handles, each relates to a point on the graph and is made of a whole new structure ('patch' Type). In this case, when one uses the "set" command mentioned before, it turns the 'Children' into an empty array and all the points disappear from the graph. My question is: is there a way to set the x,y,z data of a plot that had been colormapped, without having all the points disappear?
Thanks in advance,
Tim</p>Timhttps://de.mathworks.com/matlabcentral/profile/authors/5680269-timtag:de.mathworks.com,2005:Question/3423422017-05-29T08:28:57Z2017-05-29T08:30:22ZCreate binary mask from contour segmentation <p>I have segmented the image using active contours. The resultant image gives contours. I want to create a binary mask by assigning 1 value (White) to the area segmented by contours and rest of the image as 0 (Black). How can I create the binary mask? Kindly suggest.</p>Nataliyahttps://de.mathworks.com/matlabcentral/profile/authors/5953637-nataliyatag:de.mathworks.com,2005:Question/2465072015-10-02T04:00:00Z2017-05-29T08:23:01ZWhy can't MEX find a supported compiler in MATLAB R2015b after I upgraded to Xcode 7.0?<p>I installed Xcode 7.0 on my Mac and tried to use MEX. I receive the following error at the MATLAB command prompt:</p><p> </p><pre class="error"> >> mex -setup
Error using mex
No supported compiler or SDK was found. For options, visit
http://www.mathworks.com/support/compilers/R2015a/maci64.html</pre><p> </p><p>Why does MATLAB not recognize the Xcode 7.0 installation on my Mac?</p>MathWorks Support Teamhttps://de.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:de.mathworks.com,2005:Question/3422712017-05-28T15:33:51Z2017-05-29T08:21:26ZMatlab code from literature gives errors<p>have this code from a book I recently looked at, I want to implement the code but I get loads of errors , can someone help me localize the errors or possibly make a runnable example?</p><pre class="language-matlab">function [P,b]=AmericanPrice(r,delta,sigma,K,nx,nt, Xhat,That)
%Usage:P=AmericanPrice(r,delta,sigma,K,nx,nt,Xhat,That)
%Example:P=AmericanPrice(0.08,0.12,.2,100,50,10,300,3)
dx=Xhat/nx;
dt=That/nt;
for i=1:nx-1
A(i,i:i+2)=[((r-delta)*dt*i-sigmaˆ2*dt*iˆ2)/2...
1+r*dt+sigmaˆ2*dt*iˆ2
(-(r-delta)*dt*i-sigmaˆ2*dt*iˆ2)/2];
end
P(:,1)=max(K-[0:dx:Xhat],0);
</pre><pre class="language-matlab">if(delta==0)
b(1)=K;
else
b(1)=min(K,K*r/delta);
end
</pre><pre class="language-matlab">for j=2:nt+1
bn=0; run=1;
while(run)
An=[A(1+bn:end,1+bn:end)];
An(end+1,end-1:end)=[-1 1];
An(end+1,1)=1;
Cn=[P(bn+2:nx,j-1)’ 0 K-bn*dx]’;
Pn=inv(An)*Cn;
if(Pn(2)$<$K-((bn+1)*dx))
bn=find(sign(diff(Pn)/dx+1)-1,1,{’last’})+bn;
else
b(j)=bn*dx; run=0;
end
end
P(:,j)=[K-[0:bn-1]*dx Pn’];
end
</pre><p>what i have done so far: i changed the sigmaˆ2 to sigma*sigma, same thing with i. Then i replaced the ’ with '. I did not know what to d o with "..." The error i get is</p><pre class="language-matlab">Undefined function 'find' for input arguments of type 'cell'.
</pre><pre class="language-matlab">Error in FDM (line 28)
bn=find(sign(diff(Pn)/dx+1)-1,1,{'last'})+bn;
</pre>Khttps://de.mathworks.com/matlabcentral/profile/authors/3790244-ktag:de.mathworks.com,2005:Question/3423412017-05-29T08:20:49Z2017-05-29T08:20:49ZUsing Monte Carlo in bertool the plotted Ber curve is coming as a horizontal line and sometime is constant values over Eb/No. Why?<p>In my channel coding using convolutional codes without consider modulation/ demodulation simulation model,when I am plotting the BER vs Eb/No graph using Monte Carlo of bertool, I get a horizontal line or constant values as straight line? same horizontal line of the BER vs Eb/No plot when I change the channel coding to turbo codes and LDPC codes.
I have followed all the steps guideline on using Monte Carlo of bertool but I getting the horizontal line of BER vs Eb/No graph. why?
Pls, what should I do to get waterfall in my channel coding using convolutional codes simulation model without consider modulation/ demodulation?
Pls, help me to solve it.
Thank you.</p><img src = "/matlabcentral/answers/uploaded_files/79032/1.PNG">z mhttps://de.mathworks.com/matlabcentral/profile/authors/7588122-z-mtag:de.mathworks.com,2005:Question/3423402017-05-29T08:19:05Z2017-05-29T08:19:56ZHDL Coder Clock Summary Explanation<p>When i am generating a HDL code using the Simulink HDL coder, on the code generation report i get a clock summary report. And there are two values, Model Based Rate and the DUT Based Rate. I understand where the values come from but i dont understand what they actually mean. So the value in the Model Based Rate is the value I entered in the simulink fundamental sample time and DUT based rate is the maximum Fs of my design. What do they mean and what is the application of this two values, i did not find anything on the documentation</p><p>I am attaching a screenshot of my clock summary, As you can see the Left Out and Right Out has a sample time of 8.85771e-08 which is basically 11.28 MHz. Does this ensure that my output data is coming out at 11.28 MHz. This is what i understood by reading the matlab documentation so far.</p><img src = "/matlabcentral/answers/uploaded_files/79035/Clock%20Summary.png">shaukhttps://de.mathworks.com/matlabcentral/profile/authors/5412142-shauktag:de.mathworks.com,2005:Question/3423362017-05-29T07:43:55Z2017-05-29T08:12:56ZHow to convert compressed bit stream into image <p>Hi,
I have compressed the image and got the output in the bitstream, I am not getting how to convert it into an image.
please, anyone, give me a solution.</p>DEEPIKA https://de.mathworks.com/matlabcentral/profile/authors/8621128-deepikatag:de.mathworks.com,2005:Question/3423382017-05-29T07:58:29Z2017-05-29T08:10:00Zi have a mxn matrix. I have to use a 3x3 mask to compare the center value with all 8 neighborhood values and put a threshold to the difference (above which the center pixel has to be replaced with 0)<p>Can anyone help me with the automated code</p>Venkat Sai Kumar Kothalahttps://de.mathworks.com/matlabcentral/profile/authors/8579131-venkat-sai-kumar-kothalatag:de.mathworks.com,2005:Question/504612012-10-11T06:11:52Z2017-05-29T08:00:17ZScope showing no output<p>I have a mdl for 7 level inverter for SPWM,in this the scope is not showing output for 7 level.please help</p><p><a href = "http://www.sendspace.com/file/if3m2e">http://www.sendspace.com/file/if3m2e</a></p>kashhttps://de.mathworks.com/matlabcentral/profile/authors/3198049-kashtag:de.mathworks.com,2005:Question/3423372017-05-29T07:53:13Z2017-05-29T07:53:13ZExtract data from sparse matrix in a parfor loop<p>Hi,
I need to find eigenvectors and eigenvalues for a lot of 100*100 tri-diagonal matrices.
they defined as follow:</p><pre> A_kk = a_n ; % main diagonal (a_n is some vector)
A_kk_below = b_n*f; %below main diagonal (b_n is some vector, and f is a number which differ at each matrix)
A_kk_above = c_n*f; %above main diagonal (c_n is some vector, and f is a number which differ at each matrix)</pre><p>I'm looking for a fast way to do it so my strategy was to define a large large tridiagonal sparse matrix.
Then inside a parfor loop to take part of the sparse matrix and calculate its eigenvectors/values</p><pre> N=100;
Len_f=100;
a_ln_t=zeros(N,N,Len_f);
parfor i=1:Len_f
A_f = full(A((i-1)*N+(1:N),(i-1)*N+(1:N))); % take part of the sparse matrix A
[EigV,Eig] = eig(A_f,'vector'); % find eigenvectors/values
[Eig,iEig] = sort(Eig); % sort eigenvalues
EigV = EigV(:,iEig); % sort eigenvectors
Eig_f(:,:,i) = EigV; % save results in variable
end</pre><p>But the problem is that I get a warning when trying to take part of the sparse matrix.</p><p>"The entire array or structure "A" is a broadcast variable. This might result in unnecessary communication overhead"</p><p>Is there any suggestions on how to avoid this warning and improve this code and perhaps make it faster?</p><p>Any input on this matter would be highly appreciated</p>dhttps://de.mathworks.com/matlabcentral/profile/authors/5382698-dtag:de.mathworks.com,2005:Question/3422902017-05-28T21:58:10Z2017-05-29T07:47:11ZHow to display video by App designer?<p>Am I able to use the <b>App Designer</b> to build an application, which can read the video information from <b>Simulink</b> (the video processed by Simulink), and display it with <b>full screen</b>?</p>ying xionghttps://de.mathworks.com/matlabcentral/profile/authors/7625009-ying-xiongtag:de.mathworks.com,2005:Question/3423302017-05-29T06:42:33Z2017-05-29T07:41:39ZWriting Video Frames in Parallel<p>So I came up with a way to write video frames in parallel so that I could take advantage of all the cores in my computer only I keep getting a weird bug where I can only write videos up to 52.1 MB. Does anyone have any idea what might be going on? Below is my code I've been using to write video frames in parallel.</p><pre class="language-matlab">spmd(1,4)
open(videoWriter);
CountIndex = [0];
for i = labindex:numlabs:numFiles
if labindex == 1
frame1 = imread(fullfile(workingDirectory, stackName, imageFiles(i).name));
end
if labindex == 2
frame2 = imread(fullfile(workingDirectory, stackName, imageFiles(i).name));
end
if labindex == 3
frame3 = imread(fullfile(workingDirectory, stackName, imageFiles(i).name));
end
if labindex == 4
frame4 = imread(fullfile(workingDirectory, stackName, imageFiles(i).name));
end
</pre><pre> while ~any(abs(CountIndex-(labindex-1))<1e-10)
end
if labindex == 1
writeVideo(videoWriter,frame1);
end
if labindex == 2
writeVideo(videoWriter,frame2);
end
if labindex == 3
writeVideo(videoWriter,frame3);
end
if labindex == 4
writeVideo(videoWriter,frame4);
end
CountIndex = [CountIndex labindex];</pre><pre> if length(CountIndex) == length(numlabs)+1
CountIndex = [0];
end
end
end
end</pre>Jacob Mevorachhttps://de.mathworks.com/matlabcentral/profile/authors/8897350-jacob-mevorachtag:de.mathworks.com,2005:Question/157682011-09-13T17:29:52Z2017-05-29T07:40:37ZExtreme learning machine forecasting/prediction<p>Hello, Matlab experts!</p><p>I'm interesting in apply extreme learning machine method for time-series forecasting/prediction. The most commonly used code is on <a href="http://www.ntu.edu.sg/home/egbhuang/ELM_Codes.htm">http://www.ntu.edu.sg/home/egbhuang/ELM_Codes.htm</a></p><p>Does anyone knows how to use it for forecasting time-series (like Santa Fe or Mackey-Glass)?</p><p>Thanks for your help!</p>Gorynhttps://de.mathworks.com/matlabcentral/profile/authors/1880750-goryntag:de.mathworks.com,2005:Question/1710042015-01-21T18:01:27Z2017-05-29T07:26:27ZHow to plot a line with angle of 'Orientation' and length of 'MajorAxisLength' through 'Centroid'?<p>Dear All,</p><p>I would like to plot a line with angle of 'Orientation' and length of 'MajorAxisLength' through 'Centroid'.</p><p>Similar as shown in image bellow:</p><p><a href = "http://uk.mathworks.com/help/images/ref/referencemtoz11.gif">http://uk.mathworks.com/help/images/ref/referencemtoz11.gif</a></p><p>The code I'm using right now, is piloting the line with the right angle, but it starts from the center</p><pre> st = regionprops(Image,'Centroid','Orientation','MajorAxisLength');
x = st.Centroid(1) + st.MajorAxisLength * cosd(st.Orientation);
y = st.Centroid(2) - st.MajorAxisLength * sind(st.Orientation);
line([c(1) x],[c(2) y]);
How can do it right, maybe I should use BoundingBox as well?</pre><p>Thanks in advance for any help,</p><p>I</p>Ivan Shorokhovhttps://de.mathworks.com/matlabcentral/profile/authors/3296276-ivan-shorokhovtag:de.mathworks.com,2005:Question/3423312017-05-29T07:09:42Z2017-05-29T08:37:57Z how i will get the cluster pixel x and y . And for the pixel value to be filtered (m to z)<p>I have done k means clustering on an image. how i will get the cluster pixel x and y . And for the pixel value to be filtered (m to z).</p><p>code</p><pre class="language-matlab">% Project Title: clustring
clc;
clear all;
close all;
warning off;
</pre><pre class="language-matlab">[filename,pathname] = uigetfile({'*.*';'*.bmp';'*.tif';'*.gif';'*.png'},'Pick an Image File');
I = imread([pathname,filename]);
I = imresize(I,[256,256]);
figure(1), imshow(I); title('Image1');
</pre><pre class="language-matlab">I=rgb2gray(I);
figure(2), imshow(I); title('Image2');
</pre><pre class="language-matlab">%%%%%%%%%%%%%%%%%%%%%
imData=reshape(I,[],1); %covert into arry
imData=double(imData); % convert unit into double
prompt={'Enter the clustering value'};
num_lines=1;
dlg_title='Cluster Point Input';
kmn_val=str2double(inputdlg(prompt,dlg_title,num_lines));
[ID nn]=kmeans(imData,kmn_val);
I2=reshape(ID,size(I));
</pre><pre class="language-matlab">figure(3),imshow(I2,[]);
%%%%%%%%%%%%%%%%%%%%%%%%Plot %%%%%%%%%%%%%%
if (mod(kmn_val,2)==0)
for e=1:kmn_val
r=kmn_val/2;
subplot(r,2,e);imshow(I2==e,[]);
end
else
for e=1:kmn_val
r=(kmn_val+1)/2;
subplot(r,2,e);imshow(I2==e,[]);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
</pre>SHRUTI FRANCIShttps://de.mathworks.com/matlabcentral/profile/authors/8067481-shruti-francis