http://de.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2015-02-27T04:07:06Ztag:de.mathworks.com,2005:Question/1805832015-02-26T18:00:32Z2015-02-27T04:07:06ZIs it necessary to test a neural networks with data set unseen by ANN ??<p>Purpose: A neural networks, when properly trianed must have ability to generalize and not behave just like a memory.</p><pre> So, for me i used MLP( 7 inputs,1 ouputs, 1 hidden layer) type's of ANN with 13 years data set, i divided these data as following : </pre><pre> - 10 years data set to train my ANN
- 3 years unseen by ANN to test my model </pre><pre> My question is,can i delete this command 'net.divideparam.testRatio' since i used data unseen by ANN ????</pre><p>net.divideParam.trainRatio = 75/100;</p><p>net.divideParam.valRatio = 15/100;</p><p>|net.divideParam.testRatio = 10/100; (I think this command is not necessary!!! can i delete it ??)</p>omar belhajhttp://de.mathworks.com/matlabcentral/profile/authors/5323769-omar-belhajtag:de.mathworks.com,2005:Question/1804092015-02-26T04:39:13Z2015-02-27T04:02:43ZHow could I get an image red, green and blue from my color image?<p>Hello everyone,
I need some help with this please , How can I convert an image color(512x512) to gray image by using the following equation:
Intensity = 0.2989*red + 0.5870*green + 0.1140*blue and how can I get the image from each channel of red, green, and blue.</p><p>I really appreciate your answer.
Thank you very much.</p>Jorge Mejiahttp://de.mathworks.com/matlabcentral/profile/authors/6139935-jorge-mejiatag:de.mathworks.com,2005:Question/1806222015-02-26T21:46:26Z2015-02-27T03:55:08Zerror:Index exceeds matrix dimensions.<p>Hello,
I am trying to understand the problem here. The error is in (line 51) which is the one I have on either end. I cannot seem to figure it out. Any ideas?</p><p>%This begins the force analysis</p><p>for turn=['a','b','c','d','e','f','g']</p><pre> r.(turn).r3=.331;
r.(turn).force=r.(turn).force(:,2);
r.(turn).v=length(r.(turn).force);
r.(turn).justtime=r.(turn).justtime(1:r.(turn).v);
r.(turn).justangle=r.(turn).justangle(1:r.(turn).v);
r.(turn).sinangle=sin(r.(turn).justangle);
r.(turn).nettorque=(r.(turn).r3)*(r.(turn).sinangle).*(r.(turn).force);
for b=1:(r.(turn).v);
* *r.(turn).deltatorque(b)=r.(turn).nettorque(b+1)-r.(turn).nettorque(b);* *
end
r.(turn).deltatorque=r.(turn).deltatorque.';
r.(turn).network=(r.(turn).nettorque(1:r.(turn).v)).*(r.(turn).deltatheta(1:r.(turn).v));
r.(turn).deltapotential=(r.(turn).nettorque).*(r.(turn).justangle);
r.(turn).gravity=(9.81*(r.(turn).m))*(r.(turn).deltatheta);
r.(turn).withoutgravity=(r.(turn).deltapotential(1:r.(turn).v))-(r.(turn).gravity(1:r.(turn).v));
r.(turn).totalwork=sum(r.(turn).withoutgravity);
fprintf('The Total Work is %f\n',r.(turn).totalwork)
end</pre>Rachel Baumgartenhttp://de.mathworks.com/matlabcentral/profile/authors/6223142-rachel-baumgartentag:de.mathworks.com,2005:Question/1803942015-02-26T02:04:21Z2015-02-27T03:55:07ZHow can return the maximum appearance number in the square matrix?<p>How can I find the most repeated number in nxn matrice?
For example, if I have 3x3 matrix like this
[1 2 3;
6 6 4;
4 7 6]
In this case the most repeated number is 6. But if two or more numbers have repeated same time I want to retrieve the biggest one like next example
[2 5 2;
7 8 4;
5 -1 0]
In this case I want the function return the 5 because it is greater than 2 which both have the same number of appearances in the matrix.
I appreciate your help in advance</p>Salemhttp://de.mathworks.com/matlabcentral/profile/authors/4939341-salemtag:de.mathworks.com,2005:Question/1806322015-02-26T23:14:21Z2015-02-27T03:51:06ZHow to name .dat file headerlines? Urgent!!<p>Hello everyone, i have . dat file :</p><pre class="language-matlab">DFC=[anambe(:,1), anambe(:,6)];
saveascii(DFC ,'DFC1.dat', 8 );
</pre><p>everything is perfecet in the .dat file but there is one thing, there are default headerlines in. dat files as 'VarName1'.. please help me to change the default values as i want, please, tomorrow is the deadline for my thesis. that is the last thing left..</p>Cladio Andreahttp://de.mathworks.com/matlabcentral/profile/authors/3345831-cladio-andreatag:de.mathworks.com,2005:Question/1806372015-02-27T00:32:24Z2015-02-27T03:50:58ZLinear Integer Output from a Neural Network<p>I am trying to construct a custom neural network for regression that gives its response in whole integers rather than in continuous real numbers. This is done because the target data is also in whole integers and fractional amounts are meaningless to the application.</p><p>At first blush, I thought the solution here would be to create a copy of the purelin transfer function and sub-functions with the a=n term replaced with a=round(n). However, this seems to create only 3 discrete steps. On further inspection when the custom function runs, the inputs to the function are all bounded to [-1 1], resulting in round(n) converting them to -1, 0, or 1. Given that the purelin template is unbound, I can only surmise that there is a separate function which scales the input back up to the value range after the transfer function.</p><p>So, the question is, what function for the layer actually determines the final output? How can I achieve my aim of getting a network to output whole integers? As a note, just rounding the result after the fact is not an acceptable solution as the integer nature of the output needs to be considered when calculating the performance of the network during training.</p>James Mathiesonhttp://de.mathworks.com/matlabcentral/profile/authors/2092143-james-mathiesontag:de.mathworks.com,2005:Question/1801452015-02-24T21:14:42Z2015-02-27T03:48:20ZSaving / Showing Value of Variables in Genetic Algorithms<p>Hi there, I want to solve a problem using matlab.</p><p>It´s working great, I´m getting a solution after XXX generations.</p><p>But, it is only displaying me the FINAL solution for x(1) and x(2), the coordinates of the optimum solution. Let´s just say, I want to display the values of x(1) and x(2) after every iteration.</p><p>I want to show / save ALL values of x(1) and x(2) in the fitness function, so I can plot it in excel and show like:
Generation 1 x(1) and x(2) was bad solution
Generation 2 better etc etc
Generation XXX x(1) and x(2) are optimal</p><p>Any idea? its driving me crazy, tried the iterative display, this is getting me nowhere.</p><p>Please be patient, I am a beginner with matlab...</p><p>Best regards,
Marc</p>Marc Erhardhttp://de.mathworks.com/matlabcentral/profile/authors/6215018-marc-erhardtag:de.mathworks.com,2005:Question/1806462015-02-27T03:48:04Z2015-02-27T03:48:04Zhow to convert Resolver output to digital in simulink ?<p>I design a Motor + resolver in simulink i got the sin and cos wave forms.now i want to convert those to digital.
i see one method Inverse Tangent method but is very difficult.suggest me some other method</p>H SAI MANIKANTA Ehttp://de.mathworks.com/matlabcentral/profile/authors/6178816-h-sai-manikanta-etag:de.mathworks.com,2005:Question/1806452015-02-27T03:46:52Z2015-02-27T03:46:52Zwhat is matlab code for kampe de feriet functions or hypergeometric functions using matlab?<p><a href = "</matlabcentral/answers/uploaded_files/26264/hh.JPG"></matlabcentral/answers/uploaded_files/26264/hh.JPG</a>>
kampe de feriet functions unsing matlab</p>harish pandamanenihttp://de.mathworks.com/matlabcentral/profile/authors/6224201-harish-pandamanenitag:de.mathworks.com,2005:Question/1804082015-02-26T04:38:05Z2015-02-27T03:39:48ZI have no matlab experience and i need this done<p>EDIT: think i got it nevermind</p>John Smithhttp://de.mathworks.com/matlabcentral/profile/authors/6171988-john-smithtag:de.mathworks.com,2005:Question/1806442015-02-27T03:37:01Z2015-02-27T03:37:01Zhow to do FFT for video frames (100 frames) and store FFT results in two folder (one for magnitude and another for phase)<p>How to do FFT for video frames (100 frames) and store FFT results in two folder (the first folder for magnitude (100 magnitude images) and another for phase (100 phase images)</p>Ali Noorihttp://de.mathworks.com/matlabcentral/profile/authors/6004552-ali-nooritag:de.mathworks.com,2005:Question/1806432015-02-27T03:34:14Z2015-02-27T03:34:14Zupdate from matlab2013b to matlab2014b<p>hi, everyone
I would like to know if it costs any fees to upgrade my matlab from 2013b version to 2014b version.
I got the matlab through school and got a license for it.
Thanks</p>son lehttp://de.mathworks.com/matlabcentral/profile/authors/6149139-son-letag:de.mathworks.com,2005:Question/1805912015-02-26T18:12:18Z2015-02-27T03:00:27ZHow to best scan a table for same element values and create arrays to store the extracted data successively?<pre> I have a dataset like such: A text file with three columns Var1, Var2 and Var3.</pre><pre> In Var1 there are many elements of the same name to be exact in the following format: 0000000004 and when it reaches the 100 it becomes 0000000100.</pre><pre> UPDATE: I forgot to mention I used readtable to read in the values and set them up in a table in the below format.</pre><pre> My goal is to loop through the elements of Var1 and pick out the Var2 and Var3 values of the same Var1 and save them to a seperate array holding Var2 and Var3</pre><pre> Example: Var1 Var2 Var3
0000000004 5 6
0000000004 7 8
0000000004 9 10
0000000005 11 12
0000000005 13 14
.. .. ..</pre><pre> This will become Array4 = 4 6
7 8
9 10
Array5 = 11 12
13 14
and so on..</pre><pre> being new to matlab(coming from C++ background) the task has been harder than I anticipated. The place where I am struggling is to write a loop that changes the values I am searching for automatically, like how do I replace the numbering from 0000000004.png to 0000000010.png (replacing the zero with a 1 without going through a lot of trouble) and I am not sure how to search for a string value (since it is not only numbers). Could you please give me a few hints of how to start ?</pre><pre class="language-matlab">- I am going to iterate through the values of variable one via a for loop
- when there is a new value of Var1 I will create an array for storing its Var2 and Var3 values
- the whole procedure is put in a for loop to make it easier for the process to be repeated when a new 000000000x.png value appears in the Var1 column
</pre>KBK007http://de.mathworks.com/matlabcentral/profile/authors/4167836-kbk007tag:de.mathworks.com,2005:Question/1804512015-02-26T09:45:32Z2015-02-27T02:42:50ZLeast Squares Method for best line fitting<p>I have a set of X and Y coordinates data taken from Laser scanning</p><p>X=[x1 x2 x3 x4 .....]
Y=[y1 y2 y3 y4 .....]</p><p>Elements of both the X and Y include some errors.</p><p>I tried to find the best fitting line using <i>polyfit</i> and <i>polyval</i> command in matlab, but it can use only to calculate the Yhat w.r.t. X data.</p><p>At the end it will give X and Yhat only.</p><p>If I want to know calculate both the Xhat and Yhat, how can I use <i>polyfit</i> and <i>polyval</i> ?</p>Tharindu Weerakoonhttp://de.mathworks.com/matlabcentral/profile/authors/2598017-tharindu-weerakoontag:de.mathworks.com,2005:Question/1806392015-02-27T01:15:52Z2015-02-27T02:26:29ZRecording Kinect video in GUI<p>Hi all,</p><p>I'm using a MATLAB GUI to display a Kinect video that is being captured in real time. Does anybody know if and how it is possible to record this video while it is being captured, save it and have it available for viewing later in Windows Explorer? I should mention, it is the video appearing inside the axes that I want to record, i.e. the video with the person's skeleton overlaid on them.</p><p>Thanks!</p>MeEngrhttp://de.mathworks.com/matlabcentral/profile/authors/5225211-meengrtag:de.mathworks.com,2005:Question/1806422015-02-27T02:21:37Z2015-02-27T02:33:07Z How can I do a band pass filter over a interpolated time series?<p>I have a time series of density with a inconsistent sample interval, around 2-4 measurements per hour. I would like to select frequencies between 30 minutes(0.000555Hz) and 3 hour (0.0000926Hz), in order the identify alterations over the density data that occur only between these frequencies.</p><p>To archive this object a did a interpolation   <b><tt>yi = interp1(x,y,xi,'cubic')</tt></b>   and I am trying to apply the following band pass filter:</p><pre> fs=0.0167;
fnyquist=0.0167/2;
f1=0.0000926/fnyquist;
f2=0.000555/fnyquist;
[b,a]=butter(100,[0.0112 0.0669],'bandpass');
y=filter(b,a,x);</pre><p>This filter is not working, and I cant identify my error or how should I proceed to filter this kind of data that I have.</p><p>Thank you very much,</p><p>Gustavo</p>Gustavo Oliveirahttp://de.mathworks.com/matlabcentral/profile/authors/4306114-gustavo-oliveiratag:de.mathworks.com,2005:Question/1806112015-02-26T20:14:47Z2015-02-27T02:15:14ZNeural Network program problem in classification<p>Hi All</p><p>I am using this code to train my network, the problem is , if I give an input that is somehow among the value of the inputs I have chosen to train , it gives the right output , but if I give something out of this range , still the output is in the same range of the targets I have given to the code :</p><pre class="language-matlab">close all, clear all, clc, plt = 0
load('input.txt')
%load input
load ('target.txt')
%normalizing data
input=input';
target=target';
</pre><pre class="language-matlab">% input = mapstd(input);
% target = mapstd(target);
</pre><pre class="language-matlab">x=input;
t=target;
</pre><pre class="language-matlab">% [ x, t ] = simpleclass_dataset;
[ I N ] = size(x) % [ 2 1000 ]
[ O N ] = size(t) % [ 4 1000 ]
</pre><pre class="language-matlab">%vec2ind Transform vectors to indices. takes an NxM matrix V and returns a 1xM vector of indices
% indicating the position of the largest element in each column of V.
trueclass = vec2ind(t);
</pre><pre class="language-matlab">class1 = find(trueclass==1);
class2 = find(trueclass==2); %in my example all the largest elements are on the 2nd column
class3 = find(trueclass==3);
class4 = find(trueclass==4);
</pre><pre class="language-matlab">N1 = length(class1)
N2 = length(class2)
N3 = length(class3)
N4 = length(class4)
x1 = x(:,class1);
x2 = x(:,class2);
x3 = x(:,class3);
x4 = x(:,class4);
plt = plt + 1
hold on
plot(x1(1,:),x1(2,:),'ko')
plot(x2(1,:),x2(2,:),'bo')
plot(x3(1,:),x3(2,:),'ro')
plot(x4(1,:),x4(2,:),'go')
%
% Nw = (I+1)*H+(H+1)*O;
</pre><pre class="language-matlab">Hub = -1+ceil( (0.7*N*O-O)/(I+O+1)) % 399
Hmax = 40 % Hmax << Hub
dH = 4 % Design ~10 candidate nets
Hmin = 2 % I know 0 and 1 are too small
rng(0) % Allows duplicating the rsults
j=0
for h=Hmin:dH:Hmax
j = j+1
</pre><pre> net = patternnet(10);
net = init(net); % Improving Results since we use patternet we should use init
[ net tr y ] = train( net, x, t );
assignedclass = vec2ind(y);
err = assignedclass~=trueclass;
Nerr = sum(err);
PctErr(j,1) = 100*Nerr/N;
end
h = (Hmin:dH:Hmax)'
PctErr = PctErr</pre><p>I just want to know , according to the graphs of confusion , performance ,and the classes drawn , is the training enough or too much or little ?</p><img src = "/matlabcentral/answers/uploaded_files/26238/classes.jpg"><img src = "/matlabcentral/answers/uploaded_files/26237/conf.jpg"><img src = "/matlabcentral/answers/uploaded_files/26239/error.jpg"><img src = "/matlabcentral/answers/uploaded_files/26240/perf.jpg"><img src = "/matlabcentral/answers/uploaded_files/26241/regress.jpg"><img src = "/matlabcentral/answers/uploaded_files/26242/table.jpg">farzadhttp://de.mathworks.com/matlabcentral/profile/authors/2231846-farzadtag:de.mathworks.com,2005:Question/1806412015-02-27T01:59:02Z2015-02-27T01:59:02ZMATLAB code for segmenting an image containing no.of faces into individual faces<pre class="language-matlab">our project is automatic attendance monitoring by using face recognition
</pre>pavithra vummadihttp://de.mathworks.com/matlabcentral/profile/authors/6224010-pavithra-vummaditag:de.mathworks.com,2005:Question/1806302015-02-26T23:07:38Z2015-02-27T01:52:02ZI need to manipulate a static text in MATLAB GUI that needs to increment 1 every time the main program results a TRUE, how do I do this?<p>I have a program that results into either a TRUE or a FALSE... But in GUI, every time the result is TRUE, I need a static text to keep count and add 1 to itself per result of TRUE. How will I make this work?</p>Phillip Tiam Watthttp://de.mathworks.com/matlabcentral/profile/authors/3595010-phillip-tiam-watttag:de.mathworks.com,2005:Question/1805492015-02-26T15:31:20Z2015-02-27T01:50:10ZRepeatedly adding subplots to new figure via GUIDE<p>Hello,</p><p>I have created a GUI in GUIDE that plots a large amount of data on an axes within the GUI. What I would like to do is essentially use that axes as a preview axes, if that makes sense, and once it is deemed satisfactory by the user, it can be copied to a different figure outside of the GUI into its own subplot. I would like to be able to do this several times, such that I basically add new subplots to the other figure as I approve of the preview axes in the GUI. I have a pushbutton in the GUI called 'copyButton' with the idea that I can press this button, and my GUI axes and accompanying graph will be copied into a new subplot within the other figure, while also preserving any previously added subplots.</p><p>As I've mentioned, there is a tremendous amount of data, all stored in various multi-tiered structs within the GUI handles, so I'd like to avoid re-executing the plot command if possible. I think my key roadblock right now is just how one would copy the GUI plot over to the other figure into its own subplot without clearing the other subplots.</p><p>If anyone could provide any additional help, I'd be very appreciative. Let me know if there is any additional detail needed.</p><p>Thanks!</p>Alexhttp://de.mathworks.com/matlabcentral/profile/authors/5469587-alextag:de.mathworks.com,2005:Question/1806162015-02-26T21:11:46Z2015-02-27T01:48:14ZHow to segment objects based on their orientation?<p>If there are three object in a binary image. Their orientation are -45 20 and 85.
If I am interested in the object with orientation > 10. how can I do that</p>Mahmoudhttp://de.mathworks.com/matlabcentral/profile/authors/5880015-mahmoudtag:de.mathworks.com,2005:Question/1787782015-02-17T00:16:23Z2015-02-27T01:48:07ZGet string value from GUI listbox<p>I have created a GUI and selected the listbox to list lots of countries.</p><img src = "/matlabcentral/answers/uploaded_files/25486/Screen%20Shot%202015-02-17%20at%2000.10.59.png"><img src = "/matlabcentral/answers/uploaded_files/25487/Screen%20Shot%202015-02-17%20at%2000.12.43.png"><p>I then need to know what country the user has selected. The text box should update accordingly. I have used this code:</p><pre class="language-matlab">ListBoxCheck = get(handles.listbox1,'String');
if(ListBoxCheck == Afghanistan)
set(handles.text3,'String','Working');
elseif(ListBoxCheck == Argentina)
set(handles.text3,'String','Working2');
end
</pre><p>However, when I click on Argentina or Afghanistan I get this:
Undefined function or variable 'Afghanistan'.</p><p>Error in VisaProcessor>listbox1_Callback (line 135)
if(ListBoxCheck == Afghanistan)</p><p>Anyone know why or can help?</p><p>Thank.s</p>JRhttp://de.mathworks.com/matlabcentral/profile/authors/6001584-jrtag:de.mathworks.com,2005:Question/1803992015-02-26T02:49:19Z2015-02-27T01:41:38ZSolve system of equations by symbolic toolbox<p>Hi, I'm write a program to solve a system of equations :</p><p>clc</p><p>syms L Pg1 Pg2 Pg3 Pg4 teta1 teta2 teta3 lamda1 lamda2 lamda3 lamda4 lamda5
M1 M2 M3 P12 P13 P23 ;</p><pre> % Lagrange funtion
L = (7.5*Pg1+6*285+14*Pg3+10*Pg4) + lamda1*(-1000*teta1+500*teta2+500*teta3-(Pg1+285)...
+50)+ lamda2*(500*teta1-1500*teta2+1000*teta3-Pg3+60) +....
lamda3*(500*teta1+1000*teta2-1500-Pg4+300)+.....
lamda4*(teta1-0) + M1*(100/0.2 * (teta1-teta2)-126)+M2*(100/0.1 * (teta2-teta3)-130) + M3*(100/0.2*(teta1-teta3)-250);</pre><pre> eq1=diff(L,Pg1)
eq3=diff(L,Pg3)
eq4=diff(L,Pg4)
eq5=diff(L,teta1)
eq6=diff(L,teta2)
eq7=diff(L,teta3)
eq8=diff(L,lamda1)
eq9=diff(L,lamda2)
eq10=diff(L,lamda3)
eq11=diff(L,lamda4)
eq13=diff(L,M1)
eq14=diff(L,M2)
eq15=diff(L,M3)
[Pg1 Pg3 Pg4 teta1 teta2 teta3 lamda1 lamda2 lamda3 lamda4 M1 M2 M3]= solve (eq1,eq3,eq4,eq5,eq6,eq7,eq8,eq9,eq10,eq11,eq13,eq14,eq15)</pre><p>In command window show:
Warning: 12 equations in 1 variables.
> In solve>mupadSolve at 206
In solve at 93
In opf at 23
Warning: Explicit solution could not be found.
> In solve at 98
In opf at 23</p><p>Pg1 =</p><p>[ empty sym ]</p><p>Pg3 =</p><pre> []</pre><p>Pg4 =</p><pre> []</pre><p>teta1 =</p><pre> []</pre><p>teta2 =</p><pre> []</pre><p>teta3 =</p><pre> []</pre><p>lamda1 =</p><pre> []</pre><p>lamda2 =</p><pre> []</pre><p>lamda3 =</p><pre> []</pre><p>lamda4 =</p><pre> []</pre><p>M1 =</p><pre> []</pre><p>M2 =</p><pre> []</pre><p>M3 =</p><pre> []</pre><p>Can you tell me the solution for it ?
Thank you very much !!!!</p>ve rohttp://de.mathworks.com/matlabcentral/profile/authors/5298387-ve-rotag:de.mathworks.com,2005:Question/1806402015-02-27T01:36:05Z2015-02-27T01:41:54ZNikon camera acquisition and control using matlab?<p>I just bought a telescope and was wondering has anyone tried and/or have success with using Matlab to acquire data from a Nikon DSLR camera? I have a Nikon D7000 and I was hoping to use the home version of matlab + any toolboxes to get either the live view and/or send commands to the camera. There are some software that I found that does an adequate job but no complete suite that also does commands to the motorized gimbal and custom processing on the fly. If it is possible i'd like to create an application to acquire, process, control the gimbal, and anything else that i may think of.</p>Joseph Chenghttp://de.mathworks.com/matlabcentral/profile/authors/1938278-joseph-chengtag:de.mathworks.com,2005:Question/1806362015-02-26T23:53:32Z2015-02-27T00:49:45Zhow to input each element (different) of a matrix 'R' in same function 'f' and compute result in the matrix form?<ul><li><b>how to input each element (different) of a matrix 'R' in same function 'f' and compute result in the matrix form?</b> *</li></ul><p>I was trying to do this to get a series of f values in a (1x7) matrix form. Tried couple of if-loop variants, did not help.
Any help is appreciated. I know this is silly, but am just very new!
Thank You.</p><p>N = 7; % number of monomers %
b = 1; % bond length = hypotenuse %
R = rand(1, 7)
f =(2 * R / (N * (b^2))) * exp(-(R^2) / (N * (b^2)))</p>raktim royhttp://de.mathworks.com/matlabcentral/profile/authors/6122580-raktim-roytag:de.mathworks.com,2005:Question/990672013-03-05T15:36:00Z2015-02-27T00:43:38ZWhy do I receive the error "License Manager Error -9"?<p>When I attempt to launch MATLAB, I receive the following error:</p><p> </p><pre class="error"> License checkout failed. Invalid host. License Manager Error -9</pre>MathWorks Support Teamhttp://de.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:de.mathworks.com,2005:Question/921242013-05-07T16:16:00Z2015-02-27T00:28:13ZWhy am I unable to use matlabpool or parpool with the local scheduler or validate my local configuration of Parallel Computing Toolbox?<p>When attempting to use matlabpool or parpool in Parallel Computing Toolbox, it will not open or I receive an error message. As well, I am unable to validate my local scheduler profile.</p><p>I am not connecting to a cluster. How can I get the local scheduler to work?</p>MathWorks Support Teamhttp://de.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:de.mathworks.com,2005:Question/1802652015-02-25T11:44:28Z2015-02-27T00:16:56Zproblems writing a function<p>Hi all, I'm trying to write a function, but I have some problems, this is the script:</p><pre> exp((abs((x+2)*(x-3))/((x+3)*(x-2))))</pre><p>But Matlab shows me an error:</p><pre class="language-matlab">Error using *
Inner matrix dimensions must agree.
</pre><p>So I changed all with .*( <b>what is the difference?</b> )
The plot shows me a straight line at 2,42 (as if I only copy the function on matlab command window), but If I copy the function on wolfram site, the result is as I expect.
Why?
Thanks in advance, Alessandro</p>linofexhttp://de.mathworks.com/matlabcentral/profile/authors/5988132-linofextag:de.mathworks.com,2005:Question/1806352015-02-26T23:45:16Z2015-02-27T00:13:47ZIn an assignment A(I) = B, the number of elements in B and I must be the same. How do i tackle this<p>In an assignment A(I) = B, the number of elements in B and
I must be the same.</p><pre> clc;
clear all;
q = 50000;
h = 0.1;
g =1.4;
m1 = zeros(1,38);
m1(1) = 0.2;
cp = 1005;
t01 = zeros(1,length(m1));
t01(1) = 290.32;</pre><pre> for i = 1:length(m1)
t01(i) = t01(i)+ (i-1)*h;
m1(i+1) = m1(i) + h.*((1 +(g.*(m1(i).^2)))/2).*(((1+((g-1)/2).*(m1(i).^2)))/((1-m1(i).^2))).*(m1(i)./t01);
%t01 = t01 + q/cp;
%deno = 1 + ( ( (g-1)/2*m1^2));
%t1= t01/deno;
%dtbyds = ((1-1.4.*m1.*m1)/(1-m1.*m1))*(t1/cp);
%s = q/t01;
%m1 = m1 + (dmbydt.*(q/cp));</pre><pre> end
t(i+1) = i*h;</pre><pre> % this is the code and i am getting an error at the
m1(i+1) = m1(i) + h.*((1 +(g.*(m1(i).^2)))/2).*(((1+((g-1)/2).*(m1(i).^2)))/((1-m1(i).^2))).*(m1(i)./t01); </pre><p>part.</p>Varun Rahul http://de.mathworks.com/matlabcentral/profile/authors/6223732-varun-rahultag:de.mathworks.com,2005:Question/1806092015-02-26T20:05:11Z2015-02-26T23:53:28Zmultiple file reading from subdirectores...<p>I want to read multiple image files in sub-directories...</p><p>For that I used <i>Image Analyst's</i> very good code...</p><p><a href = "http://www.mathworks.com/matlabcentral/answers/uploaded_files/23754/recurse_subfolders.m">http://www.mathworks.com/matlabcentral/answers/uploaded_files/23754/recurse_subfolders.m</a></p><p>But when i tried it... i got this error... I already change permissions... n i m using ubuntu...</p><img src = "/matlabcentral/answers/uploaded_files/26233/Screenshot%20from%202015-02-27%2001:25:16.png"><pre> Thanks in Advanced... </pre>Shivang Patelhttp://de.mathworks.com/matlabcentral/profile/authors/5480160-shivang-pateltag:de.mathworks.com,2005:Question/934262009-08-25T18:27:00Z2015-02-26T23:48:58ZHow can I create a neural network for data classification using the Neural Network Toolbox?<p>I want to create and train a neural network which can classify the input data. For example, I would like to classify rocks into one of eight different classes based on the relative concentrations of the different minerals of which these rocks consist.</p>MathWorks Support Teamhttp://de.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:de.mathworks.com,2005:Question/1806312015-02-26T23:10:53Z2015-02-26T23:29:16ZHow can I make the following into a loop?<p>X= [some matrix I already stored and I want to add guassian noise to it, and average them out]</p><pre class="language-matlab">X_23= X + randn(size(X));
X_24= X + randn(size(X));
X_25= X + randn(size(X));
X_26= X + randn(size(X));
X_27= X + randn(size(X));
X_28= X + randn(size(X));
X_29= X + randn(size(X));
X_30= X + randn(size(X));
.
.
.
</pre><p>and so on</p>Pyrohttp://de.mathworks.com/matlabcentral/profile/authors/6001004-pyrotag:de.mathworks.com,2005:Question/1806342015-02-26T23:23:46Z2015-02-26T23:24:26ZMatlab Continuously Busy When Running Code<p>Hello again,</p><p>I have finally got my code to somewhat run. Now when I run my code with a certain function call it says it is busy, but will never end. When I manually stop the program I get this:</p><p>Operation terminated by user during test (line 57)</p><p>In newton_part_a (line 52)</p><p>fguess2 = myfunc(deltax2);</p><p>I'm just wondering what is happening here?</p><p>This is the command I am putting in:</p><p>newton_part_a(@test, [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1], 0.00001, 0.0001)</p><p>Here is my file:</p><pre class="language-matlab">if true
%Define a function that will read in:
%an m file containing n number of nonlinear functions
%an initial guess for the functions
%A value that will determine if convergence to a solution has occured
%(tolerance)
%The value for iteration for each guess
function K = newton_part_a(myfunc, guess, epsilon, step)
</pre><p>n = length(guess); %define the number of functions based on the test file input</p><p>deltay = zeros(1,n); % delta F for initial Newton Raphson guess
yguess = myfunc(guess); %Initial values for y matrix in forward substitution
initialguess = zeros(1,n);
Jacob = zeros(n,n); %Set up the initial Jacobian Matrix to a matrix of zeros
func = 1; %set func to 1 so that while loop has a valid argument</p><p>while func
%Find new value of delta y
for i = 1:n
%for number of equations in myfun, set delta y
deltay(i) = initialguess(i) - yguess(i);
end
%Exit loop if delta y has converged to an acceptable tolerance (epsilon)
if abs(deltay) < epsilon
func = 0;
break;
end</p><p>%Develop the Jacobian matrix
for i=1:n
%Fill in the empty matrix by moving column by column, line by line
for j =1:n
x1 = guess(j);
%set arguments for jacobian elements
xplus = x1 + step;
xminus = x1 - step;</p><pre> deltax1 = guess;
deltax1(j) = xplus;
deltax2 = guess;
deltax2(j) = xminus;</pre><pre class="language-matlab">fguess1 = myfunc(deltax1);
fguess2 = myfunc(deltax2);
</pre><pre class="language-matlab">guess1 = fguess1(i);
guess2 = fguess2(i);
%Find each element of the jacobian
J = (guess1 - guess2)/ (2*step);
Jacob(i,j) = J;
end
end
%Sparse Jacobian to make function faster
JJ = sparse(Jacob);
</pre><pre class="language-matlab">[L,U,P] = lu(JJ); %define lower and upper matrixes for LU factorization
</pre><pre class="language-matlab">b = deltay;
c = zeros(n,1);
b = deltay*P;
%forward substitution
for i=1:n
c(i)= (b(i)-L(i, :)*c)/L(i,i);
end
%set a matrix of zeros for new guess
newguess = zeros(n,1);
%backward substitution
for i=n:-1:1
newguess(i) = (c(i)-U(i,:)*newguess)/U(i,i);
guess(i) = guess(i) + newguess(i);
end
</pre><pre class="language-matlab">yguess = myfunc(guess);
end
%Output the value of the variables after convergence has occured
K = guess;
end
end
</pre>Kody Hauglihttp://de.mathworks.com/matlabcentral/profile/authors/6086999-kody-hauglitag:de.mathworks.com,2005:Question/185592011-10-18T05:30:09Z2015-02-26T23:21:25Zvideo frame capturing and resizing <p>i have installed a webcam .. following codes i am using for the video capturing the video</p><pre class="language-matlab">a = imaqhwinfo;
[camera_name, camera_id, format] = getCameraInfo(a);
</pre><pre class="language-matlab">vid = videoinput(camera_name, camera_id, format);
</pre><pre class="language-matlab">% Set the properties of the video object
</pre><pre class="language-matlab">set(vid, 'FramesPerTrigger', Inf);
</pre><pre class="language-matlab">set(vid, 'ReturnedColorspace', 'rgb')
</pre><pre class="language-matlab">vid.FrameGrabInterval = 5;
</pre><pre class="language-matlab">%start the video aquisition here
start(vid)
</pre><pre class="language-matlab">while(vid.FramesAcquired<=5)
</pre><pre> data = getsnapshot(vid);</pre><pre class="language-matlab">imwrite(data,'1.jpg');
</pre><pre class="language-matlab">end
</pre><p>the saved frame 1.jpg is of size 640X680...</p><p>but i want to capture the images of 104 X 120 poxel size,.. tell me how to do</p>Maxhttp://de.mathworks.com/matlabcentral/profile/authors/3008944-maxtag:de.mathworks.com,2005:Question/1806332015-02-26T23:20:40Z2015-02-26T23:20:40ZWhy is my "grayscale image" a 3D array; can I convert to 2D grayscale without sacrificing quality?<p>I am working on a reconstruction algorithm that uses total generalized variation (TGV) to reconstruct a partial parallel MR image. I need to use an image that has nice smoothness details (a gradual intensity gradient) in some areas, separated by edges, like that in figure 5 of</p><p><a href = "http://math.uni-graz.at/mobis/publications/SFB-Report-2009-038.pdf">http://math.uni-graz.at/mobis/publications/SFB-Report-2009-038.pdf</a></p><p>In fact I am trying to extract the image in 5(a) by taking a screen shot, copying to Paint and converting to .png (or .bmp, or .jpg) to be read in Matlab. The problem is that after I use</p><p>I=imread('extracted_image.png');</p><p>I is of size n x n x 3 . I figured that MATLAB simply assumes it is a rgb image. I have tried typical ways to get the image to n x n grayscale:
I1=rgb2gray(I);
I2=sum(double(I),3)./3;</p><p>But this induces some streaks across the image. It's really important to keep the smoothness of the textures. I'm not really sentimental to this image but now it's bothering me that I can't get it to work.</p><p>Thanks!</p>BenImagehttp://de.mathworks.com/matlabcentral/profile/authors/3614017-benimagetag:de.mathworks.com,2005:Question/237222011-12-12T13:15:41Z2015-02-26T23:20:28ZHow do I fix the error Function definitions are not permitted at the prompt or in scripts.<p>whenever I write the command
function imageChoice_callback(hObject,eventdata).
Encounter an error Function definitions are not permitted at the prompt or in scripts.
please suggest me how do i fix it.</p>neetika Karwasrahttp://de.mathworks.com/matlabcentral/profile/authors/3225537-neetika-karwasratag:de.mathworks.com,2005:Question/246602011-12-24T10:54:06Z2015-02-26T23:19:18Zfrom matlab class to simulink<p>Is it possible to use a matlab user defined class in simulink? What is possible in simulink is to use a matlab user defined function or script but not a class. The solution I could think off is to place the class methods (functions) in a simulink fnc block.</p>Abdullah Alshammaryhttp://de.mathworks.com/matlabcentral/profile/authors/1173689-abdullah-alshammarytag:de.mathworks.com,2005:Question/261942012-01-16T09:42:48Z2015-02-26T23:18:24ZVariables not displayed in WorkSpace.<p>From the main program, i have to call 3 different functions(e.g add, subtract and divide) and In each m-file i am using many new variables which are not shown in Matlab Workspace. Only called variables and variables in the main files are shown.
Is there any setting to view all the variables in all m-files , i use in my Program.</p><p>main()</p><p>{</p><p>call fcn1(a,b)</p><p>call fcn2(c,d);</p><p>...
}</p><p>fcn1()</p><p>{</p><p>(a, b, f,g, h, i, j ) all these variables are used which must be needed in WorkSpace.</p><p>Thanks in Advance.</p>Tallha Akramhttp://de.mathworks.com/matlabcentral/profile/authors/1419703-tallha-akramtag:de.mathworks.com,2005:Question/261372012-01-15T06:22:25Z2015-02-26T23:17:44ZHow to edit a particular variable in a netcdf file?<p>Hi, I am trying to modify a specific variable in a netcdf file. In my file a 4D-variable named MSUL_V(lat,lon,level,time) is there, i want to change the values of this variable at every lat and lon.
I am not familiar with editing variables in netcdf package MATLAB.</p><p>Please help me about this. I do appreciate if everyone could help me about this. Thanks Angshuman</p>Angshumanhttp://de.mathworks.com/matlabcentral/profile/authors/3268131-angshumantag:de.mathworks.com,2005:Question/339032012-03-29T15:14:47Z2015-02-26T23:15:16Zhow to build an interface between matlab and another software<p>Hi everyone,</p><p>I would like to get some advice on how to build an interface between Matlab and another software like in my case, CalculiX. I actually do not know how to automate the process of sending input from a matlab GUI to calculiX and then send the output from CalculiX solvers back to our Matlab GUI to visualise the simulation results. Any help would be more than welcome, thank you very much,</p><p>% Romain</p>Romain Whttp://de.mathworks.com/matlabcentral/profile/authors/2942290-romain-wtag:de.mathworks.com,2005:Question/338042012-03-29T00:10:55Z2015-02-26T23:13:40Ztable for string<p>Hello. I have a problem in making table for string.</p><p>There is a numerical value a.
Then,i want to convert it to the string, and insert it to the table.</p><p>a = 12345;
b = num2str(a);</p><p>Table(1) = b;</p><p>This code makes the Error message come up like this.
'Subscripted assignment dimension mismatch.'</p><p>What's the problem of this code?</p><p>Please help me!</p>Janehttp://de.mathworks.com/matlabcentral/profile/authors/3135897-janetag:de.mathworks.com,2005:Question/350262012-04-10T13:08:22Z2015-02-26T23:13:01ZUsage of idmodel in simulink<p>I would try a model predictive controller in simulink for a 4-input-single-output system, which is described by an idss model. the focus of the model is 100-step prediction.
How should I introduce this model into simulink? I found the block of "idmodel" in system identification tool box. But I am not clear of the format of its input and output. Shall I use an iddata as the input or 4 input vectors?</p>LEI CAOhttp://de.mathworks.com/matlabcentral/profile/authors/2041383-lei-caotag:de.mathworks.com,2005:Question/1806122015-02-26T20:18:12Z2015-02-26T23:06:39ZProblems with a plot<p>Hi,</p><p>I want to plot in Matlab the frequency of a system (vector of dimension of 1800000 * 1) between 11:00 am and 16:00 pm. My time vector has also a dimension of 1800000 * 1, containing the time sampled in milliseconds (there are 100 samples for each second). I would like to plot all the frequency with the time axis showing the time (i.e. 11:00 – 11:10 - … 16:00) but not showing the milliseconds. How can I do that?</p><p>Thank you</p>Claudia Rahmannhttp://de.mathworks.com/matlabcentral/profile/authors/1925467-claudia-rahmanntag:de.mathworks.com,2005:Question/38072011-03-23T09:11:34Z2015-02-26T23:03:25Zwatershed segmentation<p>what is watershed?what are the advantages and disadvantages of watershed segmentation?how can we say either it is lossy or lossless process</p>bhargavihttp://de.mathworks.com/matlabcentral/profile/authors/2764767-bhargavitag:de.mathworks.com,2005:Question/358562012-04-18T11:14:28Z2015-02-26T23:02:37ZHow to apply Ziegler Nichols and Cohen and coon tuning?<p><a href="http://i39.tinypic.com/332p8wh.png">http://i39.tinypic.com/332p8wh.png</a>
The problem given to me is as above mentioned. For above system when I follow Ziegler Tuning, I get oscillations at ku= 3.105 and pu=1.8sec. Now when I compute and substitute the values I am not getting the accurate result. Please help me as how to perform the Ziegler Nichols and Cohen and Coon method for the problem.
Provide me with step by step procedures.
Thanks,
BHARATH</p>Bharathhttp://de.mathworks.com/matlabcentral/profile/authors/2653443-bharathtag:de.mathworks.com,2005:Question/1806292015-02-26T22:47:25Z2015-02-26T23:02:29ZSubscripted assignment dimension mismatch.<p>Hello, I'm getting the error 'Subscripted assignment dimension mismatch.' for this piece of code:</p><pre> a = -3;
b = 3;
M = 10^(5);
nrs = a + (b-a)*rand(2*M,1);
rng(:,1) = (nrs(1:length(nrs)/2));
rng(:,2) = (nrs(length(nrs)/2:end-1));</pre><p>Could anyone help me to figure out what is wrong and how to fix it? Thank you very much.</p>Marcushttp://de.mathworks.com/matlabcentral/profile/authors/5855970-marcustag:de.mathworks.com,2005:Question/75582011-05-17T03:27:51Z2015-02-26T23:01:28ZCan't compile matcreat.cpp in linux<p>I can't successfully compile the example file: matcreat.cpp (provided by mathworks.) I am running linux centOS 5.6 and am using g++ version 4.1.2. My matlab version is 2010a and I am on a 64-bit machine.</p><p>I can, however, successfully compile and run matcreat.c using gcc.</p><p>The command I use to compile is:</p><pre> g++ -o ~/m matcreat.cpp -I /usr/local/matlab2010a/extern/include/ -L /usr/local/matlab2010a/bin/glnxa64/ -lmat -lmx</pre><p>Here are the errors I get when using g++ to compile matcreat.cpp</p><pre> /usr/local/matlab2010a/bin/glnxa64//libmx.so: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)@GLIBCXX_3.4.9'
/usr/local/matlab2010a/bin/glnxa64/libut.so: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::basic_ostream<char, std::char_traits<char> >::_M_insert<void const*>(void const*)@GLIBCXX_3.4.9'
/usr/local/matlab2010a/bin/glnxa64/libmwfl.so: undefined reference to `std::bad_alloc::what() const@GLIBCXX_3.4.9'
/usr/local/matlab2010a/bin/glnxa64/libmwfl.so: undefined reference to `std::basic_istream<char, std::char_traits<char> >& std::basic_istream<char, std::char_traits<char> >::_M_extract<bool>(bool&)@GLIBCXX_3.4.9'
/usr/local/matlab2010a/bin/glnxa64//libmx.so: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::basic_ostream<char, std::char_traits<char> >::_M_insert<double>(double)@GLIBCXX_3.4.9'
/usr/local/matlab2010a/bin/glnxa64/libut.so: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::basic_ostream<char, std::char_traits<char> >::_M_insert<long>(long)@GLIBCXX_3.4.9'
/usr/local/matlab2010a/bin/glnxa64/libut.so: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::basic_ostream<char, std::char_traits<char> >::_M_insert<bool>(bool)@GLIBCXX_3.4.9'
/usr/local/matlab2010a/bin/glnxa64//libmx.so: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::basic_ostream<char, std::char_traits<char> >::_M_insert<unsigned long>(unsigned long)@GLIBCXX_3.4.9'
collect2: ld returned 1 exit status</pre><p>I would like write c++ code to read and write .mat files. Thanks!
-- Michael</p>Michaelhttp://de.mathworks.com/matlabcentral/profile/authors/1908407-michaeltag:de.mathworks.com,2005:Question/75322011-05-16T17:16:05Z2015-02-26T22:59:54ZControl structures<p>List the control structures available in Matlab to control the
program flow. Describe an example of where you might use each structure.</p>Daniel Mershahttp://de.mathworks.com/matlabcentral/profile/authors/2876271-daniel-mershatag:de.mathworks.com,2005:Question/71842011-05-10T21:26:06Z2015-02-26T22:58:50ZHow can I write 32-bit floating point TIFs with NaNs?<p>I'm able to use IMREAD to read 32-bit floating point TIFs with NaNs for dead pixels.</p><p>After this, I do an image rotation with IMTRANSFORM with 'FillValue' of NaN (IMROTATE only fills with zeros).</p><p>Now, I'd like to save 32-bit floating point TIFs with NaNs in tact for later.</p><p>How can I do this? I've tried IMWRITE and MULTIBANDWRITE, but they don't seem to work.</p><p>I'm using MATLAB 7.11.0 (R2010b).</p><p>Thanks,</p><p>Kevin Crosby</p>Kevin Crosbyhttp://de.mathworks.com/matlabcentral/profile/authors/1435076-kevin-crosbytag:de.mathworks.com,2005:Question/1793402015-02-19T19:34:15Z2015-02-26T22:57:47ZLinearizing a non-linear ARX model for making a PID controller ?<p>Hi all,</p><p>I want to create a PID controller for my non-linear arx model but I was told that I needed to linearize my system first. Now I know the PID tuner automatically linearizes it but it does this at the first second at an input level of 1.</p><p>My plant has a dead zone behaviour at the first second and also, the input must be a minimum of 2.5V to get it to move from an output of zero.</p><p>How do I go about linearizing this non-linear arx plant at these specific conditions ?</p><p>Thanks</p>Stevehttp://de.mathworks.com/matlabcentral/profile/authors/5849142-steve