http://www.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2015-07-01T05:21:18Ztag:www.mathworks.com,2005:Question/2259502015-06-30T17:43:51Z2015-07-01T05:21:18ZHow to copy content of of 7*14 matrix file(*.mat) to a table on Microsoft Word??<p>How to copy content of of 7*14 matrix file(*.mat) to a table on Microsoft Word??</p>rose rosehttp://www.mathworks.com/matlabcentral/profile/authors/3612391-rose-rosetag:www.mathworks.com,2005:Question/424132012-06-29T19:15:59Z2015-07-01T05:09:03ZMATLAB Answers Wish-list #2 (and bug reports)<p>This topic is for features you would like to see for the MATLAB Answers facility itself, and also for bug reports about the MATLAB Answers facility.</p><p>This topic is the follow on to the earlier <a href = "http://www.mathworks.com/matlabcentral/answers/994">Wish-list for MATLAB Answer sections.</a> That topic grew large enough to become unwieldy; and Mathworks has made enough changes to make a number of the past points no longer of relevance.</p><p>I suggest one wish (or bug report) per answer, so that people can vote their wishes.</p>Walter Robersonhttp://www.mathworks.com/matlabcentral/profile/authors/434782-walter-robersontag:www.mathworks.com,2005:Question/13252011-02-14T16:13:47Z2015-07-01T05:08:08ZWhat is missing from MATLAB?<p>I'm curious, is there something you wish to do with MATLAB but you can't, maybe something you can do with other similar software but can't with MATLAB?</p>Paulo Silvahttp://www.mathworks.com/matlabcentral/profile/authors/2021205-paulo-silvatag:www.mathworks.com,2005:Question/14272011-02-16T09:53:30Z2015-07-01T05:07:14ZWhat frustrates you about MATLAB?<p>I love MATLAB. It is so quick and easy to write software to do what you want. It has excellent debugging and profiling tools. It is cross platform, making code easy to share (assuming the other people have forked out for the not-so-cheap license). It has interfaces to other software.</p>
<p>However, there are some things about it that irk me. I'd like to hear from other people what things annoy them about MATLAB.</p>Oliver Woodfordhttp://www.mathworks.com/matlabcentral/profile/authors/1073021-oliver-woodfordtag:www.mathworks.com,2005:Question/2259952015-07-01T05:01:31Z2015-07-01T05:01:31Zimplementing inverter controller profile model taking buck converter as reference<p><a href = "http://in.mathworks.com/help/supportpkg/texasinstrumentsc2000/examples/dc-dc-buck-converter.html">Buck converter</a></p><p>i want to design DC-AC inverter.
In buck converter controller profiler model i will do following modifications.
1)Inverter AC output voltage will act as fdb.
2)since i am using full bridge inverter, i will require 4 ePWM pulses instead of 2 in that example model.
If i will do above modifications, will it work fine for inverter. Any help will be appreciated.</p>ashish ahirhttp://www.mathworks.com/matlabcentral/profile/authors/6064237-ashish-ahirtag:www.mathworks.com,2005:Question/2259942015-07-01T04:58:08Z2015-07-01T04:59:46Z"Restart" elements of a matrix<p>Hi!
I have a couple of matrix (all squares and sorted by rows) like this:</p><p>A=[1 2 3; 4 5 6; 7 8 9]</p><p>And I need to, from any specific element, restart the sequence. For example:</p><p>A=[1 2 3; 1 2 3; 4 5 6]</p><p>Any ideas?
Thanks a lot!</p>Facundo Beerhttp://www.mathworks.com/matlabcentral/profile/authors/6615009-facundo-beertag:www.mathworks.com,2005:Question/2259932015-07-01T04:45:14Z2015-07-01T04:45:14ZHow to write a value on a specific portion which is constant on a graph?<p>Hi ,</p><p>I want to write something on parts of a graph which are constant.</p><p>For example,</p><pre class="language-matlab">a=[1 2 2 2 2 2 2 2 2 2 3 5 5 5 5 5 5 5 ]
b=[1:1:length(a)]
plot(b,a)
</pre><p>My graph is attached.</p><p>For the portion on the xaxis, from 2 to 10, i want to write "level=2" on top of the constant line and from 12 to 18, i want to write "level 5" on top of the constant line.</p><p>Anyway of doing it in MATLAB?</p>yashvinhttp://www.mathworks.com/matlabcentral/profile/authors/4047317-yashvintag:www.mathworks.com,2005:Question/1752052015-02-05T03:41:12Z2015-07-01T04:43:13ZHow to map certain temperature range into 0-255 gray scale image (thermogram) ?? Please advice...<p>I need to analyse the temperature variation on the facial area which i already got the thermal images in gray scale uint8 format. The range of the temperature map on the images are between 28-36 degree celcius.
So my question is how do i relate the intensity of the temperature with 0-255?? I'm using Flir camera for this research. Please anyone help me...thanks a lot...</p><p>here is a sample of the image :</p><img src = "/matlabcentral/answers/uploaded_files/24924/092.png">Blaxe 05http://www.mathworks.com/matlabcentral/profile/authors/4869211-blaxe-05tag:www.mathworks.com,2005:Question/2249652015-06-23T13:44:24Z2015-07-01T04:40:21ZSources of error to calculate X, Y Z distances using stereo when disparity map seems alright.<p>This issue is wrt Image scene reconstruction using Stereo Calibration.
I have a good (compared to my earlier pointClouds) reconstructed image of my object (wheel). I am able to filter out noise and preserve only the points corresponding to the object under consideration.</p><img src = "/matlabcentral/answers/uploaded_files/33003/Screenshot%20of%20Reconstructed%20wheel.png"><p>I am calculating the X, Y and Z distances to this object by taking a mean of all points under consideration (i.e., mean of the point cloud in each of the 3 dimensions X, Y and Z to get X_mean Y_mean and Z_mean respectively. Euclidean distance is also calculated using these mean values )</p><p>For this particular case, the euclidean distance when measured with an inch tape was around 68cm. My result shows 62cm. There is a difference of 60 mm which is not tolerable.</p><p>What could the error sources be? The reconstructed image seems very good. During stereo calibration, mean re-projection error is lesser than 0.3 pixels (using a 10MP camera)</p><p>I have <a href = "https://www.dropbox.com/sh/uq97ao7noivf7w7/AACkJO5v-oMF1IwaNE7ci7sCa?dl=0">attached the pointCloud and other relevant files to plot</a> it for your further reference.</p>Meghanahttp://www.mathworks.com/matlabcentral/profile/authors/5488039-meghanatag:www.mathworks.com,2005:Question/2259922015-07-01T04:39:26Z2015-07-01T04:39:26ZSelect specific coefficient from symbolic polynomial<p>Given a symbolic polynomial in several variables I would like to pick the coefficient for a given monomial.</p><p>Ex: P(x,y,z)= 6*x^2*y + z*x- 5*x +7*x*y*z
Let say I would like to find the coefficient of x*z in P(x,y,z) that is 1.</p><p>Or I could ask the coefficient of y in P(x,y,z) in this case I would obtain 0.</p><p>Or coefficient of x in P(x,y,z) I would obtain -5.</p><p>Is there a way to solve this?</p>Farid Salazar Wonghttp://www.mathworks.com/matlabcentral/profile/authors/3996652-farid-salazar-wongtag:www.mathworks.com,2005:Question/2255782015-06-27T15:36:27Z2015-07-01T04:38:29ZAligning 3D stereo co-ordinate system along local vertical and local horizontal<p>Using stereo vision, I am able to reconstruct the object under inspection.</p><p>After calibration, I know the co-ordinate system which stereo setup uses is mentioned <a href = "http://in.mathworks.com/help/vision/gs/coordinate-systems.html">here</a> (it is wrt optical centre of Camera 1).</p><p>I have noticed that the same co-ordinate system may not be followed in real world 3D. For example, the local vertical (of a place, which can be found using a spirit level) need not align with the vertical axis (y-axis) of my stereo setup's co-ordinate system.</p><p>Suppose I move my object only along the local vertical, without any change in its x position (i.e. local horizontal of that place), according to the stereo co-ordinate system used by the cameras, my object would have moved along y axis (obviously), and also along the x-axis of camera (which is not right, since according to the real world, my object hasn't been moved along local horizontal at all!).</p><p>How can I tackle this issue? I am aligning the stereo setup according to the local vertical and local horizontal (using a spirit level), as well as my object. Still, when I move it along local vertical only, there is a few mm change in x-coordinate reading as well. Any inputs regarding this would be appreciated.</p>Meghanahttp://www.mathworks.com/matlabcentral/profile/authors/5488039-meghanatag:www.mathworks.com,2005:Question/2259912015-07-01T04:35:52Z2015-07-01T04:35:52Zhow to convert binary string to m ary numbers?<p>For example the given binary string is 100001000111001 and m=7. ie., to map the binary string to numbers from 0 to 6. Here the string is to be splited as 100 001 000 11 100 1 and the 7 ary sequence will be 4 1 0 3 4 1. The reverse program is also needed to convert 4 1 0 3 4 1 to 100001000111001.</p>Jeenahttp://www.mathworks.com/matlabcentral/profile/authors/5763693-jeenatag:www.mathworks.com,2005:Question/771422013-05-27T21:35:26Z2015-07-01T04:19:26ZFuture value prediction with neural network method and right input and target format data<p>Hello,
Could anyone explain, how to do following with matlab neural network NARX method
I have six variables numbers (they depends on each other) for each day and for 10 days.</p><ul><li></li><li>day1 x1, x2, x3, x4, x5, x6</li><li>day2 x1, x2, x3, x4 ,x5,x6</li><li>..........................</li><li>day10 x1, x2, x3, x4, x5, x6</li></ul><p>and I want to predict these six variables for 11th day using matlab neural network
So prediction:</p><ul><li>day11 y1,y2,y3,y4,y5, y6</li></ul><p>I am starting to work with neural networks, so I know that I have to use</p><p>ntstool and to select NARX method, but there I stopped with right format of data at matlab work space variables table. Could anyone please help how to enter input and target data in right format for this case at matlab work space variables table that could allow to simulate this.</p>Povi Nikehttp://www.mathworks.com/matlabcentral/profile/authors/1622952-povi-niketag:www.mathworks.com,2005:Question/1609142014-11-01T17:15:39Z2015-07-01T04:17:48Zdata transfer from GUI to M file <p>Hello everyone,</p><p>i wrote a program for my senior project using M file , but the user have to input 18 values in the boxes that i have entered in the Gui as follows:</p><p>How can i link the first value for example, in the M file i called this value P_h
how can i let the entered value from the user for the first box that it is the value of P_h when i run the program
this is an example of what i mean</p><img src = "/matlabcentral/answers/uploaded_files/20351/Untitled.png">abdulla ishaqhttp://www.mathworks.com/matlabcentral/profile/authors/5848136-abdulla-ishaqtag:www.mathworks.com,2005:Question/2258522015-06-30T06:43:59Z2015-07-01T04:17:38ZConvert Image to Video Processing, the next step.<p>Greetings fellow programmers! As stated in the title, I am in quite a pickle. I have done my image processing completely but I have yet to learn any techniques for running a recorded video processing.</p><p>Here are my desired pre-processing of image,</p><pre class="language-matlab">if true
Reader = VideoReader('StuckTear.MOV');
get(Reader);
DarkPixel = 125;
extraction = rgb2gray(read(Reader,80));
Threshold = imextendedmax(extraction, DarkPixel);
redux = bwareaopen (Threshold, 35000);
%imshow(extraction)
%figure, imshow(redux);
for x = 1 : nframes
singleFrame = read(Reader, x);
I = rgb2gray(singleFrame);
fill = imfill (redux, 'holes');
se = strel('disk', 10);
dilate = imdilate(fill, se);
G = fspecial('gaussian', [15 15], 2);
Ig = imfilter(dilate, G, 'circular');
end
</pre><p>end</p><p>I have done processing my image and I wanted the recorded video to be processed the same way but by frame by frame, is there anyone out there that could provide me some example or perhaps some guidance regarding this? Thank you very much.</p><p>I am also planning to make centroid and bounding box on the "ON" pixels as well but that can wait.</p>Akira Chanhttp://www.mathworks.com/matlabcentral/profile/authors/5105272-akira-chantag:www.mathworks.com,2005:Question/2259902015-07-01T04:15:39Z2015-07-01T04:15:39Zhow Matlab iqr works<p>According to this wiki link (https://en.wikipedia.org/wiki/Interquartile_range), the iqr for this set of data</p><pre> 102 104 105 107 108 109 110 112 115 116 118</pre><p>should be 115 - 105 = 10.
I wonder why Matlab give me value of 8.75.</p><img src = "/matlabcentral/answers/uploaded_files/33508/iqr_wiki.PNG">Dajianghttp://www.mathworks.com/matlabcentral/profile/authors/6561063-dajiangtag:www.mathworks.com,2005:Question/2259892015-07-01T03:55:43Z2015-07-01T03:55:43ZIs it possible to know array number from plot?<p>I am trying to rule out some unnecessary arrays from my structure array.
My structure array 'data' is as follows.</p><pre class="language-matlab">1x85 struct array with fields:
lat
lng
altitude
GS
TAR
TAS
heading
</pre><p>The following two plots illustrate what I am trying to say.</p><img src = "/matlabcentral/answers/uploaded_files/33506/untitled.jpg"><img src = "/matlabcentral/answers/uploaded_files/33507/untitled2.jpg"><p>As you can see, the arrays that are in red, are the unnecessary arrays that I am trying to get rid of. If I know the array number (or index? I am not sure about the terminology) I can get rid of them manually.
In order words, data(x) that are in red are what I am trying to get rid of. Is it possible to find the number x from the plot alone? (Such features exist?)</p><p>Thanks.</p>coffeehttp://www.mathworks.com/matlabcentral/profile/authors/4500990-coffeetag:www.mathworks.com,2005:Question/2259852015-07-01T01:19:29Z2015-07-01T03:13:28ZTo plot contour as per the value in array (square matrix)<p>I wannt to plot contour plot for a array containing the values of number(no of droplet) as n_drop and mass array value. The x and y co-ordinate are in a different array- x1, y1 and z1
The difficulty is the contour not being clear and I tried scatter also. But the need is to present the data as visual format in color distinction or by contour.
Please guide me if any idea regarding the contour or coloring scheme</p><pre class="language-matlab">subplot(2,2,1)
scatter(y1,z1,floor(radius1*10^7))
xlabel('x'); ylabel('z');hold on
grid on;
title(sprintf('2D plane z-y view for drop'));
</pre><pre class="language-matlab">% Part II ploting the values in required contour level
m2=max(n_drop);
m1=2 %mean(n_drop)*0.2;
subplot(2,2,2)
contourlevel = m1:((m2-m1)/10):m2; % Required contour for 10 scale to 100
Cont = contour(y1,z1,n_drop,contourlevel); %Array rotation to match needed display
% set(Cont,'LineStyle','none');
xlabel('x'); ylabel('z');
% clabel(Cont);
grid on;
title('Contour lines for number of drop');
</pre><pre class="language-matlab">subplot(2,2,3)
m2=max(mass);
m1=mean(diag(mass))*0.2;
contourlevel2 = m1:((m2-m1)/10):m2; % Required contour for 10 scale to 100
contour(y1,z1,mass,contourlevel2); %Array rotation to match needed display
xlabel('x'); ylabel('z');
% clabel(Cont);
grid on;
title(sprintf('Stream lines for mass in spray area'));
</pre><pre class="language-matlab">subplot(2,2,4)
% smoothening by convolutiuon
F = [.05 .1 .05; .1 .4 .1; .05 .1 .05];
n_drop = conv2(n_drop,F,'same');
title(sprintf('Stream lines for no of drop -smooth in spray area'));
Cont = contour(y1,z1,n_drop,contourlevel); %Array rotation to match needed display
title(sprintf('Stream lines for number of droplet in spray area'));
</pre><p><<</p><img src = "/matlabcentral/answers/uploaded_files/33499/contour%20line%20for%20partile%20number%20and%20mass.PNG"><p>>></p><img src = "/matlabcentral/answers/uploaded_files/33500/scatter%20for%20the%20no%20of%20particle.PNG">sanjeethttp://www.mathworks.com/matlabcentral/profile/authors/5567136-sanjeettag:www.mathworks.com,2005:Question/2259812015-06-30T23:44:55Z2015-07-01T03:08:11ZHow to read in a large mixed csv data file<p>Hi,</p><p>Please excuse me if this is difficult to understand - I am new to Matlab and coding in general.</p><p>I’m trying to read in a large mixed data file that I can then manipulate. The file is 53 columns by about 8.8 million observations (rows) and is in csv format separated by commas. It is arranged as follows:</p><p>Numbers only: Columns 1-28, 30-34, 36, 50, 53</p><p>All other columns are text only (e.g. Johannesburg) or mixed text and numbers (e.g. E44). Some include spaces (e.g.Cape Town) and others symbols like slashes (e.g. A00-A09).</p><p>It is not clear to me if the first row is headings or not.</p><p>I’m assuming I need to use either readtable or textscan, but so far have been unsuccessful with the code.</p><p>Thanks for the help!
Noah</p>Noahhttp://www.mathworks.com/matlabcentral/profile/authors/4137934-noahtag:www.mathworks.com,2005:Question/2259882015-07-01T02:34:07Z2015-07-01T02:56:44ZHow to load all .mat files in a folder and save accordingly?<p>I am trying to run some code on bunch of .mat files with different names which are not in sequence (only the starting parts are same). They are all located in a folder called 'data', and I want to run my program on each one of them and save accordingly to a different folder called 'results'.
The name of my .mat files are in the following format.</p><pre class="language-matlab">SSR_******, where there are random numbers in the asterisks.
</pre><p>Can anyone help me with this?
Thanks.</p>coffeehttp://www.mathworks.com/matlabcentral/profile/authors/4500990-coffeetag:www.mathworks.com,2005:Question/2259872015-07-01T02:16:53Z2015-07-01T02:56:08ZAn strange error in summoning data though existence of the data...please help<p>Hi,</p><p>I have attached an excel file which data is used in the mfile attached.It is a very short code. But I have faced a problem that neither me nor my colleagues could solve it. The purpose of the code is to find data from the first two columns of the excel file and put the relating third column data into another matrix.
The problem is that in the "for" loop, for n<=90 everything is ok and the purpose is achieved but for n>90 it is unable to summon the value of teta1(1,n) and the "Subscripted assignment dimension mismatch" error appears.
To explain more, for n=91, teta1(1,n)=90.01
If you evaluate:
index(m,n)=find(PatternData(:,1)==phi1(1,m) & PatternData(:,2)==teta1(1,n));
in the command line, you will see error: "Subscripted assignment dimension mismatch."
but if you replace teta1(1,n) with 90.01 and evaluat it in command line,i.e.:
index(m,n)=find(PatternData(:,1)==phi1(1,m) & PatternData(:,2)==90.01);
it works and no error appears...
It is very strange for me...I cannot find any anser for that...Any help is previously appreciated.</p>Elihttp://www.mathworks.com/matlabcentral/profile/authors/3471473-elitag:www.mathworks.com,2005:Question/1539962014-09-08T07:27:00Z2015-07-01T02:48:29ZImage Mosaicing in MAtlab using SIFT and RANSAC<p>The following is a piece of code that forms a Mosaic of two images after computing the Homography Matrix H using RANSAC pror to which SIFT was used to compute the descriptors:</p><pre> % --------------------------------------------------------------------
% Mosaic
% --------------------------------------------------------------------</pre><pre> box2 = [1 size(im2,2) size(im2,2) 1 ;
1 1 size(im2,1) size(im2,1) ;
1 1 1 1 ] ;
box2_ = inv(H) * box2 ;
box2_(1,:) = box2_(1,:) ./ box2_(3,:) ;
box2_(2,:) = box2_(2,:) ./ box2_(3,:) ;
ur = min([1 box2_(1,:)]):max([size(im1,2) box2_(1,:)]) ;
vr = min([1 box2_(2,:)]):max([size(im1,1) box2_(2,:)]) ;</pre><pre> [u,v] = meshgrid(ur,vr) ;
im1_ = vl_imwbackward(im2double(im1),u,v) ;</pre><pre> z_ = H(3,1) * u + H(3,2) * v + H(3,3) ;
u_ = (H(1,1) * u + H(1,2) * v + H(1,3)) ./ z_ ;
v_ = (H(2,1) * u + H(2,2) * v + H(2,3)) ./ z_ ;
im2_ = vl_imwbackward(im2double(im2),u_,v_) ;</pre><pre> mass = ~isnan(im1_) + ~isnan(im2_) ;
im1_(isnan(im1_)) = 0 ;
im2_(isnan(im2_)) = 0 ;
mosaic = (im1_ + im2_) ./ mass ;</pre><pre> figure(2) ; clf ;
imagesc(mosaic) ; axis image off ;
title('Mosaic') ;</pre><pre> if nargout == 0, clear mosaic ; end</pre><pre> end</pre><p>I understand box2 is an area that's created based on the size of our second image in which the images will be stitcked. Why then, are we performing an Inverse Homography multiplication on it?</p><p>Could someone please explain the steps that follow as I'm not familiar with image mosaicing in Matlab.</p>Seanhttp://www.mathworks.com/matlabcentral/profile/authors/5609334-seantag:www.mathworks.com,2005:Question/2259012015-06-30T11:52:24Z2015-07-01T02:32:05ZCross validation in recurrent neural network<p>There doesn't seem to be any facility to use cross-validation in recurrent neural networks in the NN Toolbox.</p><p>The following script is taken directly from the documentation on the 'layrecnet' function;</p><p>[X,T] = simpleseries_dataset;
net = layrecnet(1:2,10);
[Xs,Xi,Ai,Ts] = preparets(net,X,T);
net = train(net,Xs,Ts,Xi,Ai);
view(net)
Y = net(Xs,Xi,Ai);
perf = perform(net,Y,Ts)</p><p>Running this script starts the window, but no validation checks are made during training, and the process is stopped either by reaching the maximum epochs or mu value.</p><p>I've tried dividerand and divideind, but I cannot get validation checks to occur in any simulation.</p><p>Any suggestions?</p><p>Also, the example given in the documentation on Design Layer-Recurrent Neural Networks has the same problem. Is it a trait of recurrent neural networks that I was unaware of that validation checks cannot occur, am I doing something wrong, or is this a bug in the program?</p><p>Cheers,</p><p>Alex</p>Alex Chttp://www.mathworks.com/matlabcentral/profile/authors/6413881-alex-ctag:www.mathworks.com,2005:Question/926342013-01-03T19:04:00Z2015-07-01T02:22:15ZWhy do I get a connection error when installing or activating MATLAB or another MathWorks product?<p>I get an error that I cannot connect to MathWorks when running the MATLAB installer or the activation client. However, I can access the website. Why can't the activation client connect to the MathWorks?</p>MathWorks Support Teamhttp://www.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:www.mathworks.com,2005:Question/2258402015-06-30T01:35:00Z2015-07-01T02:18:29ZHovering mouse over a variable no longer shows present value in R2015a (student) upgrade?<p>I loved the ability to hover my mouse over a vaiable created in a script to show the present value in R2014a (student). Now, since updating to R2015a (student), the hover no longer works. At the moment, BOTH R2014a and R2015a are installed on the same PC. In R2014a, the hover still works. Is there any setting I could have missed?</p>Richardhttp://www.mathworks.com/matlabcentral/profile/authors/1704021-richardtag:www.mathworks.com,2005:Question/1663642014-12-11T23:12:48Z2015-07-01T02:17:43ZI cannot get to an stable neural network :/<p>i have written a code it is about training a neural network , no matter what i do its training performance is not stable , i know that there is always some differences between training performances in each run but in my case the results are so much different, some times my network experiences overfitting some times it experiences underfitting sometimes its training error is fair enough, it is getting really frustrating i don't know what to do!!!!i have changed my traing functions to see if i can get better performance, for each of them i had to change my network structure too but at the end , i again faced with the same problem</p><pre class="language-matlab">if true
net=feedforwardnet(100);
net.trainFcn='traingdm';
</pre><p>net.divideParam.trainRatio=1
net.divideParam.valRatio=0
net.divideParam.testRatio=0</p><p>net.trainparam.epochs=1000;
[net,tr]=train(net,xl,TL);
Y=net(xl);</p><pre class="language-matlab">end
there is a specific reason for putting net.divideParam.trainRatio=1
</pre>fereshtehhttp://www.mathworks.com/matlabcentral/profile/authors/5048150-fereshtehtag:www.mathworks.com,2005:Question/2253922015-06-25T23:58:19Z2015-07-01T02:17:38ZHow can I best segment yeast cells in this picture?<p>Hi,</p><p>I have tried some of the algorithms I found online without much success.I am wondering what is the best approach to segment cells automatically in this picture.</p><img src = "/matlabcentral/answers/uploaded_files/33185/sample.png"><p>Any help in terms of how to approach this problem will be greatly appreciated. Please help!</p>Tianyu Yanghttp://www.mathworks.com/matlabcentral/profile/authors/3511718-tianyu-yangtag:www.mathworks.com,2005:Question/2259862015-07-01T01:27:34Z2015-07-01T02:17:21Zhow can i give rand function as an input to the given difference equation?<pre class="language-matlab">n=10
x(n)=randn(n,1)
y(n)=2.5*x(n)+ x(n-1)
</pre><p>The x(n)should be given as input to the y(n) but when i tried doing that x(n) it is giving me the following error.</p><pre class="language-matlab">??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
</pre><pre class="language-matlab">Error in ==> Untitled at 5
x(n)=randn(n,1).
</pre><p>But without using x(n) i cannot give the input to the y(n).</p><p>Kindly provide me a solution.</p>shttp://www.mathworks.com/matlabcentral/profile/authors/6140199-stag:www.mathworks.com,2005:Question/2258412015-06-30T02:18:29Z2015-07-01T01:41:57ZQuestion regarding loop with multiple string comparisons?<p>Hello. I am trying to extract several Aircraft data from a general data I have. I want the following 6 aircraft data from my general structure data. If it were for only 1 aircraft type, it works fine. However, for several aircraft, it doesn't.
I am using a method such that my field 'type' matches the aircraft types and extract those data. If I use & instead of |, it also doesn't work. ( I believe it suggests that both conditions must be satisfied if I use '&' which doesn't make sense since each array has only 1 type.)</p><pre class="language-matlab">idx_plane = false(length(data2),1);
</pre><pre class="language-matlab">for p = 1 : length(data2) % 1574
if strcmp(data2(p).type, 'A319') | strcmp(data2(p).type, 'A318') | strcmp(data2(p).type, 'B788') | strcmp(data2(p).type, 'A320') | strcmp(data2(p).type, 'A321') | strcmp(data2(p).type, 'A330')
idx_plane(p) = true;
end
end
data2 = data2(idx_plane);
</pre>coffeehttp://www.mathworks.com/matlabcentral/profile/authors/4500990-coffeetag:www.mathworks.com,2005:Question/2256822015-06-28T22:41:31Z2015-07-01T01:18:57ZHow to set Sigma value in CompactClassificationSVM in Matlab<p>Hi;</p><p>I'm new to Matlab and I would like to set the value of Sigma for the class CompactClassificationSVM</p><p>I couldn't find away to set it's value. I tried for example;</p><pre class="language-matlab">CompactSVMModel.Sigma
</pre><p>But I got the error message:</p><pre class="language-matlab">Error using subsref
No appropriate method, property, or field 'Sigma' for class 'ClassificationECOC'.
</pre><p>Any clue?</p>Diverhttp://www.mathworks.com/matlabcentral/profile/authors/6586113-divertag:www.mathworks.com,2005:Question/2256832015-06-28T22:46:36Z2015-07-01T01:15:04ZHow can I train SVM in Matlab, with more than 2 classes?<p>Hi;</p><p>I was trying to use fitcsvm to train and classify my data. However, I notice - correct me if I'm wrong - that <a href = "http://www.mathworks.com/help/stats/fitcsvm.html">fitcsvm</a> could only be used with 2 classes (groups).</p><p>My data have more than 2 classes. Is there away to do classify them in matlab?</p><p>I did some googling and I read that some recommend to use <a href = "http://www.mathworks.com/help/stats/fitcecoc.html">fitcecoc</a> , while others recommend to use out of the box code <a href = "http://www.mathworks.com/matlabcentral/fileexchange/39352-multi-class-svm">multisvm</a></p><p>Morover, other recommend to use <a href = "http://www.mathworks.com/help/stats/discriminant-analysis.html">discriminant analysis</a></p><p>Please, advise on best approach to go.</p><p>Thanking you.</p>Diverhttp://www.mathworks.com/matlabcentral/profile/authors/6586113-divertag:www.mathworks.com,2005:Question/2259842015-07-01T01:02:45Z2015-07-01T01:02:45Zhow can i solve matrix riccati differential equation?<p>to solve matrix Riccati differential i am using the piece of code from mathswork support, which is as follows</p><p>function dXdt = mRiccati(t, X, A, B, Q)</p><p>X = reshape(X, size(A)); %Convert from "n^2"-by-1 to "n"-by-"n"</p><p>dXdt = A.'*X + X*A - X*B*B.'*X + Q; %Determine derivative</p><p>dXdt = dXdt(:); %Convert from "n"-by-"n" to "n^2"-by-1</p><p>[T X] = ode45(@(t,X)mRiccati(t, X, A, B, Q), [0 10], X0)</p><p>this code works well with dimension of A = 2x2. but gives error in builtin RESHAPE function when i change dimension of A(i.e A = 3x3, B=3x1, Q=3x3)</p>mariam pervaizhttp://www.mathworks.com/matlabcentral/profile/authors/6661107-mariam-pervaiztag:www.mathworks.com,2005:Question/2259682015-06-30T20:32:34Z2015-07-01T00:37:11ZAssigning colors to different lines in one plot<p>Hello,</p><p>I am currently working on some code to create and format subplots. Would anybody be able to help with the following problem: a portion of my code is designed to create a subplot with 3 lines in the single plot (6:2:10). How can I go about assigning a color to each of these lines? Below is the section of my code attempting to run this command</p><p>figure(2),
Colors = ['r', 'g', 'b'];
c=1;
subplot(121), hold on, %this makes a subplot and plots every other column from 6-10
for i = [6:2:10]
plot(data(6:end,i), 'Color',[0.36 0.0 0.0]);
c=c+1;
end</p>fabricio saucedohttp://www.mathworks.com/matlabcentral/profile/authors/4840394-fabricio-saucedotag:www.mathworks.com,2005:Question/2258312015-06-29T23:15:27Z2015-07-01T00:35:15ZTrying to Save all my inputted data from my for loop. I need to save the the Values of A,B and C into one matrix.<pre class="language-matlab">Components = input('Enter Number of Liquid Components:' )
</pre><pre class="language-matlab">x = Components;
</pre><pre class="language-matlab">for r = 1:x
</pre><pre> A = input('Enter A:');
B = input('Enter B:');
C = input('Enter C:');</pre><pre class="language-matlab">end
</pre>Sayyid Ferouzhttp://www.mathworks.com/matlabcentral/profile/authors/6120661-sayyid-ferouztag:www.mathworks.com,2005:Question/1072312013-11-22T20:24:18Z2015-07-01T00:27:36ZWhy does the pulse shape generated by gaussdesign differ from that used in the comm.GMSKModulator object?<p>If I generate a pulse using gaussdesign as:</p><pre class="language-matlab">bt = 0.5; % 3-dB bandwidth-symbol time
L = 12; % samples per symbol
N = 4; % filter spans 4 symbols
h = gaussdesign(bt,N,L);
</pre><p>And also create a GMSK modulator as:</p><pre class="language-matlab">H = comm.GMSKModulator;
H.BandwidthTimeProduct = 0.5;
H.PulseLength = 4;
H.SamplesPerSymbol = 12;
</pre><p>The pulse used for pulse shaping in the GMSKModulator object is different from the gaussdesign</p><p>I see that they are generated in different ways (by looking at gaussdesign.m & cpmmodparams.m), but which one is correct? gaussdesign uses <i>Wireless Communications:Principles and Practice</i> 2nd Ed. by Rappaport as a reference and GMSKModulator uses <i>Digital Phase Modulation</i> by Anderson, Aulin, and Sundberg.</p><img src = "/matlabcentral/answers/uploaded_files/4905/gmsk.png">Ryan Johnsonhttp://www.mathworks.com/matlabcentral/profile/authors/1631531-ryan-johnsontag:www.mathworks.com,2005:Question/2259732015-06-30T21:23:26Z2015-07-01T00:27:12ZHow to embed MCR in Matlab Compiler using "mcc"?<p>I know that using the deploy tool you can select "Add MCR" then "Embed the MCR in the package". However, is there a way to do this using the command "mcc" instead of deploy tool.</p><p>Where I work QA likes us to create a sort of "make" file that has the mcc command string. So we can attach it in our configuration management software. So using mcc is preferred over deploy tool.</p><p>Thanks for any help!</p>Benhttp://www.mathworks.com/matlabcentral/profile/authors/6660879-bentag:www.mathworks.com,2005:Question/2259832015-07-01T00:12:11Z2015-07-01T00:14:31ZSimulink TCP communication - how can I get two Simulink models to talk over the network?<p>Here's the situation:</p><p>I have two Ettus Research B210 USRPs connected to two separate workstations, one running Windows and one running Linux. Both have MATLAB R2015a with Simulink and the Instrument Control toolbox connected.</p><p>I want to be able to have Computer #1 generate a random bitstream and send it over the network to Computer #2. Computer #2 then uses this bitstream to create a bandpass modulated digital signal and then transmits it over-the-air using its USRP. Computer #1 receives this signal on its USRP, and demodulates the data to recover the original bitstream. This bitstream is then time delayed to match the original bitstream using the "Align Signals" block and then the bit error rate is computed. This way I can test different modulation schemes and forward error correction over-the-air.</p><p>The trouble is "TCP/IP Send" and "TCP/IP Receive" blocks don't play well together as they both act as clients (ie: they error out if I try to launch them as they both try to connect to the other machine). Is there a way to have the "TCP/IP Receive" block as a listening server or vice-versa?</p><p>I tried UDP instead and it's far too unreliable on my network. As a workaround I could connect the machines with a null modem cable and do the communication over RS-232 but I'd like a solution that's more this century.</p>Peter Kazakoffhttp://www.mathworks.com/matlabcentral/profile/authors/6350843-peter-kazakofftag:www.mathworks.com,2005:Question/2253782015-06-25T21:55:25Z2015-07-01T00:11:31ZHow can I write a mathematical function in Matlab?<p>Can I build an equation which have different components?</p><p>variables written in cell array(1x3) such as 'X1' 'X2' 'X3'</p><p>exponents written in matrix (3x3 double) e.g [0 .5 -.5; .5 -.5 0; 1 0 .5]</p><p>Parameters written in matrix(3x1) e.g [.55;.25;.6893]</p><p>can I get equation like</p><p>F= .55*X2^.5*X3^-.5+ .25*X1^.5*X2^-.5+.6893*X1^1*X3^.5</p><p>Many thanks</p> Nasirhttp://www.mathworks.com/matlabcentral/profile/authors/6206347-nasirtag:www.mathworks.com,2005:Question/1657872014-12-07T16:45:31Z2015-07-01T00:03:25ZHow can I get the pre-2014b behavior of hold on?<p>I often make 2-d plots showing a comparison of cases with a parameter 'On" of 'Off'. So I'll have several curves for the first case and then another set, using dashed lines, for the second case.</p><pre class="language-matlab">%The code would be pre 2014b
plot(x,y_on)
hold on
plot(x,y_off,'--')
</pre><p>How can I get the same result in 2014b?</p>Iram Weinsteinhttp://www.mathworks.com/matlabcentral/profile/authors/1349457-iram-weinsteintag:www.mathworks.com,2005:Question/2259822015-06-30T23:51:30Z2015-06-30T23:51:30Zcoefficients as input to continuous time transfer function<p>I would like to create a continuous time SISO transfer function in Simulink whose coefficients are constant but given by the vector output of another subsystem. For example, I see that the Discrete FIR Filter block permits this kind of functionality by accepting coefficients from an input port. Is there a way that I can recreate this behavior for my situation? I am trying to avoid recreating the transfer function explicitly with integrators, gains, etc as I expect the order to be somewhat high.</p>Kelleyhttp://www.mathworks.com/matlabcentral/profile/authors/2956943-kelleytag:www.mathworks.com,2005:Question/2259782015-06-30T22:47:21Z2015-07-01T00:33:22Zedit txt file matlab<p>hey guys</p><p>I wrote a table in a .txt file. Now I rewrote my table and I want to append this new data to the same .txt file. The table's columns match.</p><p>Any idea how can I do that?</p>Adriele Rochahttp://www.mathworks.com/matlabcentral/profile/authors/6649788-adriele-rochatag:www.mathworks.com,2005:Question/2258232015-06-29T21:32:41Z2015-06-30T23:22:52Z"IntelliSense" using MATLAB commands.<p>New to MATLAB, but a veteran using MS EXCEL's VBA. In the command window, I noticed that MATLAB's commands are not hierarchically constructed under a common structure, but rather they all have to be memorized and typed individually, loosely, at each line of execution. It reminds me of working with MS EXCEL’s formulas.</p><p>As a novice MATLAB user with a learning curve ahead to climb, I would like to give my early testimony that I would have found more productive to work if such editor could mimic the behaviour of those VBA-enable applications where a user types the name of an object qualifier (let’s say, worksheet), put a period after that, and the an auto-completed dropdown list with all commands associated with that object is displayed for user selection. (Qualifiers would be optional.)</p><p>Doing so, I am certain I would not have to worry about memorizing each command, which at early stages using the tool can be overwhelming. The idea of discovering new and use commands as I go rather than trying to memorize each one before using them pleases me more, and I see benefits in trying to more straightforwardly structure MATLAB’s objects in the command window.</p><p>Any elaboration or thoughts on that would be appreciated.</p>Renato Costahttp://www.mathworks.com/matlabcentral/profile/authors/6653635-renato-costatag:www.mathworks.com,2005:Question/2259802015-06-30T22:58:48Z2015-06-30T23:18:11ZHow to plot 2 histograms on the same axis? <p>I need to plot two histograms using the same axis. Code is below:</p><pre class="language-matlab">X1 = GalList.dist;
Y1 = GalList.mass;
XY = [X1,Y1];
XY2=XY(~any(isnan(XY),2),:); % Remove NaN
XY2=XY2';
[Y,I]=sort(XY2(1,:)); % Sort by distance, I are indices
XY3 = XY2(:,I);
X2 = XY3(1,:);X2=X2';
Y2 = XY(2,:);Y2=Y2';
Y3 = cumsum(Y1); %same function as Y4
A = sort(X2);
B = sort(Y2,'descend'); %flips plot (for newgalaxy, need to use ascend for plot flip)
Y4 = cumsum(B); %total blue lum within 100 Mpc of total catalog
</pre><pre class="language-matlab">for s=1:length(X2)
if X2(s)<=20
p(s)=1;
else
p(s)=0;
end
q(s)=p(s).*X2(s);
w(s)=p(s).*Y1(s);
r(s)=p(s).*Y3(s);
</pre><pre class="language-matlab">end
</pre><pre class="language-matlab">w(w==0)=[];
w(find(isnan(w)))=[];
q(q==0)=[];
q(find(isnan(q)))=[];
r(r==0)=[];
r(find(isnan(r)))=[];
</pre><pre class="language-matlab">Q = cumsum(w);
</pre><pre class="language-matlab">L = 2.6678e+03;
</pre><pre class="language-matlab">figure(1);
</pre><pre class="language-matlab">D = cumsum(w/L);
D(D==0)=[];
D(find(isnan(D)))=[];
</pre><pre class="language-matlab">R = sum(D(:));
hist(D,50)
</pre><pre class="language-matlab">for s=1:length(X2)
if X2(s)<=20
p(s)=1;
else
p(s)=0;
end
o(s)=p(s).*X2(s);
v(s)=p(s).*Y1(s);
u(s)=p(s).*Y3(s);
</pre><pre class="language-matlab">o(o==0)=[];
o(find(isnan(o)))=[];
v(v==0)=[];
v(find(isnan(v)))=[];
u(u==0)=[];
u(find(isnan(u)))=[];
</pre><pre class="language-matlab">Q2 = cumsum(o);
</pre><pre class="language-matlab">U = 2.6678e+03;
</pre><pre class="language-matlab">figure(1);
</pre><pre class="language-matlab">D2 = cumsum(o/U);
D2(D2==0)=[];
D2(find(isnan(D2)))=[];
</pre><pre class="language-matlab">R2 = sum(D2(:));
hist(D2,50)
</pre><p>I was trying this but it doesn't work:</p><pre class="language-matlab">[n1, xout1] = hist(D,100);
bar(xout1,n1,'r'); grid; hold
[n2, xout2] = hist(D2,100);
bar(xout2,n2,'g');
</pre>jgillis16http://www.mathworks.com/matlabcentral/profile/authors/5879134-jgillis16tag:www.mathworks.com,2005:Question/2259672015-06-30T20:23:23Z2015-06-30T23:17:56ZOptimization problem - max independent given a function value<p>Hi I have the following:</p><pre class="language-matlab">syms irr2 m_S s
</pre><pre class="language-matlab">irr1=0.05;
M=0.7;
n=120;
</pre><pre class="language-matlab">f=(symsum(1/(1+irr1)^s,s,1,n)-symsum(1/(1+irr2)^s,s,1,n)*(1+M*m_S)/(1+irr2)^m_S);
</pre><p>f must be equal zero</p><p>m_S is a variable</p><p>I wanna know which is the max irr2 ... how can I do it?</p>Brunohttp://www.mathworks.com/matlabcentral/profile/authors/4113809-brunotag:www.mathworks.com,2005:Question/1645272014-11-27T14:23:34Z2015-06-30T23:16:14ZJava error when opening fig files<p>When I try to open a .fig I get this error:</p><pre class="language-matlab">Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: Could not initialize class javax.media.opengl.GLProfile
at javax.media.opengl.GLCapabilities.<init>(GLCapabilities.java:84)
at com.mathworks.hg.peer.JavaSceneServerPeer.getCaps(JavaSceneServerPeer.java:147)
at com.mathworks.hg.peer.JavaSceneServerPeer.doCreateCanvas(JavaSceneServerPeer.java:676)
at com.mathworks.hg.peer.JavaSceneServerPeer.access$200(JavaSceneServerPeer.java:50)
at com.mathworks.hg.peer.JavaSceneServerPeer$2.run(JavaSceneServerPeer.java:650)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
</pre><p>Running the line <b>opengl info</b> I get the same message. I've updated the graphic drivers but the problem persists. What could it be?</p><p>thanks!</p>Martinahttp://www.mathworks.com/matlabcentral/profile/authors/5424534-martinatag:www.mathworks.com,2005:Question/2259592015-06-30T18:43:22Z2015-06-30T23:10:23ZHow to get Matlab to unlock or release a directory?<p>I have scripts that create a temporary directory to store intermediate files created during processing. At the end of the scripts I want to clean this temporary directory out and remove the directory. I can remove the files that I create, but when I run the rmdir() command, it will usually fail with the message "MATLAB:RMDIR:SomeDirectoriesNotRemoved". If I go into the file system and do a "ls -al" command, I will see that there is a Matlab lock file or something in the directory. It will go away if I shut down Matlab. Unfortunately it's not easy to recreate, because I've tried creating a directory from the command line, adding, modifying and removing a few files, and then removing the directory and it always seems to work fine. Something about running my scripts as a whole is causing Matlab to lock the temporary directory, and I don't know a way to unlock it.</p>Scotthttp://www.mathworks.com/matlabcentral/profile/authors/688558-scotttag:www.mathworks.com,2005:Question/2175652015-05-19T13:01:07Z2015-06-30T23:01:50Zsave large image/figure<p>I have a large mxn (~300,000 x 75) element matrix that I would like to save as an image or pdf without any compression. I'm currently using imagesc() to display. I've used the print function to set my own resolution but I'm having difficulty achieving the desired result. The image is a large time series that I would like to save in such a way that I may zoom in over a region, and transmit the complete series to others without any losses. Is there a simple method to save large , essentially banner sized, images / figures?</p>George Valdeshttp://www.mathworks.com/matlabcentral/profile/authors/6513857-george-valdestag:www.mathworks.com,2005:Question/2259762015-06-30T22:21:30Z2015-06-30T23:31:19Zreturn a function without e.g. f(5)<p>I have never used Matlab before so it really is difficult for me as I now have a task in
math course that says to interpolate a function with Lagrange.</p><p>My problem has nothing to do with the interpolation itself, more a question if something is possible and if so, how.</p><p>E.g. I say</p><pre class="language-matlab">f = @(x) x^3;
and p = @(x) f(2)*x
</pre><p>Matlab display p exactly like above but i would want it to display it as</p><pre class="language-matlab">p = @(x) 8*x
</pre><p>as is wouldn't make much sense to have the result as a polynomial with f(...) as values.</p><p>so i hope someone can help me with that.</p>Marvin van Stegenhttp://www.mathworks.com/matlabcentral/profile/authors/6655431-marvin-van-stegentag:www.mathworks.com,2005:Question/2259792015-06-30T22:50:56Z2015-06-30T22:51:33ZHow do I create an interactive connected graph in MATLAB GUI<p>I want to create a connected graph in Matlab GUI. All the nodes of the graph are buttons which changes its color when clicked. Adding the buttons in GUI is easy but how do I add the lines between any 2 nodes depending on the adjaceny matrix?</p><p>Example of such a graph:</p><img src = "/matlabcentral/answers/uploaded_files/33494/Graph.png">Jigar Gadahttp://www.mathworks.com/matlabcentral/profile/authors/2293474-jigar-gadatag:www.mathworks.com,2005:Question/2259772015-06-30T22:33:42Z2015-06-30T22:33:42ZPWM manufacturer-set frequency change <p>Hi everyone,
How can I change the manufacturer-set PWM frequency of an Arduino Mega 2560 in simulink
Any help will be greatly appreciated</p>khelilhttp://www.mathworks.com/matlabcentral/profile/authors/1444891-khelil