http://de.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2016-02-14T09:51:03Ztag:de.mathworks.com,2005:Question/2680452016-02-14T06:39:18Z2016-02-14T09:51:03Zhow to convert image to rgb image to grayscale? <p>When using code mentioned in matlab examples, its working fine on 103X103 image but when applying same code on 512X512 image showing following error message.
??? Error using ==> rgb2gray>parse_inputs at 82
MAP must be a m x 3 array.</p><p>Error in ==> rgb2gray at 35
X = parse_inputs(varargin{:});</p>monica sabharwalhttp://de.mathworks.com/matlabcentral/profile/authors/6839191-monica-sabharwaltag:de.mathworks.com,2005:Question/2678942016-02-12T19:30:05Z2016-02-14T09:40:00Zreading a file in matlab<p>hello,</p><p>I have a file like below named file.txt</p><pre class="language-matlab">> head(myfile,1:4])
</pre><pre> AT1G01060 AT1G01170 AT1G01260 AT1G01380
AT1G01060 1.00000000 0.3885284 -0.14720327 -0.01865947
AT1G01170 0.38852841 1.0000000 -0.29069241 0.26992353
AT1G01260 -0.14720327 -0.2906924 1.00000000 0.30973373
AT1G01380 -0.01865947 0.2699235 0.30973373 1.00000000
AT1G01490 0.24681279 0.3955740 -0.07497821 0.23271890
AT1G01500 0.05720335 -0.1786700 -0.26813919 -0.60440141</pre><pre class="language-matlab">> dim(myfile)
</pre><pre class="language-matlab">[1] 2885 2885
</pre><p>please someone help me to read this file in matlab I was really exhausted</p><p>thank you</p>fereshteh izadihttp://de.mathworks.com/matlabcentral/profile/authors/7394708-fereshteh-izaditag:de.mathworks.com,2005:Question/2680422016-02-14T06:00:47Z2016-02-14T09:39:29ZHow do you use randperm on a vector?<p>I have a vector</p><pre class="language-matlab">A = repmat(1:6, [1 4])
</pre><p>and I need to use randperm to randomize it. How would I do that?</p>Lavy Lauhttp://de.mathworks.com/matlabcentral/profile/authors/6999983-lavy-lautag:de.mathworks.com,2005:Question/2680162016-02-13T19:56:18Z2016-02-14T09:39:15ZFind accuracy of 0.xx.. using Symsum<p>Hello!</p><p>I was given the following series (1 to inf):</p><pre class="language-matlab">((47^(2*n) *(-1)^n)/ Factorial(2*n),1,inf)
</pre><p>Which eventually gives you cos 47 in radians.</p><p>I'm trying to find a way to calculate the index number that gives me the cos 47 accuracy of 0.001 (or less), using <b>symsum</b>. (and not with a 'while' loop that checks every iteraion if cos47 minus current series gives me 0.001 or less).</p><p>Thank you very much!</p>Study ahttp://de.mathworks.com/matlabcentral/profile/authors/7661438-study-atag:de.mathworks.com,2005:Question/2680012016-02-13T17:30:42Z2016-02-14T09:33:00ZHow to solve linear equation in GUI with constraints?<p>Hi,</p><p>I have to solve a linear equation AX=B, the conditions are -
(1) All the sum of all elements of each row of X should be equal to 1.
i.e. if X is 4by5 matrix, then X(:,1)+...+X(:,5)==1.
(2) The last column of each each row should be >=0.
i.e. X(:,5)>=0.</p><p>It will be highly appreciable if someone could help me with brief documentation how to solve linear and nonlinear equations with constraints in GUI..</p>Brij Bhushan Singhhttp://de.mathworks.com/matlabcentral/profile/authors/6289251-brij-bhushan-singhtag:de.mathworks.com,2005:Question/2680492016-02-14T09:26:23Z2016-02-14T09:26:23ZHow can I specify (speed up) the rate of a ROS Subscriber in MATLAB?<p>I create a subscriber for the /camera/rgb/image_color topic to get camera input, but the subscriber only updates what seems like once a second. How can I speed this up? After hours of testing I'm positive it's not network latency or any sort of hardware issue but it's with the way MATLAB creates a subscriber using the rossubscriber function. Can I get around this somehow?</p>Sam Heaterhttp://de.mathworks.com/matlabcentral/profile/authors/7662797-sam-heatertag:de.mathworks.com,2005:Question/2680302016-02-14T00:00:21Z2016-02-14T09:00:28ZHow to extract largest square or rectangle patch from an irregular shaped patch in such a way that the square patch is completey inside the other patch? <p>How to extract largest square or rectangle patch from an irregular shaped patch in such a way that the square patch is completey inside the other patch?</p>Anika Cheerlahttp://de.mathworks.com/matlabcentral/profile/authors/6714350-anika-cheerlatag:de.mathworks.com,2005:Question/2679542016-02-13T08:29:46Z2016-02-14T08:36:55ZHow can I find coordinates of points that are placed on a line with specific distance from first point of the line?<p>I tried this:
solve(-(y1-y0)*x+(x1-x0)*y+(y1-y0)*x0-(x1-x0)*y0,sqrt((x0-x)^2+(y0-y)^2)-10);
But the result of solve is 2 points and I need just the point on my segment. As I need to use it in a loop I can't choose the one on the segment and delete another one.
I wonder is there another way different from solve to do this?</p>parihttp://de.mathworks.com/matlabcentral/profile/authors/7659703-paritag:de.mathworks.com,2005:Question/2679952016-02-13T16:25:27Z2016-02-14T08:30:14ZPass the content of a variable to a .bat file from matlab<p>Sorry, I have a new problem. I have this char variable: name='file.pdf';</p><p>when I do !test name</p><p>I see in the file test.bat "name", that is the container of the variabile but not the content of the variable.....I need to pass the content name.pdf to the file test.bat.</p><p>How can I resolve?? How cas I pass the string name.pdf to the .bat?</p>luigi luigihttp://de.mathworks.com/matlabcentral/profile/authors/1899624-luigi-luigitag:de.mathworks.com,2005:Question/2680482016-02-14T08:14:55Z2016-02-14T08:14:55ZApplying a Plot to cftool<p>Hey! Please help.</p><p>I am relatively new to Matlab and I would love some help. I have a random 5x5 binary code with zeroes and ones. With that I have plotted it using:</p><p>x=randi([0 1], 5);</p><p>index = find(1);</p><p>x(index) = [];</p><p>stairs([x,x(end)]);</p><p>print('tempplot','-dpng');</p><p>Which looks like the attached file. With this function/plot now I am trying to apply the Fourier Series Approximation using cftool (which I have). But every time I do it it says "Input must be two, three, or four variables or a curve fitting session file." I am trying to find the approximation of this function. Is there a way around it? Someone please help! I very much appreciate it in advance.</p>Ausamah Hobbihttp://de.mathworks.com/matlabcentral/profile/authors/5955956-ausamah-hobbitag:de.mathworks.com,2005:Question/2679282016-02-12T23:38:19Z2016-02-14T07:49:49Zfprintf into a stored variable<p>Instead of using fprintf I want to store all the i, xe, and f(xe) into a vector instead. That way I can call them later. Also I had another problem where I wanted to use another 'i' later on in the code. But it only allowed me to use 1. How can you use two different 'i's. So they don't get mixed up.</p><pre> f = @(x) x^2-6;</pre><pre> xl = 0;</pre><pre> xu = 10;</pre><pre> xe = (xu+xl)/(2);</pre><pre> acc = 0.00001;</pre><pre> while abs(f(xe))> acc
i = i + 1;</pre><pre> fprintf('%d)\t%f\tf(x)=%f\n',i,xe,f(xe));</pre><pre> if (f(xe)*f(xl)) < 0
xu = xe;
else
xl = xe;
end
xe = (xu+xl)/2;</pre><pre> end</pre>WhatIsMatlab-http://de.mathworks.com/matlabcentral/profile/authors/7623251-whatismatlabtag:de.mathworks.com,2005:Question/2680362016-02-14T03:23:44Z2016-02-14T07:44:17ZIf any one can remove the error from this code.when i run this code it is showing the following error <pre class="language-matlab">u_xt = @(x,t,a,b) exp(a*t+b*x); % Create a function handle
x=[0:0.1:1]; %NOTE: I chose the step-size here as 0.1
t=[0:0.1:1]; %NOTE: Since your boundary conditions for x and t are identical [0 1] the step size has to be same for both
a = 5; % (say)
b = 2; % (say)
result = u_xt(x,t,a,b);
plot(u_xt,x);
% If you want to plot both on the same figure
%hold on;
%plot(u_xt,t);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Error using plot
Conversion to double from function_handle is not possible.
.
Error in ROUGH (line 7)
plot(u_xt,x);
</pre>YOGESHWARI PATELhttp://de.mathworks.com/matlabcentral/profile/authors/7631465-yogeshwari-pateltag:de.mathworks.com,2005:Question/2680472016-02-14T07:37:45Z2016-02-14T08:00:34ZHow to have have a linear regression on multiple subplots?<p>Hi!</p><p>I've done a bit of searching, but to no avail. I've tried using polyfit on each and that doesn't do anything if I do 'polyfit(x, y, 1)' for each subplot. I just throw it in the code for each subplot right after the plot commmand. ie:</p><p>plot(Year, Solar, 'ks')</p><p>polyfit(Year, Solar, 1)</p><p>This probably isn't correct but our professor didn't explain this very clearly.</p><p>The only thing I have figured out how to do is after I run the program and everything plots like in the screenshot below, I can use the basic fitting tool to plot a linear regression. However, it only allows me to do it on one plot at a time. Sort of frustrated. Thank you for any help you may provide.</p><p>~ Collin</p><p><b>Plots</b></p><img src = "/matlabcentral/answers/uploaded_files/45314/Screen%20Shot%202016-02-14%20at%2012.24.33%20AM.png"><p><b>Code</b></p><p>% Defining the Google Search Criterion
Year=[2004:1:2015];
Solar=[19 19 24 26 31 36 37 41 37 31 31 30];
Nuclear=[26 23 22 18 18 17 16 39 14 14 14 13];
Wind=[75 71 70 79 83 100 77 72 47 46 33 35];</p><p>% Defining the First Plot
subplot(3,1,1);
plot(Year, Solar, 'ks');
xlabel('Year'); ylabel('Solar Panel Searches'); title('Google Search Results for Solar Panels')
hold on;</p><p>% Defining the Second Plot
subplot(3,1,2);
plot(Year, Nuclear, 'r*');
xlabel('Year'); ylabel('Nuclear Energy Searches'); title('Google Search Results for Nuclear Energy')
hold on;</p><p>% Defining the Third and Final Plot
subplot(3,1,3);
plot(Year, Wind, 'bx');
xlabel('Year'); ylabel('Wind Turbine Searches'); title('Google Search Results for Wind Turbines')
hold on;</p>Collin Kinderhttp://de.mathworks.com/matlabcentral/profile/authors/7525440-collin-kindertag:de.mathworks.com,2005:Question/2680442016-02-14T06:16:58Z2016-02-14T07:08:11ZHow can I integrate a multivariable function that includes Dirac delta?<p>I'm trying to integrate an expression that includes a Dirac delta function, but the "integral" function (as well as integral2 and integral3) isn't handling the Dirac delta correctly.</p><p>For example,</p><pre class="language-matlab">f = @(x) dirac(x);
q = integral(f,-100,100)
</pre><p>gives me an incorrect answer of 0, while</p><pre class="language-matlab">p = int(dirac(x),x,-100,100)
</pre><p>gives me a correct answer of 1.</p><p>Is this just a factor of the integral function using numerical integration? If so, any recommendations for how to integrate multivariable functions with a Dirac delta in MATLAB?</p>Rebeccahttp://de.mathworks.com/matlabcentral/profile/authors/5480259-rebeccatag:de.mathworks.com,2005:Question/2670002016-02-07T15:36:54Z2016-02-14T06:45:28ZDESIGNING AN ELMAN NET PROJECT<p>A MATLAB Central Contributor Question
Sent On:Feb 02/03/16 11:26 PM</p><p>Hi Greg,
I'm in a senior semester at university and our senior project is
about neural network by matlab and my mission is elman back propagation
neural network, but unfortunately, I don't know any thing about it.
can you help me please?</p><p>1. Start with the command line help and doc documentation</p><pre> lookfor elmannet
help elmannet
doc elmannet</pre><p>2. I am satisfied when</p><pre> a. the mean-square-error mse(target-output) is at least 100 times
smaller than the mean-target-variance mean(var(target',1))
b. the total number of weights net.numWeightElements is as small
as possible</pre><p>3. Run the help and doc examples</p><pre> a. Use defaults on 10 examples (Ntrials = 10, for i=1:Ntrials ...),
with different random initial weights </pre><pre> b. See if the number of hidden nodes can be reduced without
violating 2a</pre><pre> c. See if increasing the number of feedback delays makes a
significant difference</pre><p>3. For references search</p><pre> answers mathworks newsgroup </pre><pre> elman 22 26 51 </pre><pre> elman greg 11 11 16 </pre><p>4. Post an attempt on one or more of the other time-series example datasets
from</p><pre> help nndatasets
doc nndatasets </pre><pre> Hope this helps.</pre><pre> Greg</pre>Greg Heathhttp://de.mathworks.com/matlabcentral/profile/authors/2929937-greg-heathtag:de.mathworks.com,2005:Question/2678532016-02-12T15:57:46Z2016-02-14T06:37:55Zhow to create large dataset to train neural network for software fault prediction?<p>how do I create a dataset for predicting faults in a software.
I need to make use of ck metrics,but I am unable to give this as an input in matlab. so please help me in this issue.</p><p>Thank you.</p>Apeksha Haverihttp://de.mathworks.com/matlabcentral/profile/authors/7346829-apeksha-haveritag:de.mathworks.com,2005:Question/2673802016-02-09T19:12:04Z2016-02-14T06:32:42ZThe best Ann configuration<p>I have run Ann for prediction with hidden nodes from 2-17 about 50 times.
My question is which criteria I should rely on to select the best Ann?
Should I choose R squerd of Test or Mse of the Ann or validation performance?</p>Ritahttp://de.mathworks.com/matlabcentral/profile/authors/3883383-ritatag:de.mathworks.com,2005:Question/2680262016-02-13T22:38:19Z2016-02-14T06:17:51ZHow I can insert the MATLAB figure into a specific line of the document Word not at the beginning or end of the document?<p>I have a problem for which I have not find a solution, I have a word document containing text and tables.
I have to Copy or Import a figure from MATLAB into Word document.
i use the following Sub-function of by Andreas Karlsson to paste the figure but in the end of document :</p><pre class="language-matlab">function FigureIntoWord(actx_word_p)
% Capture current figure/model into clipboard:
open_system('model','loadonly');
print('-dmeta','-sModel');
% Find end of document and make it the insertion point:
</pre><pre> end_of_doc = get(actx_word_p.activedocument.content,'end');
set(actx_word_p.application.selection,'Start',end_of_doc);
set(actx_word_p.application.selection,'End',end_of_doc);
% Paste the contents of the Clipboard:
figure = actx_word_p.Selection;
invoke(figure,'Paste');
actx_word_p.Selection.TypeParagraph; %enter </pre><pre class="language-matlab">return
</pre><p>first question : Does anyone know how I can modify this code to insert the image into
a specific line of the document not at the beginning or end of the document?</p><p>second question : if I have to insert the figure after specific table, how can I do ?</p>ghanamhttp://de.mathworks.com/matlabcentral/profile/authors/3458418-ghanamtag:de.mathworks.com,2005:Question/2680432016-02-14T06:12:02Z2016-02-14T06:12:02ZFraming and windowing audio signal<p>Iam using the code
Y=waveread(' ');
w_length=128;
m=length(Y);
numFrames=floor(m/w_length);
frameData=zeros(numFrames,w_length);
for k=1:numFrames
startAtIdx=(k-1)*w_length+1;
if k~=numFrames
frameData(k,:)=Y(startAtIdx+w_length-1);
else
frameData(k,1:m-startAtIdx+1)=Y(startAtIdx:end);
end
end</p><p>Iam getting error in else part. The dimensions mismatch. So can any one help. I need to frame an audio signal and allocate memory for it.</p><p>Thanks in advance</p>gowthami komminenihttp://de.mathworks.com/matlabcentral/profile/authors/7425177-gowthami-komminenitag:de.mathworks.com,2005:Question/2680402016-02-14T05:54:36Z2016-02-14T06:02:04ZHow to eliminate or exclude complix numbers from an array solution? <p>Hello everyone,</p><p>Is there any way to eliminate the complex numbers (real and imaginary parts) from a array solution. Or can I exclude the complex elements so the solution will just include the real numbers. For example, in the next array I just want the real elements ( the first four elements. Thanks for any suggestion.</p><pre class="language-matlab">sol =
</pre><pre> 2.7081096834177947291918098879734
2.4539692532957056897462100829847
1.1392825187840759291489282043638
-4.0494620185638170836265057842329
0.88295725432536163128309307530013 - 0.1308999971886537594046901453934*i
0.1308999971886537594046901453934*i + 0.88295725432536163128309307530013
0.1528510148755374525528985048959*i - 2.0089069727922412635133142708447
- 0.1528510148755374525528985048959*i - 2.0089069727922412635133142708447 </pre>Abdulaziz Abutunishttp://de.mathworks.com/matlabcentral/profile/authors/5634873-abdulaziz-abutunistag:de.mathworks.com,2005:Question/2680392016-02-14T05:52:46Z2016-02-14T05:52:46ZHow can I create a table using ModelAdvisor.Table?<p>I found the help section for creating a table using ModelAdvisor.Table and followed the given example format exactly:</p><p><a href = "http://www.mathworks.com/help/slvnv/ref/modeladvisor.table.html#zmw57dd0e11031">http://www.mathworks.com/help/slvnv/ref/modeladvisor.table.html#zmw57dd0e11031</a></p><p>At the beginning of the example for the 5x5 table, it says to embed the code in a callback function. I have no idea what this means or how to do this. Since I don't know how to do this, the code runs but does not display the table I've created. I have included my code for reference, and would greatly appreciate any help. Thanks.</p><p>The actual data is saved in my workspace and is unavailable here.</p><pre> meanice1Kin = mean(ice1Kinsulated);
meanice1K1 = mean(ice1Keden);
meanice1K2 = mean(ice1Ksean);
meanice1T1 = mean(ice1Tkristi);
meanice1T2 = mean(ice1Tmichael);
IceTrial1 = [meanice1Kin, meanice1K1, meanice1K2, meanice1T1, meanice1T2];
meanice2Kin = mean(ice2Kinsulated);
meanice2K1 = mean(ice2Keden);
meanice2K2 = mean(ice2Ksean);
meanice2T1 = mean(ice2Tkristi);
meanice2T2 = mean(ice2Tmichael);
IceTrial2 = [meanice2Kin, meanice2K1, meanice2K2, meanice2T1, meanice2T2];
meanice3Kin = mean(ice3Kinsulated);
meanice3K1 = mean(ice3Keden);
meanice3K2 = mean(ice3Ksean);
meanice3T1 = mean(ice3Tkristi);
meanice3T2 = mean(ice3Tmichael);
IceTrial3 = [meanice3Kin, meanice3K1, meanice3K2, meanice3T1, meanice3T2];
meanboil1Kin = mean(boil1Kinsulated);
meanboil1K1 = mean(boil1Keden);
meanboil1K2 = mean(boil1Ksean);
meanboil1T1 = mean(boil1Tkristi);
meanboil1T2 = mean(boil1Tmichael);
BoilTrial1 = [meanboil1Kin, meanboil1K1, meanboil1K2, meanboil1T1, meanboil1T2];
meanboil2Kin = mean(boil2Kinsulated);
meanboil2K1 = mean(boil2Keden);
meanboil2K2 = mean(boil2Ksean);
meanboil2T1 = mean(boil2Tkristi);
meanboil2T2 = mean(boil2Tmichael);
meanboil3Kin = mean(boil3Kinsulated);
BoilTrial2 = [meanboil2Kin, meanboil2K1, meanboil2K2, meanboil2T1, meanboil2T2];
meanboil3K1 = mean(boil3Keden);
meanboil3K2 = mean(boil3Ksean);
meanboil3T1 = mean(boil3Tkristi);
meanboil3T2 = mean(boil3Tmichael);
BoilTrial3 = [meanboil3Kin, meanboil3K1, meanboil3K2, meanboil3T1, meanboil3T2];
MeanMatrix = [IceTrial1; IceTrial2; IceTrial3; BoilTrial1; BoilTrial2; BoilTrial3];</pre><pre> % Initialize a Table with 6 Rows and 5 Columns
Means = ModelAdvisor.Table(6,5);</pre><pre> % Setting Column Headings
Means.setColHeading(1, 'Thermistor');
Means.setColHeading(2, 'K-Type 1');
Means.setColHeading(3, 'K-Type 2');
Means.setColHeading(4, 'T-Type 1');
Means.setColHeading(5, 'T-Type 2');
Means.setRowHeading(1, 'Ice Trial 1');
Means.setRowHeading(2, 'Ice Trial 2');
Means.setRowHeading(3, 'Ice Trial 3');
Means.setRowHeading(4, 'Boil Trial 1');
Means.setRowHeading(5, 'Boil Trial 2');
Means.setRowHeading(6, 'Boil Trial 3');</pre><pre> %Setting Alignment
for n=1:5
Means.setColHeadingAlign(n, 'center');
Means.setRowHeadingAlign(n, 'center');
end</pre><pre> % set Table content
for rowIndex=1:6
for colIndex=1:5
Means.setEntry(rowIndex, colIndex, num2str(MeanMatrix(rowIndex, colIndex)));
% set alignment of entries
Means.setEntryAlign(rowIndex, colIndex, 'center');
end
end</pre>Kristihttp://de.mathworks.com/matlabcentral/profile/authors/3635120-kristitag:de.mathworks.com,2005:Question/2678432016-02-12T14:25:29Z2016-02-14T05:26:55ZThe use of IFFT and convolution<p>Can any kind soul please help or provide some kickstart?</p><p>1) I have a transfer function/frequency response, h(f).
Where h(f) is calculated by applying FFT to the csv data and then V2(f) is divided with V1(f).</p><p>I need to convert this frequency response to time domain [ifft(h(f)] to get the impulse response.</p><p>2) My lecturer also told me to apply discrete convolution.</p>Alycia http://de.mathworks.com/matlabcentral/profile/authors/7252134-alyciatag:de.mathworks.com,2005:Question/2680382016-02-14T05:13:51Z2016-02-14T05:13:51ZWhat is the procedure to get the output for 5 Bus system for Contingency Analysis using PSAT<p>What are the steps for contingency analysis load flow solution in PSAT and how to get the output from PSAT.</p>Santhosh Banakarhttp://de.mathworks.com/matlabcentral/profile/authors/7395811-santhosh-banakartag:de.mathworks.com,2005:Question/2675832016-02-11T02:11:56Z2016-02-14T05:00:37ZHow can I train multiple sequences in neural network using feedforwardnet?<p>Hello,</p><p>I have 5 pairs (input-output) of time series. I know the way to train multiple time series using a dynamic neural network ( <a href = "http://www.mathworks.com/help/nnet/ug/multiple-sequences-with-dynamic-neural-networks.html">http://www.mathworks.com/help/nnet/ug/multiple-sequences-with-dynamic-neural-networks.html</a> ), however I'd like to use a static neural network (feedforwardnet function) instead. How could I do that?</p><p>Thanks,</p><p>Ghazi</p>Ghazi Binarandihttp://de.mathworks.com/matlabcentral/profile/authors/7649981-ghazi-binaranditag:de.mathworks.com,2005:Question/2680372016-02-14T04:46:20Z2016-02-14T04:46:20Zwhat willbe best image density matching technique<p>i want to compare twoimages and compare densities between two ,so what algorithm will work best even if i miss to apply image registration
1.i have a image of a empty road(reference)
2.i have a image of same densed road with vehicles(real time)
3.i want to match these two images densities(want answer in %)
4.algorithm should work for day and night.</p>Adnan Saifyhttp://de.mathworks.com/matlabcentral/profile/authors/7614463-adnan-saifytag:de.mathworks.com,2005:Question/2680282016-02-13T23:13:45Z2016-02-14T04:40:08ZNARXNET with input delay<p>Hi,</p><p>I am solving a problem incorporating measurement delay in a sensor. I have a set of measured acceleration based on the sensor reading (in time series). However, the measurements that I obtained have some time delay from the 'true' value of it. I want to design a neural network that can 'predict' the true acceleration value using the measured value that I obtained from the sensor measurement.</p><p>I am using NARXNET to model the neural network of it. To accommodate the delay in the input, 'inputDelays' is adjusted according to the delay in the sensor measurement (and, technically, no delay is needed for the 'feedbackDelays'). Am I doing it correctly?</p><p>Thank you,</p><p>Ghazi</p>Ghazi Binarandihttp://de.mathworks.com/matlabcentral/profile/authors/7649981-ghazi-binaranditag:de.mathworks.com,2005:Question/2680122016-02-13T19:42:19Z2016-02-14T03:59:27Zlegend for plotyy causes axes problem<p>Hello!</p><p>Can anyone help me?</p><p>The legend in my plot generated by plotyy causes a displacement of one y-axis.</p><p>Does anyone knows a solution? Thanks</p><pre> x = 1:100;
y1= randn(1,length(x));
y2= randn(1,length(x));
y3= randn(1,length(x));
y4= randn(1,length(x));</pre><pre> % plot1
[hA,h1,h2] = plotyy(x,y1,x,y2);
hold on
% plot2
[hB,h3,h4] = plotyy(x,y3,x,y4);</pre><pre> hold off
legend([h1,h2,h3,h4],'a','b','c','d','location','northoutside','orientation','horizontal')
refresh</pre>Tom Georgihttp://de.mathworks.com/matlabcentral/profile/authors/4726399-tom-georgitag:de.mathworks.com,2005:Question/2680352016-02-14T02:39:14Z2016-02-14T03:06:25ZLicense Manager error -25<p>My MATLAB R2015b suddenly stopped working throwing following error... I am running a network license from my department, linux version.. I could not find any relevant documentation, any help would be appreciated.</p><p>License checkout failed.
License Manager Error -25
This version of MATLAB is newer than the version of the license.dat file and/or license manager on the server machine.</p>Praful Agrawalhttp://de.mathworks.com/matlabcentral/profile/authors/2857938-praful-agrawaltag:de.mathworks.com,2005:Question/2677332016-02-11T19:59:18Z2016-02-14T02:36:32ZError in nlinfit function<p>I want to execute a code to calculate Largest Lyapunov Exponent in time series. There is a "nlinfit" function in my m-file, but the result is this error:</p><pre> Error using nlinfit (line 239)
No usable observations after removing NaNs in Y and
in the result of evaluating MODELFUN at the initial
value BETA0.</pre><pre> Error in lyaprosen (line 377)
beta =
nlinfit(K(1:Tl),L(1:Tl),@nonlin1,[betar;randn(1,1)]);</pre><p>I searched this error, but there was not any results. Can anyone help me to solve this issue?</p><p>Thanks;
Peyman</p>Peyman Ghasemihttp://de.mathworks.com/matlabcentral/profile/authors/4395296-peyman-ghasemitag:de.mathworks.com,2005:Question/2680002016-02-13T17:15:10Z2016-02-14T02:29:48ZOptimization of random matrix<p>Hello,
I have a matrix 'MC' of 6 x 6 random complex numbers.
My problem is how to define my fitness function to optimize the matrix elements using GA ?
Can any one help</p><p>Here is the code I'm using,</p><p>function costFunction = FACGFSEM(MC)</p><p>FF(:,:,t)=F(:,:,t)*MC;</p><p>costFunction = sum(sum(FF))</p>abdelelah alzahedhttp://de.mathworks.com/matlabcentral/profile/authors/6758927-abdelelah-alzahedtag:de.mathworks.com,2005:Question/1326232014-06-06T00:06:16Z2016-02-14T01:46:21ZGenetic Algorithm fixed variable step in optimization toolbox <p>I have a problem of optimization of a photovoltaic and thermal system.
I have everything running on the optimization tool box and everything seems to be going well. However, I wonder if it is possible to restrict the degree of the variables. ie:</p><p>The number of variables:</p><p>nvar = 4</p><p>Variables:</p><p>Vch
Ac
PCM
Lp</p><p>My lower bounds (lb) and upper bounds (ub) are:</p><p>lb = [0 0.02 0.025 10000]
ub = [10 0.10 0:05 50000]</p><p>Optimization is being done with decimals which causes an excessively time consuming optimization.</p><p>I needed to set the step to the optimization runs. Is it possible?</p><p>Something like:</p><p>Vch = (0:1:10)
Ac = (0.02:0.01:0.10)
PCM = (0.025:0.005:0.050)
Lp = (10000:1000:50000)</p><p>It is possible to define these steps or fixed variables in the optimization by genetic algorithms?</p><p>Thanks</p>Ricardo Pereirahttp://de.mathworks.com/matlabcentral/profile/authors/2614850-ricardo-pereiratag:de.mathworks.com,2005:Question/2680342016-02-14T01:32:11Z2016-02-14T01:44:12ZHow would I create a function using a positive integer 'q' in a 5 by q matrix, where row 'i' consists of i, 2i, 3i...qi.<p>Also, how would a second output, containing the average of every element in the first output be written?</p>Jonathan Trenchenyhttp://de.mathworks.com/matlabcentral/profile/authors/7531279-jonathan-trenchenytag:de.mathworks.com,2005:Question/2680322016-02-14T01:21:30Z2016-02-14T01:33:32ZHow do I format this title function?<p>I'm displaying a figure and I want its title to be a file name as well as a string of text in combination. If the file name was Filename == example.tif and the text was '-ER' I'd want the figure title to be example.tif-ER</p><p>Doing this doesn't seem to work:</p><p>title(Filename '-ER')</p><p>I get an error in return, do I need to put something in between Filename and '-ER' to show I want them one after another as the title?</p>Kavorkahttp://de.mathworks.com/matlabcentral/profile/authors/7425652-kavorkatag:de.mathworks.com,2005:Question/2680312016-02-14T00:25:14Z2016-02-14T01:31:08ZIs there a way to define the values for the nvars variables they are incremented in steps, instead of all intermediary values defined in the bounds for running genetic algorithm. <p>Hello Matlab engineers,</p><p>I have 4 optimization variables for the GA :
* fstopb: the stopband frequency : (0.75:0.01:0.95)
* wtrans: width of the transition band :linspace(0.208,0.1250,10)
* deltas: the stop band attenuation in db : linspace(20,220,20)
* deltap: the pass band ripple in db : linspace(2,10,25)
I want these 4 nvars to take on specifically the values returned by the arrays, instead of all the values in between the bounds...is there a way ??</p>Samarth Behurahttp://de.mathworks.com/matlabcentral/profile/authors/5582284-samarth-behuratag:de.mathworks.com,2005:Question/2680332016-02-14T01:23:58Z2016-02-14T01:23:58ZHow to put pictures in a GUI that opens from the main GUI!<p>Hello!
I created a GUI with buttons that call other side GUI, each with different information. But I still fail to put images in these windows, and need multiple images to better explain the content.</p><p>Please help me!</p>Valariehttp://de.mathworks.com/matlabcentral/profile/authors/7187094-valarietag:de.mathworks.com,2005:Question/2679762016-02-13T05:00:00Z2016-02-14T01:15:19ZTEST Article<img src = "http://www.mathworks.com/matlabcentral/answers/uploaded_files/45284/28b8ea2c44135658930c6b844f91603e.png"><p>test</p>MathWorks Support Teamhttp://de.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:de.mathworks.com,2005:Question/2677022016-02-11T17:15:20Z2016-02-14T01:08:39ZGeneral Taylor Polynomial code<p>I'm trying to create a general code for evaluating Taylor polynomials for f(x)=x-sin(x)/x^3 and plot their relative error vs n iterations. I ran the code but I kept getting a N must be non-negative integers. Now, I'm confused. Also, I'm pretty new at Matlab. Some help would be great.</p><pre class="language-matlab">function[] = Taylor4(n,x)
n = input('Degree: ');
x = input('Value of x: ');
f=(1/x^2)-(sin(x)/x^3);
terms = zeros(1, n+1);
for j = 0:1:n
terms(j+1)=(-1).^(j+1)*(x.^(2j-2))/factorial(2j+1);
end;
</pre><pre class="language-matlab">%display(terms)
termsSum = cumsum(terms); %holds the estimate
termsSum1 = sum(terms);
</pre><pre class="language-matlab">display('The iteration: ')
display(terms)
</pre><pre class="language-matlab">display('The approximate estimate at x = -20: ')
display(termsSum1)
</pre><pre class="language-matlab">%true value at x=-20
display('TRUE VALUE')
display(f)
</pre><pre class="language-matlab">%absolute error between the approximated and true value
t = exp(x);
y = termsSum.^sign(x);
h = abs(t-y);
display('THE RELATIVE ERROR: ')
display(abs(f-termsSum))
</pre><pre class="language-matlab">%plot the Taylor approximation and exact value
semilogy(0:n,h); hold on %the Taylor polyonmial estimate when n = 10
semilogy(x,exp(x),'*') %exact value at x = -20
</pre>Chris Kwanhttp://de.mathworks.com/matlabcentral/profile/authors/6099572-chris-kwantag:de.mathworks.com,2005:Question/2680172016-02-13T19:56:22Z2016-02-14T01:03:45Zhelp with find function --> system of ODEs<p>Hello, I have solved a system of differential equations f(X,t) in Matlab. I would like to find t when X= 20% of its value at t=0. Any help? I am trying to use the find function.</p>Emma Andersonhttp://de.mathworks.com/matlabcentral/profile/authors/6970828-emma-andersontag:de.mathworks.com,2005:Question/2679872016-02-13T15:06:38Z2016-02-14T00:42:50ZWhy does 10^61 not equal 1e61 in MATLAB?<p>I noticed that 10^61==1e61 evaluates to false (0) in MATLAB. This implies that a^b and 1eX are computed differently. I am wondering how each one is computed, and why are they computed differently? In other words, why is 1eX not just computed as 10^X using the existing exponentiation function?</p><p>So far, I have figured out that 10^61-1e61==eps(1e61), meaning that 10^61 and 1e61 are adjacent floating point numbers, and that the true value is in between these two, and that 1e61 is closer than 10^61 to the true value. But I am not sure why they are different -- in other programming languages, like Python and even Octave, they are the same. But in MATLAB, they seem to be different?</p>Michaelhttp://de.mathworks.com/matlabcentral/profile/authors/1517402-michaeltag:de.mathworks.com,2005:Question/2680062016-02-13T19:06:20Z2016-02-14T00:32:12ZWhy do Nans occur in the inverse-transform process of my home-grown DFT (hgdft.m file recently uploaded)?<p>I have to terminate Nannies at the boundary points of the inverse DFT process of hgdft.m and I wonder if this is a Matlab limit.</p>Paul Fieldshttp://de.mathworks.com/matlabcentral/profile/authors/7396950-paul-fieldstag:de.mathworks.com,2005:Question/213392011-11-16T05:50:04Z2016-02-14T00:29:23ZHow to seperate fractional and decimal part in a real number<p>Hi,
Please help me in seperating fractional and decimal part in a real number.
For example: If the value is '1.23', I need to seperate decimal part '1' and 'fractional part '0.23'.</p><p>Thanks and regards,
soumya..</p>DSP Mastershttp://de.mathworks.com/matlabcentral/profile/authors/2774392-dsp-masterstag:de.mathworks.com,2005:Question/2679262016-02-12T23:30:28Z2016-02-14T00:03:55ZDecimal to Binary (ieee 754)<p>I want to create a code that converts decimal to ieee754. I do not want to use dec2bin so I do not know where to start. I want x to be my decimal number, eb to number of exponent bits and mb for my mantissa. The outputs are the convert value 'q' followed by s, e, m for sign, exponent, mantissa.</p><pre> function [q, s, e, m,] = GetRepresentationIEEE754(x, eb, mb)</pre>WhatIsMatlab-http://de.mathworks.com/matlabcentral/profile/authors/7623251-whatismatlabtag:de.mathworks.com,2005:Question/2680242016-02-13T22:12:22Z2016-02-14T00:01:31ZHow do I efficiently create a matrix that combines specific columns from pairs of odd and even rows into one, while excluding all columns with NaN values?<p>I have a matrix of the format:</p><pre class="language-matlab">[(time 1) (number of pairs in time 1)
(pair 1x) (pair 1y) (pair 2x) (pair 2y) (pair 3x) (pair 3y)
(time 2) (number of pairs in time 2)
(pair 1x) (pair 1y) (pair 2x) (pair 2y)]
</pre><p>where the time increases with a set interval. It should be noted that NaN’s fill up the ‘elements’ that do not have numerical data points.
So, a sample matrix would look like:</p><pre class="language-matlab">[1, 3, NaN, NaN, NaN, NaN;
1, 50, 20, 35, 3, 26;
2, 2, NaN, NaN, NaN, NaN;
2, 55, 21, 36, NaN, NaN]
</pre><p>The matrix I want has the format:</p><pre class="language-matlab">(pair 1x) (pair 1y) (time 1)
(pair 2x) (pair 2y) (time 1)
(pair 3x) (pair 3y) (time 1)
(pair 1x) (pair 1y) (time 2)
(pair 2x) (pair 2y) (time 2)
</pre><p>I essentially get the data from each even row in the original matrix and insert each pair of data AND the time from the row above it into a new 3-column matrix. The NaN’s aren’t included.
So, for the example above, I have:</p><pre class="language-matlab">[1, 50, 1;
20, 35, 1;
3, 26, 1;
2, 25, 2;
21, 36, 2]
</pre><p>I managed to get this done using two for loops, but that method is REALLY inefficient as I have 1000s of rows of data in a 44-column matrix.
The function that I have is:</p><pre class="language-matlab">function [prepared_matrix_with_x_y_t] = prepare_matrix(data)
number_of_columns_in_odd_rows = 2; %to delete NaN columns after extracting odd rows
column_with_number_of_pairs = 2; %the column number of the column that has the number of pairs
</pre><pre> coordinates = data(2:2:end,:);
x = coordinates(:,1:2:end);
y = coordinates(:,2:2:end);</pre><pre> number_of_columns_in_odd_rows_plus_one = number_of_columns_in_odd_rows + 1;
time_and_number_of_pairs = data(1:2:end,:);
time_and_number_of_pairs(:, number_of_columns_in_odd_rows_plus_one:end) = [];
size_of_time_and_number_of_pairs = size(time_and_number_of_pairs);
number_of_time_intervals = size_of_time_and_number_of_pairs(1); % can make MORE efficient, but using time_and_number_of_pairs below anyway</pre><pre> prepared_matrix_with_x_y_t = [];
for i=1:number_of_time_intervals
number_of_pairs = time_and_number_of_pairs(i, column_with_number_of_pairs);
for j=1:number_of_pairs
xj = x(i, j);
yj = y(i, j);
if (isnan(xj) || isnan(yj))
continue;
else
row_to_add = [xj yj i];
prepared_matrix_with_x_y_t = [prepared_matrix_with_x_y_t; row_to_add];
end
end
end
end</pre><p>Do you have any suggestions on how I can effectively handle this problem? I am new to MATLAB (as you may be able to tell), and I am certain that I am missing out on something very simple. Additionally, playing around with arrayfun and reshape got me nowhere.
Thank you for your time!</p>TribalPrincehttp://de.mathworks.com/matlabcentral/profile/authors/6364023-tribalprincetag:de.mathworks.com,2005:Question/2680292016-02-13T23:40:55Z2016-02-13T23:59:14ZI installed Matlab R14 on a Windows 10 OS. I seems to install OK, but the MATLAB program doesn't open correctly. When I try to uninstall Matlab with either the Matlab or Windows 10 uninstaller, I get an error. How can I uninstall MATLAB?<p>The uninstaller error message is "exception calling main".</p>Dekehttp://de.mathworks.com/matlabcentral/profile/authors/7661927-deketag:de.mathworks.com,2005:Question/2675142016-02-10T16:57:38Z2016-02-13T23:47:36ZHow to merge the waitbar into UIcontrol GUI <p>I have a UIcontrol program like below</p><pre class="language-matlab">function [] = MyGui()
</pre><pre class="language-matlab">S.fh = figure('units','pixels',...
'position',[200 200 800 800],...
'menubar','none',...
'name','GUI_2',...
'numbertitle','off',...
'resize','off');
</pre><pre class="language-matlab">S.ls = uicontrol('Style','text',...
'String','INTERACTIVE PARAMETER UPDATE',...
'FontWeight','bold',...
'FontSize', 12,...
'position',[200 700,400,50]);
</pre><pre class="language-matlab">S.pb1 = uicontrol('style','push',...
'units','pix',...
'position',[350 400 100 40],...
'fontsize',12,...
'string','Start',...
'callback',{@start_call});
</pre><pre class="language-matlab">S.ed = uicontrol('style','edit',...
'unit','pix',...
'position',[220 300 100 40],...
'fontsize',12,...
'string','New String');
</pre><pre class="language-matlab">S.pb2 = uicontrol('style','push',...
'units','pix',...
'position',[500 300 100 40],...
'fontsize',12,...
'string','Add String',...
'callback',{@update_call,S});
</pre><pre class="language-matlab">%Function for getting the nTs value and passing into encdec
function [] = update_call(varargin)
% Callback for pushbutton, reads new string from edit box.
S = varargin{3};
addstr = str2double(get(S.ed,'string')); % The string to add to the stack.
if ~strcmp(addstr,'NaN')
if addstr > 0 && addstr < 100
addstr
%pass the value to encdec
else
msgbox('Please enter a number between 1 and 100','WARNING')
end
end
</pre><pre class="language-matlab">%Function for starting the main program
function [] = start_call(varargin)
MainProgram
</pre><p>I am doing following tasks
1. I press the start and "MainProgram" runs. (Its a long running process)
2. I put some value in edit text box and press the update
3. The value will be passed onto the "MainProgram" for update.</p><p>Now I have two questions
1. there is a waitbar in MainProgram and how to merge that in main GUI (Instead of having a seperate pop-up). (start_call)
2. If user enters "addstr" value and press update, how can I interrupt MainProgram to take this addstr value for further processing ?</p><p>Thanks.
2.</p>Statisticalbeginnerhttp://de.mathworks.com/matlabcentral/profile/authors/2492431-statisticalbeginnertag:de.mathworks.com,2005:Question/2680252016-02-13T22:30:53Z2016-02-13T23:45:13ZHow to delete a character with quotation marks from the following text file ?<p>I want to delete the first row and first column from the attached text file by using the Matlab, which line command could help to achieve this task, I have alread tried "textscan", but I could not achieve this task ?!!</p><p>As a final result, I need to get a text file its content as the following:</p><img src = "/matlabcentral/answers/uploaded_files/45312/sample.png">Aiman Qaishttp://de.mathworks.com/matlabcentral/profile/authors/4775800-aiman-qaistag:de.mathworks.com,2005:Question/321372012-03-13T15:35:42Z2016-02-13T23:37:30ZUse video Live stream<p>Hello guys. I need to have a live video stream on matlab. I prefer if it's not on GUIDE. I found one but it's a .dll file and I can't use it. When I call it's function i get error. Do they need to be complied into matlab in any way???</p><p>All I need is to be able to capture an image from video stream each half second or maybe more. I have a code to process images but I want them to be taken from live webcam.</p><p>I appreciate any help.
Regards,
Arman</p>arman Yaraeehttp://de.mathworks.com/matlabcentral/profile/authors/3080821-arman-yaraeetag:de.mathworks.com,2005:Question/2679382016-02-13T02:02:43Z2016-02-13T23:06:24ZShuffle two different lists of numbers in the same way<p>I want to shuffle two vectors, both with n elements, so that they are shuffled in the same way, i.e. the corresponding elements in each are moved to the same spot. I have tried doing this by using randperm like this:</p><p>ix = randperm(n);</p><p>ShuffledVector1 = Vector1(ix);</p><p>ShuffledVector2 = Vector2(ix);</p><p>But the shuffling is not done in the same way, I know because when I run it for Vector1=Vector2, ShuffledVector1 doesn't end up equaling ShuffledVector2. Any advice?</p>Kavorkahttp://de.mathworks.com/matlabcentral/profile/authors/7425652-kavorkatag:de.mathworks.com,2005:Question/2680272016-02-13T23:03:05Z2016-02-13T23:03:05ZMatlab arduino serial interface for GPS and servos?<p>Hi all,
On the documentation page "Use Serial Communications with Arduino Hardware" it says "Serial communications are not supported in models that also use the Arduino Standard Servo Read, Standard Servo Write, and Continuous Servo Write blocks." Is there anyway to do this? We need to access a GPS shield via soft serial and also swing servo(s).
We are wondering if we could go back to the old style of Arduino I/O and just write PWM to the servos and talk standard serial to the GPS board? Any ideas or suggestions would be appreciated.</p>Jay Friedlandhttp://de.mathworks.com/matlabcentral/profile/authors/6825355-jay-friedlandtag:de.mathworks.com,2005:Question/2680202016-02-13T20:21:28Z2016-02-13T22:38:17ZProblem with matrix as input for pwelch()<p>I am trying to use pwelch fuction, but when I put in data in matrix (columns are independent parts of signal). pwelch returns PSD only for first column (vector), but I expected matrix with PSD in columns for every culomn. What I do wrong? My code is:</p><pre class="language-matlab">x; % data in matrix
w = pwelch(x); % w is vector with PSD of first column of x
</pre>Jan Pastykahttp://de.mathworks.com/matlabcentral/profile/authors/7661518-jan-pastyka