http://de.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2014-12-18T20:09:09Ztag:de.mathworks.com,2005:Question/1671292014-12-18T20:09:09Z2014-12-18T20:09:09ZHow to add a circuit element in series via MNA netlists?<p>Hey guys. So I've got this algorithm in which I have a whole bunch of impedance values that need to be added to a given circuit (one at a time), and I have to measure the new Y - parameters across a given frequency range. With netlists in MATLAB, you can only add elements in parallel. Does anyone how to add an element to an existing circuit in series?</p>Luv Tomar/matlabcentral/answers/contributors/5970080-luv-tomartag:de.mathworks.com,2005:Question/1668642014-12-16T22:15:01Z2014-12-18T20:02:49ZWhen modelling the melting of snow on sea-ice, how can I create a vector, for example the density of both snow and ice, respectively, so that I can run it in a loop?<p>I am currently writing a code to model the evolution of melt-ponds on sea-ice. For simplicity, I have divided the snow and ice into 5 layers each. I am using a diffusion equation. My aim is to model the melt within a loop, so I believe I need to create vectors for constants like specific heat capacity and density for the two given mediums. The density for snow = 200 and ice = 919 (kg m-3). So I can then calculate this in the model</p><pre class="language-matlab">(dt/(rho.*c.*dz))*Q
</pre><p>Thank you in advance.</p>Thomas/matlabcentral/answers/contributors/5994248-thomastag:de.mathworks.com,2005:Question/1671202014-12-18T18:33:46Z2014-12-18T19:58:11ZHow to let the matlab to remember the previous directory?<p>I have this task daily:</p><p>Many plots are generated within the same "run". Then I check each of them. If it's good, I save it through "file" -> "save as".</p><p>However, for every save I need to choose the directory again. I wonder if I can setup matlab and let it to remember the last directory just seconds ago like many other software.</p><p>Thanks.</p>Jian/matlabcentral/answers/contributors/4297175-jiantag:de.mathworks.com,2005:Question/1671242014-12-18T18:47:32Z2014-12-18T19:54:23ZA Problem with log10<p>Dear all</p><p>I just began to work w Matlab. I have an array with decimal numbers and zeros from which I have to calculate log10 and write a new array, but it doesn't work. When i run this i got error "Attempted to access log10(0.946491); index must be a positive integer or logical." code is as follows</p><pre class="language-matlab">log10=zeros(2030,1354);
for j=1:1354
for i=1:2030
log10(i,j)=R547(i,j)/R531(i,j);
end
end
log10(isnan(log10)) = 0 ; %my array
>> for j=1:1354
for i=1:2030
if log10(i,j)~=0
X(i,j)=log10(double(log10(i,j)));
end
end
end
</pre><p>Anyone please help me</p><p>Thank you</p>Alina/matlabcentral/answers/contributors/5999519-alinatag:de.mathworks.com,2005:Question/1671282014-12-18T19:53:30Z2014-12-18T19:53:30ZHow to compute time delay [Tau] of two RF signals coming from an RTL-SDR [or any source] after computing Cross Correlation without using XCORR<p>Hey guys,</p><p>I was wondering if anyone could share a sample code or an algorithm to find similarity between two RF signals coming from an RTL-SDR [or any radio source]. I want to cross correlate the two signals and find the time delay between them.</p>srikant/matlabcentral/answers/contributors/4871743-srikanttag:de.mathworks.com,2005:Question/1671232014-12-18T18:44:08Z2014-12-18T19:51:42Zfitting a normal distribution function to a set of data<p>Hi, I have a set of data, in the form of a histogram (with actual data also ready) and I want to fit a normal distribution curve on it. Is their an efficient way to do it?</p><p>Thanks</p>cgo/matlabcentral/answers/contributors/5852688-cgotag:de.mathworks.com,2005:Question/1670562014-12-18T08:41:14Z2014-12-18T19:28:17ZUnderstanding Matlab multiobjectiveoptimization functions<p>I have questions concerning the optimization function "fgoalattain". I use this formulation to find the paretooptimum in a multiobjective optimization problem with 2-3 objectives. The objectives and their weights and goals have following form:</p><p>f(1) = ...; weight(1) = 10; goal(1) = 0;</p><p>f(2) = ...; weight(2) = 1; goal(2) = 0;</p><p>f(3) = ...; weight(3) = 1; goal(3) = 0;</p><p>The documentation explains that if a goal for a specific objective is "0", I need to use the option "GoalsExactAchieve". I do not really understand this option. Which value do I need to choose for "GoalsExactAchieve", 1 or 3? Considering it is most important, that f(1) is minimized, I applied a weight of "10" to this objective. But are the weights even active if I use the option "GoalsExactAchieve"?</p><p>Alternatively i use the function gamultiobjectiveoptimization. There it is not possible to define weights or goals, why not?</p><p>In general, do the objectives need to have the same order in a multiobjectiveoptimization, or does the toolbox normalize the values by itself?</p><p>Thanks in advance!</p>Ben/matlabcentral/answers/contributors/3180864-bentag:de.mathworks.com,2005:Question/1670522014-12-18T07:55:46Z2014-12-18T19:25:07ZRepresentation of a function <p>Hi I state that are new to the world of matlab so I'm not an expert.</p><p>Should I edit a script in which I have a function, displayed with the plot command.
This function represents the transmission of a single bit.
I suppose now I have to send more bits at a distance of a predetermined time (that I know) so I should recalculate and represent the corresponding graph.
Someone would know help me?</p><p>thanks</p>loredana/matlabcentral/answers/contributors/5998056-loredanatag:de.mathworks.com,2005:Question/1671272014-12-18T19:18:52Z2014-12-18T19:55:00Zproblem with solving overlapping sounds <p>I'm currently trying to give my matlab game sound. To stop the sounds from overlapping I found a solution and changed the data accordingly.</p><pre class="language-matlab">SOUND_FILE_NAMES = {'.\sounds\pacman_beginning.wav', '.\sounds\pacman_chomp.wav', ...
'.\sounds\pacman_death.wav', '.\sounds\pacman_eatfruit.wav', ...
'.\sounds\pacman_eatghost.wav', '.\sounds\pacman_extrapac.wav', ...
'.\sounds\pacman_intermission.wav', '.\sounds\pacman_moving.wav'};
</pre><pre class="language-matlab">SOUND_KEYS = {'Beginning', 'chomp', 'death', 'eatfruit', 'eatghost', ...
'extrapac', 'intermission', 'moving'};
</pre><pre class="language-matlab">SOUND_SAMPLES = [5,5,5,3,3,2,6,5];
</pre><pre class="language-matlab">obj.audioPlayers = struct();
for i = 1 : length( SOUND_FILE_NAMES )
[y, Fs] = audioread(SOUND_FILE_NAMES{i});
str = 'audioplayer(y,Fs)';
for j = 2 : SOUND_SAMPLES(i);
str = sprintf('%s, audioplayer(y,Fs)', str );
end
eval( sprintf('obj.audioPlayers.(SOUND_KEYS{i}) = {%s};', str ));
</pre><pre> end</pre><pre class="language-matlab">PlaySound(obj,'Beginning');
</pre><p>and the function</p><pre class="language-matlab">function PlaySound( obj, soundName )
</pre><pre> done = false;
i = 1;
while ~done && i < length(obj.(soundName))
if ~obj.(soundName){i}.isplaying()
obj.(soundName){i}.play();
done = true;
end
i = i + 1;
end
end</pre><p>But I only get the error</p><pre class="language-matlab">Reference to non-existent field 'Beginning'
</pre><pre class="language-matlab">Error in PlaySound (line 7)
while ~done && i < length(obj.(soundName))
</pre><p>I don't know how to solve this problem.</p>Gino/matlabcentral/answers/contributors/5960871-ginotag:de.mathworks.com,2005:Question/1671222014-12-18T18:43:23Z2014-12-18T19:14:49ZRemove element from cell array completely<p>I have a cell array with the following information:</p><pre> >> handles.guideGUI</pre><pre> ans = </pre><pre class="language-matlab">Columns 1 through 8
</pre><pre> @arq_02 @arq_03 @arq_04 @arq_05 @arq_06 @arq_07 @arq_08 @arq_09</pre><pre class="language-matlab">Columns 9 through 14
</pre><pre> @arq_10 @arq_11 @arq_12 @arq_13 @arq_14 []</pre><p>It is still saying that that this is a 1x14 cell, and therefore the empty brackets [] still exist. How do I get rid of it completely so that it becomes 1x13 cell?</p><p>i.e. I want it to appear as:</p><pre> ans = </pre><pre class="language-matlab">Columns 1 through 8
</pre><pre> @arq_02 @arq_03 @arq_04 @arq_05 @arq_06 @arq_07 @arq_08 @arq_09</pre><pre class="language-matlab">Columns 9 through 13
</pre><pre> @arq_10 @arq_11 @arq_12 @arq_13 @arq_14</pre>Muaaman/matlabcentral/answers/contributors/5823965-muaamantag:de.mathworks.com,2005:Question/1671262014-12-18T19:12:53Z2014-12-18T19:12:53ZLinear Transformer Turn Ratio<p>I am trying to simulate a SIB Converter having specs attached. I just want to know how can I set the turn ratio of a linear transformer (1:5)....</p><p>Help will be really appreciated. Thanks in Advance :)</p>Hammad Armghan/matlabcentral/answers/contributors/5999565-hammad-armghantag:de.mathworks.com,2005:Question/1670782014-12-18T10:42:32Z2014-12-18T19:10:38ZDir command addresses one extra file<p>Hello all,</p><p>I have a folder containing 9 .htk files. I need to use "dir", and then "readhtk" in a loop to import them to MATLAB, but DIR appears to give 10 files instead of 9!
here is my code:</p><pre> htkfiles = dir('/Users/Desktop/Acsegment/mfcdir/*.htk');
nhtkfiles = length(htkfiles); % 10!!! It should be 9 tough!
data = cell(nhtkfiles,2);
for k = 1:nhtkfiles
b(k,1) = strcat({'/Users/Desktop/Acsegment/mfcdir/'},{htkfiles(k,1).name});
eval(['data{k,1} = readhtk(b{k,1});']);
end</pre><p>When looking at the filenames in htkfiles, I have them like this:</p><pre> htkfiles(1,1).name = '.htk'
htkfiles(2,1).name = 'fadg0_si1279.htk'
htkfiles(3,1).name = 'fadg0_si1909.htk'
htkfiles(4,1).name = 'fadg0_si649.htk'
htkfiles(5,1).name = 'fadg0_sx109.htk'
htkfiles(6,1).name = 'fadg0_sx19.htk'
htkfiles(7,1).name = 'fadg0_sx199.htk'
htkfiles(8,1).name = 'fadg0_sx289.htk'
htkfiles(9,1).name = 'fadg0_sx379.htk'
htkfiles(10,1).name = 'faks0_si943.htk'</pre><p>Comparing to what I see in that folder, the first file is not supposed to be there!
Anyone got any ideas why Im getting one extra file?</p>Negar/matlabcentral/answers/contributors/4405202-negartag:de.mathworks.com,2005:Question/1671142014-12-18T17:01:12Z2014-12-18T19:09:04ZHow to Place an image over existing plots?<p>Hello,
I have some graphs in Matlab over which I want to insert a small image. I do not want to cover the graphs completely, and want to know how to specify the exact position for overlaying this image onto the existing plots. I have used imread to read the file, but cannot seem to figure out imshow to display the image properly where I would like it to be.</p>Ashley/matlabcentral/answers/contributors/4321335-ashleytag:de.mathworks.com,2005:Question/1671212014-12-18T18:36:00Z2014-12-18T18:44:33ZHow to create a 2D circular intensity plot?<img src = "/matlabcentral/answers/uploaded_files/22753/snapshot.png"><p>Hi,
I can generate 2D plots like in the image above in comsol. I want to generate the same in matlab. This is a plot of electric field distribution in a cylindrical resonator. My matlab code has the electric field as a function of radius and angle. May be creating a meshgrid and then using polar command might be the way to go but I am not sure how to do that correctly. Any suggestion or link would be appreciated.
Thanks <a href = "</matlabcentral/answers/uploaded_files/22752/snapshot.png"></matlabcentral/answers/uploaded_files/22752/snapshot.png</a>></p>Zeba/matlabcentral/answers/contributors/2270000-zebatag:de.mathworks.com,2005:Question/1373932014-06-24T16:55:44Z2014-12-18T18:37:13ZHow can we encourage more thoughtful feedback on FEX submissions? <p>Is there a way that either TMW or File Exchange (FEX) users can encourage more thoughtful feedback on FEX pages? I find that ratings without verbal feedback are not very helpful. I always wonder, "did you give this submission one or two stars because there are errors in the code; because it's computationally inefficient; because you didn't take the time to learn how to use it; because it was designed to solve a different problem than the problem you are trying to solve?" A five-star rating can be a helpful endorsement, but when I see a four-star rating without explanation I am left to wonder about the submission's weaknesses.</p><p>Perhaps the most confounding rating is a three-star rating without comment. What does it mean? On more than one occasion I've even noticed users who have created a Mathworks account simply to leave a three-star rating without comment, and have not left any other feedback on FEX. Clearly they're driven to express their lack of opinion, but there's no telling why.</p><p>It's counter-intuitive, but I think reducing the five-star rating system to a simple thumbs-up/thumbs-down rating could actually add nuance, particularly if a minimum word limit were required when giving a negative review. Amazon has recognized the value of a minimum word limit in reviews, and it's turned out to be quite helpful.</p><p>Without a redesign of the FEX rating system, is there a way to encourage more thoughtful feedback?</p>Chad Greene/matlabcentral/answers/contributors/1062128-chad-greenetag:de.mathworks.com,2005:Question/1668242014-12-16T14:50:54Z2014-12-18T18:32:49Z2D Transient Heat Conduction with neumann condition<p>Hi All,</p><p>I had been having trouble on doing the matlab code on 2D Transient Heat conduction with Neumann Condition. I do not know how to specify the Neumann Boundary Condition onto matlab. For example, Du/Dt = 5.</p><p>Any help would be appreciated as currently, there are no one helping and I cant find any related source regarding to Neumann on matlab.</p><p>Thank you for any help! :)</p>emily/matlabcentral/answers/contributors/5717569-emilytag:de.mathworks.com,2005:Question/1671192014-12-18T18:23:38Z2014-12-18T18:23:38ZForecasting by Neural Network<p>Hello everyone ! I am entirely new to the "Neural Network Toolbox". However I have explored many example data sets provided in NN toolbox , but i am having trouble in fitting my own case study into it . i am frustrated and completely drained out after following many webinars and searching here. Your help will be highly appreciated . My problem is as follows .</p><pre> I have the data set which contains monthly demand of 30 vehicle models of a heavy commercial automobile manufacturer for the past 3 years. In short , my datasheet is of size [ 30 X 36 ] , ( 30 vehicle models are represented row wise) . </pre><p>I want to forecast the future demand of all vehicles by using Neural Network . I have tried using Curve Fitting , Time series (both NAR and NARX) by the default setting and various training algorithms , But still the MSE is not acceptable . Is it just because of my "SMALL data set" ? or anything else ?</p><p>Kindly suggest me some method (or some way ) , So that i can work with the same dataset and predict the future values by using Neural Network .</p><p>Your coperation will be higly praised . Thank You all in advance ( Please ignore my bad english)</p>pradeep kumar/matlabcentral/answers/contributors/5306014-pradeep-kumartag:de.mathworks.com,2005:Question/1668832014-12-17T06:17:08Z2014-12-18T18:20:08ZDisplay GUIDE GUIs in random order?<p>I have 14 GUIDE GUI's and I want them to appear in a random order, one after another.</p><p>i.e. GUIDE GUI #1 opens, press push button and then the next GUIDE GUI pops up (e.g. GUIDE GUI #2) and GUIDE GUI #1 closes. The next GUIDE GUI that comes is random (one of the 13 that remain)</p><p>How may I about doing that?</p><p>Any relevant input would be greatly appreciated.</p>Muaaman/matlabcentral/answers/contributors/5823965-muaamantag:de.mathworks.com,2005:Question/1671182014-12-18T17:55:31Z2014-12-18T18:12:05ZHow to access a variable in workspace with a string<p>I'm trying to make a simple menu system. I have all the variables I need in the workspace, and I have the name of the variable I want to access stored as a string, how do I open the workspace variable using that string?</p>Chaz/matlabcentral/answers/contributors/5999436-chaztag:de.mathworks.com,2005:Question/1670102014-12-18T00:13:48Z2014-12-18T18:10:36ZDefinite integral in (embedded) Matlab function, with passing additional parameters to the integrand <p>Hi,</p><p>I have a simulation file to model the dynamic behaviour of system, at each time step , I need to evaluate a time-independent integral. To do so I use (embedded) Matlab function but I got many errors. Any help would be appreciated.</p><p>inside my (embedded) Matlab function is:</p><p>%%________________ method one</p><p>function forces=my_embeded_func(positions)</p><p>y1=position(1);</p><p>y2=position(2);</p><p>forces=integral(@(theta),y1+y2*theta,0,2*pi)</p><p>end</p><p>%_______________</p><p>Notes:
1-my integrand is actually very complicated but I put something simple here.</p><p>2-I have been told to use "quadgk" instead of "inregra;", but it did not worked</p><p>3- I also tried the following method but it did not helped!</p><p>%%________________ method two</p><p>function forces=my_embeded_func(positions)</p><pre> coder.extrinsic('myFunc')</pre><pre> y1=position(1);</pre><pre> y2=position(2);</pre><pre> forces=myFunc(y1,y2)
end</pre><p>% where</p><p>function a=myFunc(y1,y2)</p><pre> a=quadgk(@(theta),y1+y2*theta,0,2*pi)</pre><p>end</p><p>%_______________</p><p>Thanks,</p><p>Ehsan</p>Ehsan Asadi/matlabcentral/answers/contributors/2631987-ehsan-asaditag:de.mathworks.com,2005:Question/1671132014-12-18T17:01:04Z2014-12-18T18:04:43Zgetframe difference in 2014b.... bug?<p>The following code run in 2014a and 2014b produces remarkably different results. I think it's a bug.</p><pre class="language-matlab">figure('Position',[100 100 200 500],'Color','y');
I = imread('rice.png');
imagesc(I)
axis image
colormap(gray)
gf = getframe(gca);
figure, imshow(gf.cdata)
</pre><p>In 2014a it successfully captures ONLY the current axes:</p><img src = "/matlabcentral/answers/uploaded_files/22746/getframe2014a.png"><p>In 2014b it grabs beyond the axes limits to the extent of the figure:</p><img src = "/matlabcentral/answers/uploaded_files/22747/getframe2014b.png"><ul><li>The figure "Color" parameter makes no difference - I just used yellow for clarity.</li><li>The <b>axis image</b> line does the damage. Without it both 2014a <i>and</i> 2014b capture only the axes extents (as they should).</li></ul><p>Can anyone suggest a workaround that produces identical results in both 2014a and 2014b? I have code that runs on both systems and is expected to produce similar figures using getframe. I understand that there can be pixel border effects when using getframe, these minor differences are fine, but the results shown are major differences that I want to avoid.</p><p>And if someone can confirm that they get similar results I'll submit a bugfix request.</p><p>Thanks,
Sven.</p>Sven/matlabcentral/answers/contributors/1672378-sventag:de.mathworks.com,2005:Question/1587702014-10-15T18:22:12Z2014-12-18T17:53:53ZIs it actually possible to use datetick? <p>I have a cell array of timestamps with the format:</p><pre class="language-matlab">'2014-10-06 09:27:34'
</pre><p>I converted this to a datetime type using:</p><pre class="language-matlab">t = datetime(Date, 'InputFormat', 'yyyy-MM-dd HH:mm:ss');
</pre><p>Then, I made this into a DateNumber, so I could use it as the x-axis for a plot:</p><pre class="language-matlab">DateNumber = datenum(t);
plot(DateNumber, myData)
</pre><p>I tried to convert the x-asix to something readable using datetick. I only care about the hours, minutes and seconds , so I entered:</p><pre class="language-matlab">datetick('x', 'HH:mm:ss')
</pre><p>However, all my ticks say 00:10:00 no matter how I zoom in on the axis. Also, if I change the axis limits using the plot tool before I run datetick from the command line, it reverts to the old axis limits.</p><p>I tried plotting a small subset of my data (80 points) that was taken between 4:52:56 and 6:25:46. My plot only gets five ticks, 04:10:00, 05:10:00, 05:10:00, 06:10:00 and 06:10:00. How are these 'repeat' ticks possible?</p><p>If I look at the contents of DateNumber using datestr:</p><pre class="language-matlab">datestr(DateNumber(2550))
</pre><pre class="language-matlab">ans =
</pre><pre class="language-matlab">08-Oct-2014 04:52:56
</pre><p>I get back the values I expect, so it looks like the DateNumber variable is filled properly. The problems seem to be with datetick.</p>Victoria/matlabcentral/answers/contributors/4485121-victoriatag:de.mathworks.com,2005:Question/1671172014-12-18T17:50:45Z2014-12-18T17:50:45Zhow to write a new cost function for MPC?<p>i want to use MPC for my plant. my cost function is especial.
can i change the cost function of MPC?how?
please answer me,</p>fariba/matlabcentral/answers/contributors/5525529-faribatag:de.mathworks.com,2005:Question/1671152014-12-18T17:15:01Z2014-12-18T17:44:47Zhow to pass a variable into imadjust?<p>Hi,</p><p>I wish to pass the contrast limits in the imadjust using a variable.</p><p>I tried in this way but it didn't work. I'll get a value for lower contrast limit using a input dialog box.</p><pre> lowerContrast=str2num(answer{1});</pre><pre> lowContLimit=sprintf('%d',lowerContrast);</pre><pre> imgadj=imadjust(imgreen,[lowContLimit,1],[]);</pre><p>but i am getting an error as</p><p>Function imadjust expected its second input argument, [LOW_IN;
HIGH_IN]
to be a two-element vector.</p><p>Can anyone help me.</p>Manoj Kumar/matlabcentral/answers/contributors/4953597-manoj-kumartag:de.mathworks.com,2005:Question/1670572014-12-18T08:42:46Z2014-12-18T17:41:01ZUpdate plot data when HOLD ON is active<p>I need to update 1 set of data on a GUI figure as a slider variable changes. I have HOLD ON active as I have other data on the plot I need to keep. I get a new curve when i move the slider, but I want the old curves associated with the previous slider positions to be cleared from the plot. Any help would be greatly appreciated.</p>Matthew Saul/matlabcentral/answers/contributors/5995298-matthew-saultag:de.mathworks.com,2005:Question/1671162014-12-18T17:39:03Z2014-12-18T17:39:03Zblack box function export in MATLAB<p>Is it possible to export a function in MATLAB in such a way that it is possible to execute that function, but do not read its source code?</p><p>I would like to distribute a MATLAB application to the students while keeping a functionality as a black-box. So they can execute a program and see the results. Then, they should re-implement that black-box functionality, without being able to read the solution from the distributed application.</p>Davide/matlabcentral/answers/contributors/4710846-davidetag:de.mathworks.com,2005:Question/1671092014-12-18T16:41:44Z2014-12-18T17:36:20ZHow I can change the video in Motion-Based Multiple Object Tracking example?<p>Hi .I am new in matlab and I want to study the Motion-Based Multiple object Tracking example.I tried to change the video but I have this error "The filename specified was not found in the MATLAB path".Please help me in this .Thanks..</p>amani Aljefri/matlabcentral/answers/contributors/5947272-amani-aljefritag:de.mathworks.com,2005:Question/1602112014-10-27T08:00:20Z2014-12-18T17:10:02ZHost-Target Communication: Cant boot target PC. Simulink Real-Time<p>Hi,</p><p>for an experiment in the university we used XPCTarget 5.4 and Matlab 2012a on windows XP to run a model in a real time computer. Now we updated to Windows 8 and to Matlab 2014a and I´m currently trying to create a boot disk for the target computer. Until now I´ve tried to boot the target computer with a CD, with a USB stick and with a diskette without sucess. The target computer starts loading the real time software and then stops and shows the following message:</p><p>On Time RTOS-32 5.0 Disk Loader (c) 1996, 2009 On Time
Loading program.....................................................................
......................................................................
......................................................................
......................................................................
......................................................................
...............................................................
RTTarget-32 5.0 16-Bit Boot Code (c) 1996, 2006 On Time Informatike GmbH</p><img src = "/matlabcentral/answers/uploaded_files/20030/IMAG0120.jpg"><p>Does someone know what the problem is? I haven´t found any information about this message in the internet. Any help would be really appreciated.</p><p>The configuration on the Simulink Real Time explorer to create a boot disk is like showed on the following image. It doesn´t show any error messages during the creation of the boot media (In the image is configured to create a CD, but I´ve also tried with a diskette and a usb) and it says that it was created succesfully.</p><img src = "/matlabcentral/answers/uploaded_files/20031/heine_conf.png">David/matlabcentral/answers/contributors/5805280-davidtag:de.mathworks.com,2005:Question/1671082014-12-18T16:37:42Z2014-12-18T17:09:20Zhow can i remove object bigger than x pixel <p>i know that bwareaopen remove small elements , but how can i remove object bigger than x pixels???</p><p><a href = "http://www.image-share.com/ijpg-2791-262.html">http://www.image-share.com/ijpg-2791-262.html</a></p><p>i want to just the letter to stay so how can i remove that 2 big objects???</p>Lukasz Jarod/matlabcentral/answers/contributors/5985971-lukasz-jarodtag:de.mathworks.com,2005:Question/1671122014-12-18T16:59:11Z2014-12-18T17:29:19Zconverting a function into a code ?<p>hello everyone
i'm struggling with this question
(sin(x), exp(x^2-y^2), 0)
how to i convert the whole thing into a matlab code ?
and how can i use matlab to find the "curl" of a function ?</p>maryam 94/matlabcentral/answers/contributors/4888532-maryam-94tag:de.mathworks.com,2005:Question/1670872014-12-18T12:49:39Z2014-12-18T16:59:27ZHow to apply operations (add/subtract) to only a certain row range between 2 matrics?<p>Lets say I have 2 matrics with n rows:</p><pre class="language-matlab">A = 1 2 6
3 5 6
2 4 6
.
.
.
3 3 1
</pre><pre class="language-matlab">B = 1 5 6
2 5 7
8 5 3
.
.
.
3 4 5
</pre><p>And I want to add Row 2 to Row (n) of both matrics up (skipping row 1)</p><p>I know for this the coding should be:</p><p>.</p><pre class="language-matlab">C = A(2:n,:) + B(2:n,:)
.
</pre><p>So the result be like:</p><pre class="language-matlab">C = - - -
5 10 13
10 9 9
.
.
.
6 7 6
</pre><p>and after that another matric is to add Row 1 and, Row 3 to Row (n), of both matrics (skipping row 2)</p><pre class="language-matlab">D = 2 7 12
- - -
10 9 9
.
.
.
6 7 6
.
</pre><p>then Row 1 and, Row 2 and, Row 4 to Row (n), of both matrics (skipping row 3)
.</p><pre class="language-matlab">E = 2 7 12
5 10 13
- - -
.
.
.
6 7 6
</pre><p>all the way to Row 1 to Row (n-1) of both matrics. (skipping last row)</p>ZONG YI Ng/matlabcentral/answers/contributors/5751907-zong-yi-ngtag:de.mathworks.com,2005:Question/1671112014-12-18T16:55:33Z2014-12-18T16:55:33Zshoulder coordination translation to world coordination <p>how to do the shoulder coordination translation to world coordination for robot manipulator in simMechanics?</p>geogia guni/matlabcentral/answers/contributors/4740596-geogia-gunitag:de.mathworks.com,2005:Question/1671102014-12-18T16:55:10Z2014-12-18T16:55:10ZHow to Find rectangular region using hough line in Matlab?<p>I use this code but did't finded plate region. How do I find the plate ?</p><p>This code gives only horizontal lines but I must find vertical and horizontal lines.</p><pre> I = imread('image.jpg');
I= rgb2gray(I);
%I(:,1:2)=0;
%I(1,:)=0;
%I(end,:)=0;
%I(:,end)=0;
BW = edge(I,'canny');
%imshow(BW)
[H,T,R] = hough(BW);
%{
imshow(H,[],'XData',T,'YData',R,...
'InitialMagnification','fit');
xlabel('\theta'), ylabel('\rho');
axis on, axis normal, hold on;
%}
P = houghpeaks(H, 20,'NHoodSize',[1 1],'threshold',ceil(0.1*max(H(:))));
lines = houghlines(BW, T, R, P, 'FillGap', 40, 'MinLength', 1);
%P = houghpeaks(H,7,'NHoodSize','threshold',ceil(0.4*max(H(:))));
%lines = houghlines(BW,T,R,P,'FillGap',40,'MinLength',90);
x = T(P(:,2)); y = R(P(:,1));
%plot(x,y,'s','color','blue');
% Find lines and plot them
figure;
imagesc(I);hold on;colormap gray;
axis image;
max_len = 0;
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
% Plot beginnings and ends of lines
%plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red')
plot(xy(1,1),xy(2,2),'x','LineWidth',2,'Color','blue');
%plot(xy(2,2),xy(2,2),'x','LineWidth',2,'Color','green');
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green'); %connect red and blue point
% Determine the endpoints of the longest line segment
len = norm(lines(k).point1 - lines(k).point2);
if ( len > max_len)
max_len = len;
xy_long = xy;
end
end</pre><p>This part draws connect red and blue point. How to connect blue blue point and red red point ? If I can it , I find plate area.</p><pre> % Plot beginnings and ends of lines
%plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red')
plot(xy(1,1),xy(2,2),'x','LineWidth',2,'Color','blue');
%plot(xy(2,2),xy(2,2),'x','LineWidth',2,'Color','green');
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green'); %connect red and blue point</pre><p>then , Probably this part change.</p><pre> lines = houghlines(BW, T, R, P, 'FillGap', 40, 'MinLength', 90); </pre><p>input :</p><img src = "/matlabcentral/answers/uploaded_files/22750/input.jpg"><p>output :</p><img src = "/matlabcentral/answers/uploaded_files/22749/output.JPG">Adrian/matlabcentral/answers/contributors/5948506-adriantag:de.mathworks.com,2005:Question/1670652014-12-18T10:09:24Z2014-12-18T16:40:01ZHow to generate a regression fit of a 2D surface from 4D data<p>Hi All,
First time posting so please forgive etiquette errors.</p><p>I have been using polyfitn to generate a regression fit of 3D noisy data onto a 2D surface.
I have also been using polyfitn to generate a regression fit of 4D noisy data onto a 3D surface.</p><p>However I now want to fit 4D noisy data onto a 2D surface. Unfortunately I cannot find reference to any matlab functions which will support this. As far as I can see I will need a parametric surface (<http://en.wikipedia.org/wiki/Parametric_surface>) but have been unable to form a method that will make the matlab functions fit to it.</p><p>A third or fourth order polynomial is expected to give a reasonable fit to the function as it is not very far from a plane, but it is actually an exponential function <b>a*e^( m*x+c)</b>.
We have around a million data points in the range roughly 0.5 - 1.0 on each axis.</p><p>Can anyone make some suggestions about how I can go about generating this fit?</p><p>(Edit: Further Clarification of data available)</p>William/matlabcentral/answers/contributors/4034124-williamtag:de.mathworks.com,2005:Question/1670692014-12-18T10:15:23Z2014-12-18T16:23:02ZParameterize Image Name In Function<p>Hello Colleagues,
I have Function with parameter image name, inside the function i want to write image after some of editing, but i want to take part from image name and add another part as imwrite image name
for example</p><pre class="language-matlab">function editing (ImageName)
w=imread(ImageName);
w=double(w);
w=w+0.02;
w=uint8(w);
imwrite(w,'w_ImageName.jpg','jpg');
end
</pre><p>I want the new image name to be w letter with image name.</p>muath shaikh/matlabcentral/answers/contributors/4741474-muath-shaikhtag:de.mathworks.com,2005:Question/1058602013-11-11T05:00:00Z2014-12-18T16:16:46ZHow do I install or update the License Manager for a network license?<p>I would like to install or update the License Manager for a network license on my license server. I would like to know how to perform this installation.</p>MathWorks Support Team/matlabcentral/answers/contributors/4622813-mathworks-support-teamtag:de.mathworks.com,2005:Question/1011032011-06-16T19:54:00Z2014-12-18T16:12:31ZHow do I download the MATLAB .ISO image?<p>I am interested in DVD images for MATLAB installation. Is there a way that I can download an ISO image?</p>MathWorks Support Team/matlabcentral/answers/contributors/4622813-mathworks-support-teamtag:de.mathworks.com,2005:Question/1671032014-12-18T15:02:55Z2014-12-18T16:09:57ZHow can I solve this ?<p>I have this code to generate the J1 matrix</p><pre class="language-matlab">syms r phi
</pre><pre class="language-matlab">r=sym('r','real');
</pre><pre class="language-matlab">phi=sym('phi','real');
</pre><pre class="language-matlab">N=zeros(3,3+2*nlayers);
</pre><pre class="language-matlab">Naux1=[1,0,0,r*sin(phi),-r*cos(phi);0,1,0,0,0;0,0,1,0,0];
</pre><pre class="language-matlab">N(:,1:5)=Naux1
</pre><pre class="language-matlab">J1=int(r*N'*N,r,R1,R2);
</pre><pre class="language-matlab">J1=int(J1,phi,0,2*pi)
</pre><p>But I received this error message:</p><pre class="language-matlab">The following error occurred converting from sym to double:
Error using ==> sym.double at 29
DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.
</pre><p>What should I modify ?</p>Ba2508/matlabcentral/answers/contributors/5999002-ba2508tag:de.mathworks.com,2005:Question/1650172014-12-02T01:38:53Z2014-12-18T15:59:56ZgpuArray memory requirement estimation<p>Dear All,</p><p>I was running a script employing parallel processing and a gpuArray structure. I get the following error on two PCs with different Nvidia cards</p><p>Error using gpuArray.eye
An unexpected error occurred during CUDA execution. The CUDA error was:
out of memory</p><p>Ressetting the gpuDevice(1) on either box does not help.</p><p>Questions:
1. How can I estimate what memory is required by any gpuArray (I know the available GPU memory with gpuDevice() command, but not that requested)</p><p>2. Besides a true relative memory deficit (task vs available), what other causes could lead to this error?</p><p>For example, I work on a PC 64 bit windows 8.1, matlab R2014a</p><p>GPU:
gpuDevice()</p><p>ans =</p><pre class="language-matlab">CUDADevice with properties:
</pre><pre> Name: 'GeForce GTX 645'
Index: 1
ComputeCapability: '3.0'
SupportsDouble: 1
DriverVersion: 5.5000
ToolkitVersion: 5.5000
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 1.0737e+09
FreeMemory: 207220736
MultiprocessorCount: 3
ClockRateKHz: 823500
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceSelected: 1</pre><p>Thank you,</p><p>Octavian</p>Octavian/matlabcentral/answers/contributors/3314170-octaviantag:de.mathworks.com,2005:Question/1228932014-03-24T16:21:38Z2014-12-18T15:59:08Zhow do i get clusters from a pointcloud?<p>i have a point cloud from an object i measured with a 3d microscope.</p><p>i am dealing with 3 vectors: x,y containing coordinate points in regular intervals and z containing the z-value (if there is no "Point, resp. no surface" the value is "NaN")</p><p>i would like to store and count "clusters" in 2D. By cluster i mean fibres.
See pictures from scatter plot below:</p><p>how can i handle this? is it easier to convert the data to an image file and use matlabs morphological tools? i would be glad to avoid doing this..
thanks in advance</p><img src = "/matlabcentral/answers/uploaded_files/10324/clusters.png">Stephan/matlabcentral/answers/contributors/3387162-stephantag:de.mathworks.com,2005:Question/1671042014-12-18T15:14:07Z2014-12-18T15:53:38ZI want to run MATLAB on a SPARC Solaris T5-2. <p>I am just getting into the MATLAB world. What version of Solaris do I need to run to run MatLAB? Thank you.</p>Matt/matlabcentral/answers/contributors/5999046-matttag:de.mathworks.com,2005:Question/1671062014-12-18T15:52:12Z2014-12-18T15:52:12ZPlotting Selective Outage Probability vs Distance graph<p>Hi everyone. I am new to this forum and it is my first time posting a thread here. I need to plot a graph which plots the selective outage probability of a terrestrial point-to-point communication system against a range of distances. For example, from 0 - 1232m (1.232km)</p><p>I had got hold of some resources such as from this link: <a href = "http://www.ofcom.org.uk/static/archive/ra/topics/fixedlnk/members/rsspwg/docs2002/08-05-02/pr0202-024-0.doc">http://www.ofcom.org.uk/static/archive/ra/topics/fixedlnk/members/rsspwg/docs2002/08-05-02/pr0202-024-0.doc</a></p><p>For Appendix 5B on page 24, it shows an example of the application for the outage probability. I had tried using a for loop to loop the equations with an interval of 1m at 900MHz frequency. This is because i thought that the required parameters changes along with the increment in distance. The steps to completing the selective probability is as follows.</p><p>Step 1: Calculation of the mean time delay from:</p><p>tau_m = 0.7*(d/50)^1.3</p><p>Where d is the path length (km)</p><p>Step 2: Calculation of the multipath activity parameter eta from:</p><p>eta = 1 - exp^(0.2*po^0.75)</p><p>Where po = pw/100 is the multipath occurrence factor corresponding to the percentage of time pw (%) of exceeding A = 0 dB in the average worst month. The pw formula is given as follows:</p><p>pw = K*d^3*(1+|ep|^-1.2)*10^(0.033*f-0.001*hl)</p><p>Where f is the frequency (GHz),
hl is the altitude of the lowest antenna ,
K is the geoclimatic factor (in UK a typical value is 8.241 10-5) ,
ep = (height of the transmitter – height of the receiver) / d : is the inclination angle in mrad
(1 mrad = approx. 0.03 degrees)</p><p>Step 3: Calculation of the selective outage probability from:</p><p>Ps = 2.15*eta[(wm*10^-3*10^(-nm) + wnm*10^-3*10^(-ndm))]</p><p>Where:
wm: signature width (GHz)
nm: signature depth (dB)
wnm: non-minimum phase width
ndm: non-minimum phase depth
tau: the reference delay (ns) used to obtained the signature</p><p>However, my graph plot end up looking like this.</p><img src = "/matlabcentral/answers/uploaded_files/22743/Outage_v1.gif"><p>This graph is certainly wrong according to the Appendix 5B example.</p><p>Could it be that i am supposed to use expectant operator function to work out the formulas or if there are some missing parameters which i may have overlooked?</p><p>Please do give me as much guidance as possible. I really do appreciate any help from anyone or whom is an expert in this. Thank you so much everyone.</p>Suan Foo/matlabcentral/answers/contributors/3087195-suan-footag:de.mathworks.com,2005:Question/1670972014-12-18T14:00:05Z2014-12-18T15:47:00ZProblem with contraining a general delaunay Triangulation<p>I got a set of points, shaped like a figure 8 filled in (See figure 1)</p><img src = "/matlabcentral/answers/uploaded_files/22736/scatter.jpg"><p>Now when I use the function "Alphashape" as in:</p><pre class="language-matlab">%% Generate sphere -- DELETE THIS IF DATA IS AVAILABLE
N=1; %counter
Point=1; %secondary counter
Q=15; %amount of data points the sphere has
r=20; %radius of the sphere
[X,Y,Z] = sphere(Q); %generating coordinates
%count=Q+1;
count=length(X);
M=zeros(((Q+1)^2),3); %assigning a matrix M to speed up code.
for N=1:(count)
M(((N-1)*count)+1:N*count,1)=r*X(N,:); %%rewriting to one matrix
M(((N-1)*count)+1:N*count,2)=r*Y(N,:);
M(((N-1)*count)+1:N*count,3)=r*Z(N,:);
N=N+1;
end
%% end of code of sphere
count=sqrt(length(M));
count2=length(M);
seen=nan(count2,3); %filling a "seen" matrix in which the points are located that have been "seen".
</pre><pre class="language-matlab">%% generating a double projected sphere
for TT=1:count^2
Point=M(TT,:)';
if Point(3)>(-sqrt(r^2-((2.7*r)/3.5)^2))
twohalves(TT,:)=Point(1:3)';
end
if Point(3)<(-sqrt(r^2-((2.7*r)/3.5)^2))
twohalves(TT,:)=Point(1:3)'-[0 (0.8*((2*r)-(r-((2.5*r)/3.5)))) 0]; %the 0.8 is an overlap factor, smaller means more overlap
end
end
P=twohalves(:,1:2);
[~, I, ~] = unique(P,'first','rows');
I = sort(I);
P = P(I,:);
twohalves=P;
%% start triangulation, and start of the problems
dt = alphaShape(twohalves(:,1:2),(r/4));
[tri,GG] = alphaTriangulation(dt)
[t,QQ] = tsearchn(P,tri,[0,0]) %searches for point 0,0 -> gives t, row number in tri and QQ = baricentric coordinates
</pre><pre class="language-matlab">%trimesh(tri,GG(:,1),GG(:,2))
triplot(tri,GG(:,1),GG(:,2),'r')
</pre><p>This code gives this plot.</p><img src = "/matlabcentral/answers/uploaded_files/22738/alphashapetriangulated.jpg"><p>Which is nice.</p><p>However, the code for "selecting" the nearest triangle in the set does not seem to work.</p><p>the code for looking for the point is</p><pre class="language-matlab">[t,QQ] = tsearchn(P,tri,[0,0])
hold on
triplot(tri(t,:),GG(:,1),GG(:,2))
</pre><img src = "/matlabcentral/answers/uploaded_files/22739/wrongpointslpha.jpg"><p>Which clearly is not the triangle closest to the point 0,0.</p><p>I allready "solved" <b>that</b> problem using delaunay conversion, and using the pointLocation function.</p><pre> dt=delaunayTriangulation(twohalves(:,1:2))
triplot(dt)
random_x=0
random_y=0
triangleId=pointLocation(dt, random_x,random_y) %select the triangle ID of the triangle closest to the point generated by the random generator
tri = dt(triangleId, [1:end 1]);
patch(P(tri,1), P(tri,2), 'r', 'LineWidth',1, 'FaceColor','r')</pre><p>but plotting the delaunay transformation of the pointset dt gives THIS:</p><img src = "/matlabcentral/answers/uploaded_files/22735/wrongdeluanayplot.jpg"><p>Which is not the correct shape ( I want the triangulation to follow the "vacuum sealed" constraints that the alpha shape does so very nicely)</p><p>So what I'm asking for is:</p><ul><li>A solution to find the right points in the alphashape</li></ul><p>or:</p><ul><li>A way to constrain the delaunay so that the shape is "vacuum sealed"</li></ul><p>Thanks in advance, and sorry for the long read!</p>luc/matlabcentral/answers/contributors/4279774-luctag:de.mathworks.com,2005:Question/1671052014-12-18T15:45:41Z2014-12-18T15:45:41ZData acquisition support for NI PCI 6562<p>Dear Sirs
Do you have any plans to support NI PCI-6562 ?</p>Mats Anderssson/matlabcentral/answers/contributors/5575915-mats-andersssontag:de.mathworks.com,2005:Question/1670722014-12-18T10:18:20Z2014-12-18T15:16:45ZHot can I redirect mex output to stderr? <p>I have compiled my script with deploytool.</p><p>I try to capture the output of fprintf(1,...) in a mymex.exe > output.txt.
This does not work, output comes onto the console.</p>Christoph/matlabcentral/answers/contributors/2692559-christophtag:de.mathworks.com,2005:Question/1670822014-12-18T12:30:56Z2014-12-18T15:15:04ZHow to convert matlab file into a voltage signal in simulink <p>Hi, I have a code where it is a sin wave for first 0.6 seconds and 0 for the next 0.4 seconds. Which i have created using if statements etc. so its a matlab file. Now thing is i want to generate this as a voltage supply, how do i import this matlab file into the voltage supply. I know there is a 'from workspace' and 'from file' function. but i have no idea how to use this. thanks.</p>Saurabh Sakpal/matlabcentral/answers/contributors/4142730-saurabh-sakpaltag:de.mathworks.com,2005:Question/1671002014-12-18T14:50:40Z2014-12-18T15:11:21ZTaking every nth element from each column in a matrix<p>Hello,</p><p>I have a 10x5 matrix:</p><pre class="language-matlab">A = randi(10,10,5);
</pre><pre class="language-matlab">A =
</pre><pre> 2 8 7 1 4
9 8 8 1 7
4 8 2 8 8
3 3 2 10 6
8 7 6 7 8
1 6 5 2 3
1 4 9 8 8
7 1 8 2 10
7 8 8 2 9
6 4 1 7 1</pre><p>I would like to make another matrix (B) that contains every 2nd element from each column of A, such that</p><pre class="language-matlab">B =
</pre><pre> 9 8 8 1 7
3 3 2 10 6
1 6 5 2 3
7 1 8 2 10
6 4 1 7 1</pre><p>Thank you.</p>Henry Hallock/matlabcentral/answers/contributors/5990925-henry-hallocktag:de.mathworks.com,2005:Question/1669442014-12-17T12:56:07Z2014-12-18T15:01:08ZHow to set up Compiler Configuration?<p>Hi,
I have set Compiler configuration using mex - setup. But one of my automation script invokes MATLAB instance as if run by the "system". And the invoke fails because, the compiler configuration is not set for the "system". DO any of you have any idea how to do it?</p><p>P.S. Just to provide some clarity,
running MATLAB by "system", does not open the MATLAB GUI. And hence I am not able to run the mex -setup.</p><p>Your time is hugely appreciated,</p>Chocolate Warrior/matlabcentral/answers/contributors/4396345-chocolate-warriortag:de.mathworks.com,2005:Question/1671022014-12-18T14:54:19Z2014-12-18T14:54:19ZThree phase synchronous machine<p>how to design a synchronous machine (generator) using matlab?? we asked to design in abc model.</p>izzat sukeri/matlabcentral/answers/contributors/5998998-izzat-sukeritag:de.mathworks.com,2005:Question/1671012014-12-18T14:53:00Z2014-12-18T14:53:00ZHow to solve convection diffussion equation<p>Hello,</p><p>I want to solve the following equation in Matlab, but I have no idea how to do it:</p><p>u*dC/dz = Dh*d^2C/dx^2+Dv*d^2C/dz^2</p><p>Kind regards,
Teun</p>Teun/matlabcentral/answers/contributors/1973206-teun