http://nl.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2015-03-28T03:48:53Ztag:nl.mathworks.com,2005:Question/1949572015-03-28T03:02:42Z2015-03-28T03:48:53ZHow to read 1st coloumn from excel sheet which contains 60x3 values.<p>I have an excel sheet which contains 60x3 values I want to read the entire first column and display it..
can somebody help me with the code</p>krishnasrihttp://nl.mathworks.com/matlabcentral/profile/authors/5577130-krishnasritag:nl.mathworks.com,2005:Question/1841032015-03-20T00:39:41Z2015-03-28T03:18:13ZGPU fft encounters error<p>I am using gpu parallel to accelerate computation with Tesla 20, Matlab2015a. However, the program always encounters error at the same gpu operation. Below is the error message:</p><pre class="language-matlab">Error using gpuArray/fft2
MATLAB encountered an unexpected error in evaluation on the GPU. If you continue to see this error, reset the GPU device or restart MATLAB and try again.
</pre><p>I guess that this results from limited gpu memory since when I smaller the data size, the program runs smoothly. However, when the program breaks, I find that there are still 3G space available according to gpuDevice.
What could be the problem? Does the system only grants Matlab a limited portion of gpu memory? How can I solve it?
Thanks,</p>Jingzhao Zhanghttp://nl.mathworks.com/matlabcentral/profile/authors/4579240-jingzhao-zhangtag:nl.mathworks.com,2005:Question/1949562015-03-28T02:52:42Z2015-03-28T03:16:09ZElement-wise Matrix Division<p>I'm trying to create a one column vector (Nrows:1) called 'Grad' by dividing each element of 'delta_P' by the corresponding element in 'delta_x'. The issue I'm having is that matlab is substituting 'delta_x .* f' for 'delta_P' in the grad equation at the very bottom of the script. Then the final equation becomes Grad=(delta_x .* f)/delta_x, it cancels delta_x on the top and bottom and sets Grad=f in the end. I don't want the program substituting intermediate variables and performing arithmetic with the final equation. Is there anyway to get around this?</p><p>Thanks,</p><pre> % calculate Grad
f = 0.000082;</pre><pre> % North/South distance balloon travels in one second (feet).
delta_x = north_south_wind .* 3.28;
% Find the horizontal pressure change given f=PGF (pascals).
delta_P = delta_x .* f;
% Gradient is change in pressure over change in distance
Grad = delta_P ./ delta_x; </pre>Jeff Szkodzinskihttp://nl.mathworks.com/matlabcentral/profile/authors/6257348-jeff-szkodzinskitag:nl.mathworks.com,2005:Question/1948622015-03-27T12:23:55Z2015-03-28T03:05:52ZHow to read LSB of audio sample?<p>Hello everyone...
I am working on audio steganography project.And i need to read and manipulate LSB of the audio sample.Please tell me a way to do this.
Thanks in advance.</p>manisha sharmahttp://nl.mathworks.com/matlabcentral/profile/authors/5909327-manisha-sharmatag:nl.mathworks.com,2005:Question/1945202015-03-26T14:03:16Z2015-03-28T03:03:40Zeuclidean distance calculation for values from excel sheet<p>sir, I have values in an excel sheet, which contains 60x3 values, they are x,y,z cordinates for all the 60 points.Now I need to find out the distance : <tt>|d(i)|</tt>=sqrt((x(k)-x(j))^2+(y(k)-y(j))^2+(z(k)-z(j)^2)), where i=1:60 , j,k are end points of the line segment under consideration, i.e., between these 60 points line segments are considered, for which this distance we are calculating. So j,k can be j=1:59 and k=2:60..</p><p>Can you please help me with the code...</p>krishnasrihttp://nl.mathworks.com/matlabcentral/profile/authors/5577130-krishnasritag:nl.mathworks.com,2005:Question/1946192015-03-27T00:15:59Z2015-03-28T03:03:31ZHow do I use MatLab to solve this set of differential equations?<p>So here is my code (The code only contains the initial constants and equations):</p><pre class="language-matlab">%Constants
Fb = .103;
k = 40/60*1000;
alpha = .010235;
mass = 30;
vo = 8.571;
epsilon = .6;
</pre><pre class="language-matlab">%Equations defining the Concentrations and the Rate of Destruction
Ca = @(x,y) Fb*(4-2*x)*y/((1+epsilon*x)*vo);
Cb = @(x,y) Fb*(1-x)*y/((1+epsilon*x)*vo);
rb = @(x,y) k*Ca(x,y)^2*Cb(x,y)^2;
</pre><pre class="language-matlab">% Differential Equations
dx = @(x,y) rb(x,y)/Fb;
dy = @(x,y) -alpha*(1+epsilon*x)/(2*y);
</pre><p>x is the percent conversion and it is a function of w (catalyst mass). y is a ratio of pressures and is also a function of w. When w = 0, x = 0 and y = 1. I need to find the percent conversion (x) for a given catalyst mass (w).</p><p>dx represents dx/dw and dy represents dy/dw.</p><p>How do I solve a problem like this using MatLab?</p>CarlosRobellihttp://nl.mathworks.com/matlabcentral/profile/authors/4970164-carlosrobellitag:nl.mathworks.com,2005:Question/160352011-09-17T07:31:38Z2015-03-28T02:58:12Zsaving all of workspace in a specified folder<p>saving all of workspace in a specified folder and after saving, how it can be import to MATLAB (load) from that specified folder?</p>mohammadhttp://nl.mathworks.com/matlabcentral/profile/authors/3010602-mohammadtag:nl.mathworks.com,2005:Question/1948542015-03-27T11:50:42Z2015-03-28T02:58:06ZWhat is the minimum sample that I should take to do forecasting of a vegetable sold by company on per day basis. I am using Functional Artificial Neural Network to do the forecasting. I have taken data of 40 days and I am getting large error.<img src = "/matlabcentral/answers/uploaded_files/27961/Potato_demand_forecast.jpg"><p>During training of my FLANN model :</p><p>BLUE Line ---> Actual sales data,</p><p>GREEN Line -----> Predicted sales data</p>Anand Kumarhttp://nl.mathworks.com/matlabcentral/profile/authors/6339048-anand-kumartag:nl.mathworks.com,2005:Question/1086712013-12-04T21:17:41Z2015-03-28T02:53:23ZHow can change the performance function in neural network ?<p>I have Matlab versions R2013a and R2012b. I want to customize the performance function for neural network online training using 'adapt' function. The default performance function for both adapt/train functions is 'mse'. How can I change this function for adapt function.</p><p>What I tried so far:
I tried changing the 'performFcn' to a .m file I wrote. Using the standard template of mse.m. I wrote all the necessary functions and the dcos function for gradient error function as well. But everything gave random errors - which mostly I traced back to the problem that latest versions of Matlab dont allow overriding 'mse' for adapt function. Is it true ?</p><p>Irrespective of that - how do I customize the performance function for neural network ?</p><p>Thanks</p><p>Anush</p>Anushhttp://nl.mathworks.com/matlabcentral/profile/authors/2715693-anushtag:nl.mathworks.com,2005:Question/1949552015-03-28T02:44:02Z2015-03-28T02:44:02ZParallel Computing Toolbox: Client/Server Compatibility?<p>Is a client/server version compatibility matrix documented for the PCT? Which versions of the PCT client are compatible with which versions of the MATLAB Distributed Computing Server?</p><p>Specifically, I am running R2012a on my laptop and my school's computing server is at version R2014a. Is this client/server combination compatible?</p><p>If I upgrade my laptop to the latest R2015a and the computing grid stays at R2014a, then is this combination compatible?</p>Christopher Rhttp://nl.mathworks.com/matlabcentral/profile/authors/3765291-christopher-rtag:nl.mathworks.com,2005:Question/1948212015-03-27T10:20:05Z2015-03-28T02:43:21ZHow to create an output layer consisting of a single output neuron using patternnet?<p>Hi!</p><p>I have a 2-class classification problem, for which I want to use an output vector that consists of only two values, 1 and 0. When I use patternnet for creating the network and then train it using train function, all the patterns are classified to only one class, giving me only 50% accuracy (I have equal patterns from both classes). Is there any solution?
Thanks.</p>TS Sharmahttp://nl.mathworks.com/matlabcentral/profile/authors/5002777-ts-sharmatag:nl.mathworks.com,2005:Question/1948732015-03-27T13:30:01Z2015-03-28T02:22:29ZCan I use neural network in this case?<p>can I use neural networks or svm or etc, if my output data is 27680 that all of them are zero and just one of them is one? I mean that Is it right to do this?</p><p>when I use SVM I have this error: Error using seqminopt>seqminoptImpl (line 198) No convergence achieved within maximum number of iterations.</p><p>thanks</p>sarahttp://nl.mathworks.com/matlabcentral/profile/authors/5590407-saratag:nl.mathworks.com,2005:Question/1949482015-03-28T00:27:45Z2015-03-28T02:18:51ZAssigning property/value to image color, Oklahoma state<p>Hello,</p><p>I have a very simple image (attached) that has white background and several filled circles of different colors. I am interested in the part of the image that is inside the line boundary (approximate boundaries for Oklahoma state). How can create matrices/grids that will have different numbers based on the color of the circles. For instance, the matrix/grid for red circles (color) should have value 5 for red color and 0 for whatever is not red; green should have 3 inside and 0 outside, etc.</p><p>Thanks,
DjR</p>djrhttp://nl.mathworks.com/matlabcentral/profile/authors/5483786-djrtag:nl.mathworks.com,2005:Question/1949302015-03-27T20:11:53Z2015-03-28T02:18:34ZWhat is the appropriate Method to normalize inputs data ????<p>I used sigmoidal function as activation function in hidden layer (forecasting issues).who is interval can i choose to normalize my inputs datasets [-1,1] or [0.1,0.9] ?? and how can i do it ?? by default i used these following commands :</p><pre class="language-matlab">net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};
</pre>omar belhajhttp://nl.mathworks.com/matlabcentral/profile/authors/5323769-omar-belhajtag:nl.mathworks.com,2005:Question/1949412015-03-27T22:04:06Z2015-03-28T02:16:01ZHow can I use an edit text box to plot a function in a GUI?<p>Hello,</p><p>I've tried just about everything I can think of to take a function input from a text edit box in a GUI and plot it. Here's my code currently:</p><pre class="language-matlab">function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
</pre><pre class="language-matlab">% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
</pre><pre class="language-matlab">fct1 = get(handles.edit1,'string');
axes(handles.axes1);
plot(fct1)
</pre><p>I've tried various things, such as using str2func, messing with eval, etc. but nothing seems to work. Can someone help me out with correct syntax to make this happen?</p><p>Thanks!</p>Ian Hankenhttp://nl.mathworks.com/matlabcentral/profile/authors/4964809-ian-hankentag:nl.mathworks.com,2005:Question/1949422015-03-27T22:24:34Z2015-03-28T02:04:55ZCan I add toolboxes to Matlab Home Later On?<p>Q1: I am a Matlab author and have used Matlab extensively in my two books. Now that I am aware of Matlab Home I want to know if I can recommend it to my readers. To find out, I plan to order Matlab Home and try it out on my book scripts. If I need certain additional toolboxes, say, like the signal processing toolbox, can I order the toolbox separately and install it after the basic Matlab Home package was installed?</p><p>Q2: I currently have the regular Matlab with several toolboxes. Will the installation of Matlab Home interfere the regular Matlab installation?</p><p>Thanks.</p>David Koenighttp://nl.mathworks.com/matlabcentral/profile/authors/1322461-david-koenigtag:nl.mathworks.com,2005:Question/1949512015-03-28T01:09:28Z2015-03-28T01:56:47ZHow to get Second GUI to pop up in Front of Main GUI instead of Behind<p>When i launch another GUI from my main GUI, the new one pops up BEHIND the main GUI, i want it to pop up in front of the main GUI.
is there a "make this the current figure" code?
or a "send GUI to back" code?</p>Michael Johnsonhttp://nl.mathworks.com/matlabcentral/profile/authors/6143949-michael-johnsontag:nl.mathworks.com,2005:Question/1949362015-03-27T21:33:32Z2015-03-28T01:54:13ZMorphological dilation in a certain direction<p>Dilation by creating structuring element will dilate in all direction, but I want to do dilation in a particular direction, say 70 degree from a particular pixel. I understand that I need to write a self-adaptive function, but how?
For example, I have a line with slope of 70 degree. I want to increase the length of the line in both end (by dilation). If i use "bwmorph()", it increases in all direction, But I need only in one direction.</p>Tanmoyhttp://nl.mathworks.com/matlabcentral/profile/authors/4522085-tanmoytag:nl.mathworks.com,2005:Question/1949532015-03-28T01:32:14Z2015-03-28T01:53:52ZPlot not as expected<p>Could someone help me with this
t=1:1:200</p><p>v1=1+3*t</p><p>v2=1-0.2*t</p><p>vs=v1</p><p>vs(v1>60)=v2(v1>60)</p><p>plot(t,vs)</p><p>I was trying to plot the velocity of an object.It accelerate at 3 m/s2 until 60, and then slows down at 0.2.</p><p>The plot consists of dispersed parts from the two functions, instead of a zigzag fluctuation around 60 which is what I am trying to achieve.
I understand why the plot is like this, but failed to come up with a solution.</p>Mu Lihttp://nl.mathworks.com/matlabcentral/profile/authors/6341065-mu-litag:nl.mathworks.com,2005:Question/1949392015-03-27T21:59:29Z2015-03-28T01:48:35Zpassing multiple inputs to .exe via system or dos<p>I'm trying to pass a series of inputs to an executable via the <tt>system</tt> command, but in every way I've tried to run it, I'm prompted to manually input values in the command window. I need to run this program several hundred times, so I'd rather not enter parameters manually. The program is called solid.exe and is available <a href = "http://home.comcast.net/~dmilbert/softs/solid.zip">here</a> if you're feeling compelled to give it a shot.</p><p>To get solid earth tide estimates for March 12, 2005 at (65°N,123°E), I've tried</p><pre class="language-matlab">system('solid.exe 2005 3 12 65 123')
</pre><p>and</p><pre class="language-matlab">s = sprintf('solid.exe %s \r %s \r %s \r %s \r %s','2005', '3','12','65','123');
system(s);
</pre><p>and a whole host of other ways to concatenate strings. No matter what I try, the command window still wants manual data entry. I can simply type</p><pre class="language-matlab">system('solid.exe')
</pre><p>and when I enter parameters, it takes a fraction of a second for the program to run. How can I automate this to compute a series of lat, lon and times?</p>Chad Greenehttp://nl.mathworks.com/matlabcentral/profile/authors/1062128-chad-greenetag:nl.mathworks.com,2005:Question/1838812015-03-18T18:40:40Z2015-03-28T01:48:06ZMat file corrupt? I'm not so sure...<p>Hi,</p><p>I have a random issue where the following line in my code:</p><pre> data = load(job_output_filenames{job_index});</pre><p>ends up generating a message that it's unable to load that mat file, and it may be corrupt. Maybe 50% of the time. Yet every time I drag it into Matlab, it opens fine, and I see 4 variable cell arrays, all looking OK. Could it possibly be memory, or heap space? I have 600mb heap now...if I go too much higher, Matlab says it cannot open, so it reduces back to 128mb.</p><p>If it happens again, I can capture exact error messages if it helps....</p><p>Dave</p>David Pesetskyhttp://nl.mathworks.com/matlabcentral/profile/authors/6182327-david-pesetskytag:nl.mathworks.com,2005:Question/1949442015-03-27T23:21:22Z2015-03-28T01:13:58ZHow to generate intercorrelated multivariate random numbers?<p>Hi,
how can I generate a matrix (say 100x60) of normally distributed variables where some of the variables are correlated with others and some of them aren't?</p><p>do I approach this with 'randn' or 'mvnrnd' function?</p><p>Thank you in advance!</p>paaschttp://nl.mathworks.com/matlabcentral/profile/authors/6210057-paasctag:nl.mathworks.com,2005:Question/1949522015-03-28T01:12:46Z2015-03-28T01:12:46ZSky plot in matlab<p>Hi,
I'm trying to plot sky plot in Matlab. I have all the required data i.e azimuth angle and the elevation angle but I'm not able to plot it properly. My azimuth and elevation is in radians.
I'm plotting polar(azimuth,elevation) but the desired plot is not coming. Can someone help me with this?</p><p>Thanks,
Swarnava Pramanik</p>Swarnava Pramanikhttp://nl.mathworks.com/matlabcentral/profile/authors/6096011-swarnava-pramaniktag:nl.mathworks.com,2005:Question/1949492015-03-28T00:39:50Z2015-03-28T01:11:55Zx0=0 ,x1=0.05 and x2=0.1 of[0,0.1] and f(x)=e^2x .... find the cubic spline s whith clamped boundary conditions that interpolates f in matlab .. I need solve that<p>x0=0 ,x1=0.05 and x2=0.1 of[0,0.1] and f(x)=e^2x .... find the cubic spline s whith clamped boundary conditions that interpolates f
Solve in matlab</p>Fatimah abdulrahmanhttp://nl.mathworks.com/matlabcentral/profile/authors/6311049-fatimah-abdulrahmantag:nl.mathworks.com,2005:Question/1949502015-03-28T01:05:24Z2015-03-28T01:09:55ZHow to maintain original indexing while applying multiple constraints?<p>I'm trying to identify the elements of a vector that meet several different inequality constraints. For a variety of reasons I can't apply all constraints in a single step.</p><p>I'm trying to accomplish this by finding all the elements that satisfy the first inequality, then attempting to evaluate ONLY those elements against the second inequality, and so forth. The problem is that I need to maintain a reference to the original vector's indexing. I'm attempting it like this:</p><p>Ans1 = find(X > 0)</p><p>Ans2 = find(X(Ans1) < 10)</p><p>Let's say X is a 100 element column vector and Ans1 = [1; 3; 5; 7; 9].</p><p>Then when I evaluate X(Ans1) < 10 I lose the indices of the original matrix that meet both conditions, because X(Ans1) is a 5x1 vector rather than a 'sparse' 100x1 vector containing only the elements that met the first constraint.</p><p>Is there a simple way to go about doing this? I understand for this example there are simple ways (find 0 < X < 10) but I have to apply the constraints separately, and need to only consider elements of my original vector that meet 'previous' constraints.</p><p>Any help is appreciated,
Thanks.</p>John Doehttp://nl.mathworks.com/matlabcentral/profile/authors/6340997-john-doetag:nl.mathworks.com,2005:Question/1948912015-03-27T16:01:08Z2015-03-28T00:40:59ZTrascendent equation with fsolve<p>I have the following <b>trascendent equation</b> :</p><p>(k2+k3)*sin((k2+k3)*L/2)-(k2-k3)*sin((k2-k3)*L/2)</p><p>If k2=sqrt(2*m*(E-Vi1))/hb and k3=sqrt(2*m*(E+Vi2))/hb it would be</p><p>((sqrt(2*m*(E-Vi1))/hb)+(sqrt(2*m*(E+Vi2))/hb))*sin(((sqrt(2*m*(E-Vi1))/hb)+(sqrt(2*m*(E+Vi2))/hb))*L/2)-((sqrt(2*m*(E-Vi1))/hb)-(sqrt(2*m*(E+Vi2))/hb))*sin(((sqrt(2*m*(E-Vi1))/hb)-(sqrt(2*m*(E+Vi2))/hb))*L/2)=0;</p><p>How can i find the zeros of this equation (all the function is only function of E, the rest are parameters?</p><p>Should i give numeric values to Vi1 Vi2 m hb etc or could i do it as a simbylic computation?</p><p>How could i do it in eah case?</p>Daniel Lagartohttp://nl.mathworks.com/matlabcentral/profile/authors/6339939-daniel-lagartotag:nl.mathworks.com,2005:Question/1949472015-03-28T00:17:26Z2015-03-28T00:29:54ZHow to get my code to define variables<p>Hi, I've written a quick piece of code which is the following:</p><pre class="language-matlab">function [Delta, theta, theta1, theta1prim, theta2prim, theta2] = mindeviation(n, A)
</pre><pre class="language-matlab">n0 = 1;
Delta = asin(n/n0 * sin(A/2))*2 - A;
theta = (Delta + A)/2;
disp(['Minimum deviation is ' num2str(Delta) ' radians or ' num2str(Delta*180/pi) ' degrees.'])
disp(['The angle of incidence is ' num2str(theta) ' radians or ' num2str(theta*180/pi) ' degrees.'])
</pre><pre class="language-matlab">theta1 = linspace(0,pi/2);
theta1prim = (asin(sin(theta1)/n));
theta2prim = (A-theta1prim);
theta2 = (asin(n*sin(theta2prim)));
Delta2 = theta1 + theta2 - theta1prim - theta2prim;
</pre><pre class="language-matlab">plot(theta1*180/pi,Delta2*180/pi)
xlabel('Angle of incidence (deg)')
ylabel('Angle of deviation (deg)')
xlim([0 90])
ylim([10 45])
</pre><p>I want it to define Delta, theta, and so on in Matlab when I run it but it doesn't for some reason so I figured I must be missing something important, but I can't find it whatever I try. Can anyone help me how to fix it? Thanks a lot for your time.</p>Marcushttp://nl.mathworks.com/matlabcentral/profile/authors/5855970-marcustag:nl.mathworks.com,2005:Question/1949382015-03-27T21:43:02Z2015-03-28T00:21:26ZPlot Matrix Matlab at even spaces<p>I have a matrix A = [1000,1000] and i need to plot it at even spaces</p><pre> Ex: The x axis have 1000 spaces from 1 to 1000.
The y axis have 1000 spaces from 0.5 to 500</pre><p>the numbers on matrix A represent the position of each point in the z axis</p><p>For the first element of A there should be a point</p><pre> (1,0.5,{1,1})</pre><p>and thereafter...</p><pre> (1,0.5,{1,1}) (1,1,{1,2}) (1,1.5,{1,3})...
(2,0.5,{2,1}) (2,1,{2,2}) (2,1.5,{2,3})...
(3,0.5,{3,1}) (3,1,{3,2}) (3,1.5,{3,3})...</pre><p>In the end i would have a graphic containing 10^6 points</p>Matheus Nuneshttp://nl.mathworks.com/matlabcentral/profile/authors/6340749-matheus-nunestag:nl.mathworks.com,2005:Question/1949452015-03-27T23:42:53Z2015-03-28T00:05:12Zcorrupted excel 2007 file<p>Hello folks,</p><p>The built-in repair option excel 2007 has isn't working either.</p><p>The whole "save as another file type" thing seems to be, but works since I can't open the file.</p><p>I've opened the filed on WordPad, and it was just an abracadabra. Saving it to another format just reproduced sad abracadabra.</p><p>I've even downloaded some of the programs that claim to restore corrupted excel files, but no effect.</p><p>There are two hours for every day for the whole month, I worked with the file...</p><p>I keep getting the an error: "Excel cannot open the file "filename.xlsx" because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file."</p><p>I have no idea how to fix it?</p><p>Thanks folks...</p>Carlos Antuneshttp://nl.mathworks.com/matlabcentral/profile/authors/6340913-carlos-antunestag:nl.mathworks.com,2005:Question/1949462015-03-27T23:49:46Z2015-03-27T23:49:46ZWhy am I getting the error: Simulink Coder Fatal: Can not select ERT option 'Suppress error status in real-time model data structure' when selecting ERT option 'External mode'<p>I am trying to run the generated software interface model from the HDL workflow advisor on a Zedboard. When I attempt to run in external mode I get the following error copied from the Diagnostic Viewer:</p><pre class="language-matlab">### Generating code into build folder: E:\Projects\SPIcontroller\work\gm_SPI_controller_interface_ert_rtw
### Invoking Target Language Compiler on gm_SPI_controller_interface.rtw
### Using System Target File: C:\Program Files\MATLAB\R2015a\rtw\c\ert\ert.tlc
### Loading TLC function libraries
.
**** - TLC Function Traceback ****
C:\Program Files\MATLAB\R2015a\rtw\c\tlc\lib\utillib.tlc:LibReportFatalError(1179)
C:\Program Files\MATLAB\R2015a\rtw\c\tlc\mw\setuplib.tlc:SLibSetupLayoutOptions(792)
C:\Program Files\MATLAB\R2015a\rtw\c\tlc\mw\commonsetup.tlc(101)
**** - END TLC Function Traceback ****
</pre><pre class="language-matlab">### Build procedure for model: 'gm_SPI_controller_interface' aborted due to an error.
</pre><pre class="language-matlab">Error: File: C:\Program Files\MATLAB\R2015a\rtw\c\tlc\lib\utillib.tlc Line: 1179 Column: 8
%exit directive: Simulink Coder Fatal: Can not select ERT option 'Suppress error status in real-time model data structure' when selecting ERT option 'External mode'
</pre>Dave Walterhttp://nl.mathworks.com/matlabcentral/profile/authors/3378692-dave-waltertag:nl.mathworks.com,2005:Question/1949432015-03-27T23:14:57Z2015-03-27T23:45:06Z1-D digital filter runtime<p>Quick question - Is there any computational savings to padding input arrays for the filter function to a power of 2?</p>Peter Cookhttp://nl.mathworks.com/matlabcentral/profile/authors/1035009-peter-cooktag:nl.mathworks.com,2005:Question/1949152015-03-27T18:22:03Z2015-03-27T23:45:03ZMatlab coder and exponentiation<p>I'm sure there is a way to get matlab coder to do
A = B ^ C
where all A, B and C are scalers, but for the life of me, I'm just not seeing it.</p><p>Every way I try and express it ends up with the error "Matrix power is not supported for code generation."</p><p>A = B(1) .^ C(1) isn't getting me where I want to go.</p><p>I can do it in C. I can do it in Matlab, I just can't get Matlab to do it in C.</p>David Shorthttp://nl.mathworks.com/matlabcentral/profile/authors/1310567-david-shorttag:nl.mathworks.com,2005:Question/1827102015-03-12T00:38:16Z2015-03-27T22:49:07ZCreating a matrix after giving initial conditions<p>Hi,</p><p>I need to create a matrix when given the begin year, month, day, time and end year, month, day and time.</p><p>for example; (I do not need to see the header in the matrix)</p><p>I would like to enter:</p><pre class="language-matlab">begin year = 1998
begin month = 1
begin day = 1
begin time = 0
end year = 1998
end month = 2
end day = 15
end time = 12
(as shown in the table below)
</pre><p>But, if I enter leap years (e.g. 2000,2004, etc) it should include Feb 29 and do the same time steps (0 to 21) as shown in the table.</p><p>Then, the program should generate the output for the time periods given above. See the sample below.</p><pre class="language-matlab">Year Month Day Time
1998 1 1 0
1998 1 1 3
1998 1 1 6
1998 1 1 9
1998 1 1 12
1998 1 1 15
1998 1 1 18
1998 1 1 21
1998 1 2 0
.
.
.
1998 2 15 12
</pre><p>Any help is appreciated.</p><p>Thanks in advance.</p>Damithhttp://nl.mathworks.com/matlabcentral/profile/authors/5131512-damithtag:nl.mathworks.com,2005:Question/1948632015-03-27T12:25:07Z2015-03-27T22:34:07ZError when trying to install PottersWheel<p>I am attempting to install PottersWheel for Matlab and I keep running into the following error:</p><p>Problem detected at 2015-03-27 12:18:54:
Error using mex
Cannot compile both C and FORTRAN source files in a single call to MEX.</p><p>Line 347 of pwCompileFortranIntegrators.p
Line 70 of pwInstall.p
Matlab 2015a (mexw64) PottersWheel 3.1.2
-------------------------------------------</p><p>I have installed C++ and am using 'Microsoft Visual C++ 2013 Professional (C)' via the 'mex -setup command'. Does anybody know the problem?</p>Ciaranhttp://nl.mathworks.com/matlabcentral/profile/authors/5207596-ciarantag:nl.mathworks.com,2005:Question/1948712015-03-27T13:19:15Z2015-03-27T22:28:56ZSetting Variable Text Based on Radio Button<p>I want to have 4 variations of the same format to display 4 sections of predefined text when a radio button is pushed. How would I do this?</p>Declan Simonshttp://nl.mathworks.com/matlabcentral/profile/authors/6338464-declan-simonstag:nl.mathworks.com,2005:Question/1844382015-03-22T09:34:27Z2015-03-27T22:15:15ZIs mapstd the same as Zcore ? what is the reverse function?<p>Hi All</p><p>for my work , I should apply zcore to my target matrix , that is a 4x1055 matrix , the zcore I apply is like :</p><pre class="language-matlab">[ tc meanT stdT] = zscore(tc)
</pre><p>and for rolling back I do :</p><pre class="language-matlab">an = meanT + stdT'* an';
</pre><p>I just wanted to know if the mapstd works the same and if the above is correct ?</p><p>thank you very much</p>farzadhttp://nl.mathworks.com/matlabcentral/profile/authors/2231846-farzadtag:nl.mathworks.com,2005:Question/1948882015-03-27T15:50:40Z2015-03-27T22:13:10Zhow to open multiple image,processing the image then save it into a folder?<p>my code as below,
file = dir('C:\Users\doey\Desktop\New folder');
file = file(~[file.isdir]); NF = length(file);
for k = 1 : NF
Img = imread(fullfile('C:\Users\doey\Desktop\New folder', file(k).name));
%Processing the image
%obatain figure(k)</p><p>print(figure(k),'-dpng','C:\Users\doey\Desktop\New folder (2)')
close(gcf)
end</p><p>Anyone can answer me this 2 question:
1)the figures which i obtain not saving in my directory (C:\Users\doey\Desktop\New folder) although I can show it during my processing .
2)i cannot load tiff images with this code.. why???</p>inter stellerhttp://nl.mathworks.com/matlabcentral/profile/authors/6167614-inter-stellertag:nl.mathworks.com,2005:Question/1949402015-03-27T22:03:58Z2015-03-27T22:05:00Zwhat is the alternative of imageSet function of MATLAB 2014a in MATLAB 2013a?<p>I want to perform the following function in MATLAB 2013a.
faceDB = imageSet('folderName','recursive');
figure;
montage(faceDB(1).ImageLocation);
the above code can run in MATLAB 2014a and above, because the imageSet function is included in MATLAB 2014a image processing toolbox but not in MATLAB 2013a's.</p>ALI MEHMOODhttp://nl.mathworks.com/matlabcentral/profile/authors/6254056-ali-mehmoodtag:nl.mathworks.com,2005:Question/1843172015-03-21T09:59:24Z2015-03-27T22:02:53ZNeural Network Toolbox - Backpropagation stopping criteria<p>I am using Neural Network Toolbox to classify a data of 12 alarms into 9 classes with one hidden layer containing 8 neurons. I wanted to know:</p><ol><li>What equations does training algorithm <a href = "http://www.mathworks.com/help/nnet/ref/traingdm.html">traingdm</a> use to update the weights and bias? Are these the same as given below (etta is learning rate i.e. 0.7 and alpha is momentum coefficient i.e. 0.9):</li></ol><img src = "/matlabcentral/answers/uploaded_files/27583/Capture.PNG"><p>where delta_j for output layer is:</p><img src = "/matlabcentral/answers/uploaded_files/27584/Capture.PNG"><p>while for hidden layer it is:</p><img src = "/matlabcentral/answers/uploaded_files/27585/Capture.PNG"><p>These equations are taken directly from the paper attached.</p><p>2. What does the stopping criteria net.trainParam.goal mean? Which field to update if I want my stopping criteria to be mean square error equal to 0.0001? Do I need to update net.trainParam.min_grad to 0.0001 for this?</p><p>3. How are the weights being updated in traingdm? Is it batch updation (like after every epoch) or is it updation after every input pattern of every epoch?</p><p>4. I have 41 training input patterns. How many of those are use for training process and how many for recall process. What if I want all 41 of them to be used only for training process?</p><p>5. I have tried the following code but the outputs are not being classified accurately.</p><pre> clear all; close all; clc;
p = [
1 0 0 0 0 0 0 0 0 0 0 0; ... %c1
1 0 1 0 0 0 0 0 0 0 0 0; ...
1 0 1 1 0 0 0 0 0 0 0 0; ...
1 0 1 0 1 0 0 0 0 0 0 0; ...
1 0 1 0 0 0 0 0 0 1 0 0; ...
1 0 1 1 1 0 0 0 0 0 0 0; ...
1 0 1 0 1 1 0 0 0 1 0 0; ...
1 0 1 0 1 0 0 0 0 1 0 0; ...
1 0 1 1 0 0 0 0 0 1 0 0; ...
1 0 1 0 1 1 1 0 0 0 0 0; ...
1 0 1 0 1 1 0 1 0 0 0 0; ...
1 0 1 1 1 0 0 0 0 1 0 0; ...
0 1 0 0 0 0 0 0 0 0 0 0; ... %c2
0 0 0 0 0 0 0 0 0 0 0 0; ...
0 0 0 1 0 0 0 0 0 0 0 0; ...
0 0 0 0 1 0 0 0 0 0 0 0; ...
0 0 0 0 0 0 0 0 0 1 0 0; ...
0 0 0 1 1 0 0 0 0 0 0 0; ...
0 0 0 0 1 1 0 0 0 1 0 0; ...
0 0 0 0 1 0 0 0 0 1 0 0; ...
0 0 0 1 0 0 0 0 0 1 0 0; ...
0 0 0 0 1 1 1 0 0 0 0 0; ...
0 0 0 0 1 1 0 1 0 0 0 0; ...
0 0 0 1 1 0 0 0 0 1 0 0; ...
0 0 0 1 0 0 0 0 0 0 0 0; ... %c3
0 0 0 0 1 0 0 0 0 0 0 0; ... %c4 or c5
0 0 0 0 1 1 0 0 0 0 0 0; ...
0 0 0 0 1 1 1 0 0 0 0 0; ...
0 0 0 0 1 1 0 1 0 0 0 0; ...
0 0 0 0 0 1 0 0 0 0 0 0; ... %c6
0 0 0 0 0 1 1 0 0 0 0 0; ...
0 0 0 0 0 1 0 1 0 0 0 0; ...
0 0 0 0 0 0 0 1 0 0 0 0; ... %c7
0 0 0 0 0 0 0 0 1 0 0 0; ... %c8
0 0 0 0 0 0 0 0 0 0 1 0; ...
0 0 0 0 0 0 0 0 1 1 0 0; ...
0 0 0 0 0 0 0 0 0 0 1 1; ...
0 0 0 0 0 0 0 0 1 0 1 0; ...
0 0 0 0 0 0 0 0 0 0 0 1; ... %c9
0 0 1 0 0 0 0 0 0 0 0 0; ... %c1 or c2
0 0 0 0 0 0 0 0 0 1 0 0; ... %c1 or c2 or c3
]';
t = [
1 0 0 0 0 0 0 0 0; ...
1 0 0 0 0 0 0 0 0; ...
1 0 0 0 0 0 0 0 0; ...
1 0 0 0 0 0 0 0 0; ...
1 0 0 0 0 0 0 0 0; ...
1 0 0 0 0 0 0 0 0; ...
1 0 0 0 0 0 0 0 0; ...
1 0 0 0 0 0 0 0 0; ...
1 0 0 0 0 0 0 0 0; ...
1 0 0 0 0 0 0 0 0;...
1 0 0 0 0 0 0 0 0; ...
1 0 0 0 0 0 0 0 0; ...
0 1 0 0 0 0 0 0 0; ... %c2
0 1 0 0 0 0 0 0 0; ...
0 1 0 0 0 0 0 0 0; ...
0 1 0 0 0 0 0 0 0; ...
0 1 0 0 0 0 0 0 0; ...
0 1 0 0 0 0 0 0 0; ...
0 1 0 0 0 0 0 0 0; ...
0 1 0 0 0 0 0 0 0; ...
0 1 0 0 0 0 0 0 0; ...
0 1 0 0 0 0 0 0 0; ...
0 1 0 0 0 0 0 0 0; ...
0 1 0 0 0 0 0 0 0; ...
0 0 1 0 0 0 0 0 0; ... %c3
0 0 0 1 1 0 0 0 0; ... %c4 or c5
0 0 0 1 1 0 0 0 0; ...
0 0 0 1 1 0 0 0 0; ...
0 0 0 1 1 0 0 0 0; ...
0 0 0 0 0 1 0 0 0; ... %c6
0 0 0 0 0 1 0 0 0; ...
0 0 0 0 0 1 0 0 0; ...
0 0 0 0 0 0 1 0 0; ... %c7
0 0 0 0 0 0 0 1 0; ... %c8
0 0 0 0 0 0 0 1 0; ...
0 0 0 0 0 0 0 1 0; ...
0 0 0 0 0 0 0 1 0; ...
0 0 0 0 0 0 0 1 0; ...
0 0 0 0 0 0 0 0 1; ... %c9
1 1 0 0 0 0 0 0 0; ... %c1 or c2
1 1 1 0 0 0 0 0 0; ... %c1 or c2 or c3
]';
net = feedforwardnet(8,'traingdm'); %8 hidden layers and training algorithm
net = configure(net,p,t);
net.layers{2}.transferFcn = 'logsig'; %sigmoid function in output layer
net.layers{1}.transferFcn = 'logsig'; %sigmiod fucntion in hidden layer
net.performFcn = 'mse';
net = init(net);
net.trainParam.epochs = 100000; %no. of epochs are not my concern hence a large number
net.trainParam.lr = 0.7; %obtained from the paper attached
net.trainParam.mc = 0.9; %obtained from the paper attached
net.trainParam.max_fail = 100000;
net.trainParam.min_grad = 0.00015; %is this stopping criteria same as mse?
net = train(net,p,t);
view(net);</pre><p>Let me know if something else needs to be specified.
Regards.</p>Haider Alihttp://nl.mathworks.com/matlabcentral/profile/authors/6312081-haider-alitag:nl.mathworks.com,2005:Question/1949322015-03-27T20:25:40Z2015-03-27T22:02:37ZCalculating Rectangular Window FIR type filter coefficients using Convolution method<p>Please advice how to calculate Rectangular Window FIR type filter coefficients using the Convolution method with the Output Side Algorithm described in <a href = "http://www.dspguide.com/ch6/4.htm">Chapter 6</a>.</p>Sundekshttp://nl.mathworks.com/matlabcentral/profile/authors/6340609-sundekstag:nl.mathworks.com,2005:Question/1830962015-03-14T06:58:01Z2015-03-27T21:54:28ZHelp regarding Image Segmentation of B/W Image!!<p>Hello!
I am working on a project titled 'Yarn Hairiness determination using Image Processing'. The steps involved are- Image processing and Image analysis. In the processing, I converted the image to B/W. After that I am suppose to segment the core yarn from the its protruding fibres. I am stuck here. I have attached the the picture below. It would be a big help!</p>Samkit Muttahttp://nl.mathworks.com/matlabcentral/profile/authors/6253158-samkit-muttatag:nl.mathworks.com,2005:Question/1949332015-03-27T20:57:43Z2015-03-27T21:37:35Zsolving integral equation system for 3 unknowns<p>Hi guys,</p><p>I need to solve integral equations : The equations are kutta, lateral, angular. Unknons are h4, theta4, c13. I used brute force algorithm. but it gives me error. I assume the error comes from integral upper bouns being x!!</p><pre class="language-matlab">beta1=0.2;
alphabar=-0.1;
theta4range=-1:0.1:4;
h4range=0:0.1:1;
c13range=-1:0.1:1;
% c23=-c13;
rmass=1.0;
rmomi= 2.0;
</pre><pre class="language-matlab">a = 0.1;
x=linspace(0,1,101);
thickness= a*sin(pi*x);
</pre><pre class="language-matlab">eps=0.01;
hassolution=0;
</pre><pre class="language-matlab">for theta4=theta4range
for h4=h4range
for c13=c13range
% syms x;
H0=@(x) 1/(2*(1-thickness));
H14 =@(x)(-h4-theta4.*(x-1/2));
H24 =@(x)(h4 + theta4.*(x-1/2));
u13=@(x)1./H0 *( -4 * integral(H14,0,x) +c13);
u23=@(x)1./H0 *(-4 * integral(H24,0,x) -c13);
velocitydifference= @(x)1./H0 * (-4 * integral(H24,0,x) -c13)- ...
(1./H0 * (-4 * integral(H14,0,x) +c13)) ;
p12 = @(x) -3 * integral(u13,0,x);
p22 = @(x) -3 * integral(u23,0,x);
pressuredifference=@(x) -3 * integral(u23,0,x) - (-3 * integral(u13,0,x));
kutta = 3 * integral(velocitydifference,0,1)+beta1*alphabar;
lateral = integral(pressuredifference,0,1)-12*rmass*h4;
angular = integral((x-1./2).*(pressuredifference),0,1)-12*rmomi*theta4;
</pre><pre> if abs(kutta)<eps && abs(lateral)<eps && abs(angular)<eps
c13
theta4
h4
hassolution=1;
end
end
end
end
if ~hassolution
disp('No solution');
end</pre>Mevahttp://nl.mathworks.com/matlabcentral/profile/authors/4934134-mevatag:nl.mathworks.com,2005:Question/1949372015-03-27T21:37:19Z2015-03-28T02:33:44ZCan Matlab plot a 1st-order ODE that has initial conditions at two values of t? f'(t) = f(2t)<p>I'm trying to plot a function defined as a first-order Ordinary Differential Equation (ODE), which looks deceptively simple, but has been difficult to analyze. It is simply:</p><pre class="language-matlab">f'(t) = f(2t), where
f(0) = 0
</pre><p>Thus,</p><pre class="language-matlab">f'(0) = f(0) = 0
</pre><p>As defined above, there exists a trivial solution: f(t) = 0. And for a "sufficiently smooth" function, there is exactly one solution. Apparently, I am not looking at a smooth function. I want a solution that also meets the following conditions:</p><pre class="language-matlab">f(2) = 1
f'(2) = 0
</pre><p>It follows that</p><pre class="language-matlab">f'(1) = f(2) = 1
</pre><p>Due to the function's symmetry,</p><pre class="language-matlab">f(1) = 0.5
</pre><p>It follows from this that</p><pre class="language-matlab">f'(0.5) = f(1) = 0.5
</pre><p>In studying Matlab's ODE solvers, it appears that it calculates each new iteration N from the value of iteration N-1 (or in the case of ode113, from multiple previous iterations). Thus, I don't see how the solver can take into account the values at t=2.</p><p>There is a theorem (I forget the name) that states that if all the derivatives of a function are known at some time t0, and all the function's derivatives are finite over an interval that contains time t0, then the function is completely defined over that interval. In the case of this function, f'(t) = f(2t), and f(0) = 0. So 0 = f'(0) = f''(0) = f'''(0) and so on: all higher derivatives at t=0 are zero, and the function is simply f(t) = 0. However, this function as I am defining it does not satisfy the conditions of the above theorem because the derivatives at times other than t=0 approach infinity as the order of the derivatives approach infinity. Nevertheless, the function is continuous in all its derivatives and has a very smooth, simple and elegant shape (see attached figure, created in Excel). The reason why I want to plot the function in Matlab is to verify that the function I cumbersomely generated in Excel is indeed the function f'(t) = f(2t).</p><p>NOTE: This function appears to be periodic, but is not. Also, if the function can be defined over the interval 0 <= t <= 1, it can be easily extrapolated to any value of t.</p>Jim Hoffhttp://nl.mathworks.com/matlabcentral/profile/authors/6322041-jim-hofftag:nl.mathworks.com,2005:Question/1838602015-03-18T17:00:53Z2015-03-27T21:25:43ZWhat´s wrong with my neural network´s training?<p>Dear all,</p><p>I have this code for training neural network (type newff) and MATLAB is almost all day busy, but nothing happens (no training newff). Does anyone know, where is the mistake?</p><pre class="language-matlab">load ('trenovaci_modely2_stredni')
D = [stredni_tvar{1,:}];
F = [stredni_tvar{2,:}];
net_stredni_MLP = newff(D,F,20);
net.trainparam.epochs = 100;
net = train(net_stredni_MLP,D,F);
D = stredni_tvar{1,7};
J = sim(net_stredni_MLP,D);
save net_stredni_MLP
disp('Neuronová síť byla uložena')
Thank you for your answers.
</pre>Veronikahttp://nl.mathworks.com/matlabcentral/profile/authors/5886404-veronikatag:nl.mathworks.com,2005:Question/1949352015-03-27T21:19:13Z2015-03-27T21:19:13Ztime-triggered CAN simulation<p>Hi everyone,</p><p>I would like to build a model to test my time-triggered CAN communication. so for example I got 3 messages and I would like to transmit them in such way: message 1 transmit a 2.5s; message 2 transmit at 3.5s; message 3 transmit at 4.5s. overall their period is 5s (like message 1 is been transmitted at 2.5s, 7.5s and so on).</p><p>so I use 3 CAN transmitting blocks and set their period as 5s. now how can I change the time offset so the transmission time sync with my message?</p><p>and also, how can I execute simulation in real time?</p>Ruoshi Zhanghttp://nl.mathworks.com/matlabcentral/profile/authors/6279221-ruoshi-zhangtag:nl.mathworks.com,2005:Question/1839352015-03-19T03:40:37Z2015-03-27T21:18:46ZHow to generate initial weights for back-propagation neural network (BPNN) using MATLAB R2012a?<p>I am trying to predict future values using BPNN, with 1 input and output neuron respectively and also 1 layer of hidden layer. And I change the number of hidden neurons from 2 to 10.
For example, I set the number of hidden neurons (N) as 10 first. So, I want to generate the weights (10 weights from input to hidden, and 10 from hidden to output),and I write this:</p><p>s=rng;
m=rand(10,2)</p><p>Is this the correct way? However, when I change the N to 7, it gives me the same predicted values as N=10.</p>soo rachaelhttp://nl.mathworks.com/matlabcentral/profile/authors/6303923-soo-rachaeltag:nl.mathworks.com,2005:Question/1949142015-03-27T18:09:15Z2015-03-27T21:06:12ZHow to search a string with multiple rows for text?<p>Hello, After running seq=getgenpept('NP_036795'); . I want to search seq.Features for some text value 'Protein' . I have been unable to find the correct function to search a string with multiple rows.</p><p>Running: k=strfind(seq.Features,'Protein') results with "Error using strfind. Input strings must have one row."</p><p>Any thoughts? Best, Joe</p>Joseph Esquibelhttp://nl.mathworks.com/matlabcentral/profile/authors/6340217-joseph-esquibeltag:nl.mathworks.com,2005:Question/1946472015-03-27T02:10:56Z2015-03-27T20:55:41ZHow to compute sensitivity analysis in neural network model?<p>How to compute sensitivity analysis in neural network model?
I would like to find the level of importance of each input.</p><p>Input value is 12x1505 double.
Target value is 1x1505 double.</p><p>Here is my code:</p><pre class="language-matlab">x = Input';
t = Target';
trainFcn = 'trainlm';
hiddenLayerSize = 3;
net = feedforwardnet(hiddenLayerSize,trainFcn);
net.input.processFcns = {'removeconstantrows','mapminmax'};
net.output.processFcns = {'removeconstantrows','mapminmax'};
</pre><pre> net.divideFcn = 'divideind';
net.divideParam.trainInd = 1:903;
net.divideParam.valInd = 904:1204;
net.divideParam.testInd = 1205:1505.
net.performFcn = 'mse';
[net,tr] = train(net,x,t);
y = net(x);
e = gsubtract(t,y);
performance = mse(net,t,y)
trainTargets = t .* tr.trainMask{1};
valTargets = t .* tr.valMask{1};
testTargets = t .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,y)
valPerformance = perform(net,valTargets,y)
testPerformance = perform(net,testTargets,y)
view(net)</pre><p>Thank you very much</p><p>Janthorn</p>Janthorn Sinthupundajahttp://nl.mathworks.com/matlabcentral/profile/authors/6296692-janthorn-sinthupundajatag:nl.mathworks.com,2005:Question/942722012-05-03T16:34:00Z2015-03-27T20:55:33ZHow do I constrain a fitted curve through specific points like the origin in MATLAB?<p>I would like to use the POLYFIT function or the Curve Fitting Toolbox to impose linear constraints on fitted curves to force them to pass through specific points like the origin.</p>MathWorks Support Teamhttp://nl.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-team