https://www.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2016-07-28T07:15:55Ztag:www.mathworks.com,2005:Question/2974792016-07-28T06:38:21Z2016-07-28T07:15:55ZOut of memory error while using eye function.<p>Dear Sir/Madam,
I am getting Out of memory error while allocating an array(214748 x 314748 x 4) of size 270366014016 bytes or 270G</p><pre> >> C=eye(214748,314748);
Error using eye
Out of memory. Type HELP MEMORY for your options</pre><p>i have approx 500G memory on my 64 bit machine and i had >400G free when i was trying to allocate.</p><pre class="language-matlab">free -g
total used free shared buffers cached
Mem: 504 58 445 0 0 46
-/+ buffers/cache: 11 493
Swap: 7 0 7
</pre><p>Out of memory. Type HELP MEMORY for your options</p><pre class="language-matlab">ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 4133744
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) unlimited
cpu time (seconds, -t) unlimited
max user processes (-u) 1024
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
</pre><p>Why this allocation failed?</p><p>Are there some default upper limits?</p><p>can i override them?</p>puneet singhhttps://www.mathworks.com/matlabcentral/profile/authors/8467428-puneet-singhtag:www.mathworks.com,2005:Question/2974842016-07-28T07:14:21Z2016-07-28T07:14:21Zhow can i renew license(3172874) ?plz hep me<p>i want to renew my license for matlab.plz hep me as soon as possible.</p>nisha budhwarhttps://www.mathworks.com/matlabcentral/profile/authors/8372942-nisha-budhwartag:www.mathworks.com,2005:Question/1557452014-09-22T07:24:34Z2016-07-28T07:13:03ZImage Encryption using RSA<p>I am trying to encrypt an image using RSA algorithm</p><pre class="language-matlab">inImg = imread('lena.jpg');
s = size(inImg);
</pre><pre class="language-matlab">% Encryption:
enImg = ones(s);
for i = 1:s
enImg(i)= i_encrypt(inImg(i),n,e);
end
</pre><pre class="language-matlab">% Function:
function en = i_encrypt(in,n,e)
en=1;
for i=e:-1:1
en=rem(en*in,n);
end
</pre><p>Here n is the modulus, e is the key</p><p>However after all these steps all the pixels have the value of 1. Even if the value isn't one, the displayed image is an all white image.
Can u please tel me where I have gone wrong.</p>Anisha Coelhohttps://www.mathworks.com/matlabcentral/profile/authors/5647217-anisha-coelhotag:www.mathworks.com,2005:Question/2974832016-07-28T07:09:34Z2016-07-28T07:09:34ZI want to prediction using NARX network<p>example) inputs are 5x3000[2016.06.1~06.30] variable = x1,x2,x3,x4,x5
output is 1x3000[2016.06.1~06.30] variable = y1
additionally, i want to put 06.01~06.30 x1,x2,x3,x4,x5 and 07.01 x2 variable
so i want to prediction y1 [2016.07.01]
what can i do!?</p>ryuddohttps://www.mathworks.com/matlabcentral/profile/authors/8236008-ryuddotag:www.mathworks.com,2005:Question/2973272016-07-27T06:34:44Z2016-07-28T07:07:29Zidentifying objects in a picture containing several objects_2<p>I have a picture that contains more obiecte.Obiectele I have separated into smaller pictures (cut from full size) must make a sequence of code that I find an object and make a circle around him.
This subject had been opened 21 Dec 2011 as a 'identifying objects in a picture containing several objects'. I want to to know if we try to find same object in image more than one and different rotation how can we do? For example there is three same object in image with different places,also 2 of them vertical and last one horizontal. Can we identify with same method under 'identifying objects in a picture containing several objects' topic?
Below 'img.jpg' original image and 'img2/3/4.jpg' objects which need to be founded. How can i find all objects same as img2/3/4?</p><img src = "/matlabcentral/answers/uploaded_files/56778/img.jpg"><img src = "/matlabcentral/answers/uploaded_files/56779/img2.jpg"><img src = "/matlabcentral/answers/uploaded_files/56780/img3.JPG"><img src = "/matlabcentral/answers/uploaded_files/56781/img4.JPG">Ahmet Ipekhttps://www.mathworks.com/matlabcentral/profile/authors/8470774-ahmet-ipektag:www.mathworks.com,2005:Question/499062012-10-04T19:22:36Z2016-07-28T07:04:49ZHow to calculate PSNR of compressed images, and how to compare PSNR of images compressed by two different techniques.<p>I have to compare image compression techniques like VQ, JPEG, WAVELET, and fractal. For this, the parameter to be compared is PSNR. Please tell me how I can calculate PSNR OF AN IMAGE which is COMPRESSED by different compression techniques. plz explain with example.</p>akanksha sharmahttps://www.mathworks.com/matlabcentral/profile/authors/3599480-akanksha-sharmatag:www.mathworks.com,2005:Question/2972882016-07-26T20:39:41Z2016-07-28T07:01:12ZI need a code to solve this problem<p>The budget to be shared is 40.5;
The participant initially gets the following amount</p><pre class="language-matlab">v1= 7;
v2=10.5
v3= 13
v(1,2)= 28
v(1,3)=28
v(2,3)=28
v(1,2,3)=40.5
</pre><p>v1,v2 and v3 should get an amount greater 7, 10.5,13 respectively and the total should be equal to 40.5</p><p>At the same time the this conditions should be satisfied as well v1+v2 >=28 ; v1+v3 >=28 ; v2+v3 >=28</p>Jeffrey Eiyikehttps://www.mathworks.com/matlabcentral/profile/authors/7113348-jeffrey-eiyiketag:www.mathworks.com,2005:Question/2974822016-07-28T06:55:11Z2016-07-28T07:01:29Zhow to retrieve value from look up table without passing the entire array points as in interp1<p>favorite</p><p>I have a function in which a look up table is created. LUT has some random x points and corresponding Y values. Now I have another function which uses a loop to find exact X point say xq. In each loop I also need to find the corresponding Y value (yq) by <b>passing only the current Xq</b> to another function which should interpolate and obtain Yq value in case Xq value is not found in the LUT and is within limit. But I find that I have to pass the x and Y array used in LUT as well as current xq point each time in my loop if I use <b>interp1</b>. Is there any other means to <b>get Yq value without passing the entire x and y arrays</b>? I have given the structure of the code below.</p><pre class="language-matlab">func to create LUT
x = [1.8558;2.5549;3.4438;4.433;5.5271;6.5236;7.4795;8.4345;9.232;9.8256;10.4205;10.9303;11.3257;11.8103];
y = [0.0433;0.0598;0.0672;0.0749;0.0945;0.0991;0.0858;0.0857;0.0894;0.0788;0.0838;0.0815;0.0866;0.0971];
</pre><pre> main func</pre><pre> for i = 1:1:1000
expression for xq ;
call func to find yq from LUT by passing only xq ;
do something using xq and yq ;
end</pre><p>Thanks</p>Nadia Ahttps://www.mathworks.com/matlabcentral/profile/authors/8246779-nadia-atag:www.mathworks.com,2005:Question/2974812016-07-28T06:52:03Z2016-07-28T06:52:03ZHow can I plot the input function in this example? (I already got the graph of the output function)<img src = "/matlabcentral/answers/uploaded_files/56838/Capture.JPG"><p>How could I plot the input function as well for the same range of x? thanks so much.</p>Rogelio Garciahttps://www.mathworks.com/matlabcentral/profile/authors/7373464-rogelio-garciatag:www.mathworks.com,2005:Question/1275332014-04-02T04:00:00Z2016-07-28T06:49:57ZHow do I renew or extend my trial?<p>My trial is expiring or is expired. How do I extend or renew my trail or get a new one?</p>MathWorks Support Teamhttps://www.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:www.mathworks.com,2005:Question/2974802016-07-28T06:40:51Z2016-07-28T06:43:46ZC# MWMCR::EvaluateFunction error undefined function 'splinelev' for input arguments of type 'double'<p>I have created a .dll package in Matlab 2012a,the m file as follow：</p><p>function z = curveFitFunc(x,y,d)</p><p>xx = [min(x):d:max(x)];</p><p>opts = fitoptions('mtthod','smoothing');</p><p>ffunc = fittype('smoothingspline');</p><p>f = fit(x',y',ffunc,opts);</p><p>z = feval(f,xx)';</p><p>end</p><p>1.and open the deployment tool window: deploytool</p><p>2.build the .net component.</p><p>3.write source code for a C# application</p><p>I use visual studio 2010</p><p>4.build and run the application in visual studio .NET</p><p>the error is :</p><p>MWMCR::EvaluateFunction error</p><p>undefined function 'splinelev' for input arguments of type 'double'</p><p>the 'splinelev' is the MEX file in MATLAB at</p><p>'R2012a/toolbox/curvefit/curvefit/private/splinelev.mexw64'</p><p>I don't know how to solve the error, anyone can help me? thanks a lot!</p>yh ellendehttps://www.mathworks.com/matlabcentral/profile/authors/8474607-yh-ellendetag:www.mathworks.com,2005:Question/2974782016-07-28T06:38:01Z2016-07-28T06:38:01ZHi guys, How to set a ARMA model with Garch<pre> thx guys. I wonder how to set a ARMA model with 'Garch'. Anyone knows? Thank you </pre>bo wuhttps://www.mathworks.com/matlabcentral/profile/authors/2239321-bo-wutag:www.mathworks.com,2005:Question/2974692016-07-28T03:55:32Z2016-07-28T06:30:03ZTrying to check if a 3-d point is inside a triangle specified in a 3D plane<p>This is what I did:</p><p>Specified the co-ordinates of the triangle (P) and triangulated. Plotted this triangle and specified the point (B) to be checked if lying inside or outside the triangle. Used 'cartesianToBarycentric' and asked to plot only if every Barycentric co-ordinate lies between 0 and 1. The point is getting plotted even though it is evident from the plot that it lies outside.
Is there anything wrong in my understanding or does 'cartesianToBarycentric' work effectively only for 2-d points?</p><pre> % code</pre><pre class="language-matlab">P = [5 0 1; 0 5 1; 0 0 1]; %co-ordinates of the triangle
T = [1 2 3]; %indices of the points forming the triangle
TR = triangulation(T,P);
trimesh(TR);
hold on
ti = 1;
PC= [2 2 2];
B = cartesianToBarycentric(TR, ti, PC);
if (B(1,1)>=0 && B(1,2)>=0 && B(1,3)>=0 && B(1,1)<=1 && B(1,2)<=1&& B(1,3)<=1)
plot3(PC(1,1),PC(1,2),PC(1,3),'.k');
end
</pre><img src = "/matlabcentral/answers/uploaded_files/56833/Capture.JPG">Rumhttps://www.mathworks.com/matlabcentral/profile/authors/3972344-rumtag:www.mathworks.com,2005:Question/2974772016-07-28T06:13:54Z2016-07-28T06:13:54ZHow to detect two images in one background individually<p>Hello,I have a white background with 2 images in it. How can I analyze and store these two images individually? thanks.</p>Fateme Jalalihttps://www.mathworks.com/matlabcentral/profile/authors/7292066-fateme-jalalitag:www.mathworks.com,2005:Question/2974662016-07-28T03:11:45Z2016-07-28T06:10:03Zbsxfun seems to return too few values<p>In Matlab 2016a, the following command behaves as I expect:</p><pre> >> bsxfun (@(x,y)((y-x)), [1], [3, 4])
ans =
2 3</pre><p>However, this very similar command returns a scalar, instead of a 1x2 matrix:</p><pre> >> bsxfun (@(x,y)(min(y-x)), [1], [3, 4])
ans =
2</pre><p>Am I right in assuming this is a bug in bsxfun? If so, how can I report it. If not, could someone please explain this behaviour?</p>Lachlanhttps://www.mathworks.com/matlabcentral/profile/authors/5065993-lachlantag:www.mathworks.com,2005:Question/2972332016-07-26T14:10:02Z2016-07-28T06:03:51ZHow to create a 2D look-up table from vectors ?<p>Hello,</p><p>I would like to create a 2D look-up table from 3 vectors (size n x 1 each). Anyone have an idea about how could I do this please ?</p><p>First, we have in below the variation of 2 vectors (Temp, DCR) in function of vector SOC in range [0.25 - 0.9]</p><pre class="language-matlab">SOC = [0.25;0.3;0.35;0.4;0.45;0.5;0.55;0.6;0.65;0.7;0.75;0.8;0.85;0.9] ;
Temp = [1.8558;2.5549;3.4438;4.433;5.5271;6.5236;7.4795;8.4345;9.232;9.8256;10.4205;10.9303;11.3257;11.8103];
DCR = [0.0433;0.0598;0.0672;0.0749;0.0945;0.0991;0.0858;0.0857;0.0894;0.0788;0.0838;0.0815;0.0866;0.0971];
</pre><p>and Second, we have in below the variation of 2 vectors (SOC, DCR) in function of vector Temp in range [1.5 - 11.5]</p><pre class="language-matlab">SOC = [0.2222;0.2713;0.3038;0.3363;0.3605;0.3847;0.4089;0.433;0.4571;0.4811;0.505;0.5288;0.5603;0.584;0.6151;0.638;0.6695;0.7155;0.761;0.8135;0.865];
Temp = [1.5;2;2.5;3;3.5;4;4.5;5;5.5;6;6.5;7;7.5;8;8.5;9;9.5;10;10.5;11;11.5];
DCR = [0.0237;0.0582;0.0598;0.0659;0.0677;0.0843;0.0713;0.0731;0.0945;0.0777;0.0991;0.0821;0.0856;0.0892;0.0911;0.0767;0.066;0.0803;0.0684;0.0876;0.0778];
</pre><p>I want to know if it's possible, from datas above, to create a 2D look-up table of the parameter DCR in function of 2 parameters left such as SOC, Temp.</p><p>I've tried the command meshgrid and surf but it doesn't work.</p><p>Looking for your answers,
Thank you a lot</p>Tuan-Tuhttps://www.mathworks.com/matlabcentral/profile/authors/5995929-tuan-tutag:www.mathworks.com,2005:Question/2974742016-07-28T05:26:25Z2016-07-28T06:03:06ZHow to read data from the name of data (chracter)?<p>I want to read data from the name.</p><p>I used function "eval", when I want to do this past days.</p><p>But I forgot how to do it.</p><p>Would you let me know the method using "eval" or anything others?</p><p>-------------------------------------------------------------------</p><p>For example</p><p>I have five variables with size 10905 x 16, c_data1, c_data2, c_data3, c_data4 and c_data5.</p><p>I write their name using <b>"clist = whos('c_</b>');"*</p><p>and Because I have to read the five variables using for loop, I write like below.</p><pre> *for i = 1: 5
fname(i,:) = clist(i).name;
%%%%%%%%%%
end*</pre><p>In the %%%%%%%%%% line,</p><p>I'd like to divert the variable name (fname) to the variable (including the content of c_data1).</p><p>Please let me know about the clever answer.
Thank you for write my question.</p>sunmin choihttps://www.mathworks.com/matlabcentral/profile/authors/6972209-sunmin-choitag:www.mathworks.com,2005:Question/2973312016-07-27T07:25:48Z2016-07-28T05:58:27ZCompiling an m-file, which calls to python, to an exectuable<p>Hello,</p><p>I'm trying to compile a function which has an internal call to python modules.
The function runs perfectly from matlab, python is loaded, my custom python modules are loaded and everything works great.
However, when I try to compile the function (using Matlab Compiler) and run it from the command lind, it fails because python is not loaded (I've verified it by adding the "pyversion" command to the beginning of the script).
This is the output of pyversion and the next command I'm trying to issue:</p><pre class="language-matlab">version: '3.5'
executable: 'C:\Anaconda3\python.EXE'
library: 'C:\Anaconda3\python35.dll'
home: 'C:\Anaconda3'
isloaded: 0
</pre><pre class="language-matlab">Undefined variable "py" or class "py.list".
</pre><p>I've read that python is loaded by Matlab upon the first time a py.something command is issued, so I've tried a simple while loop which attempts to execute a simple py.list command until Python is loaded, but that didn't help...</p><p>Any suggestions?
Am I doing something fundamentally wrong?</p><p>Thank you in advance,
Gabi Shahmayster</p>Gabi Shahmaysterhttps://www.mathworks.com/matlabcentral/profile/authors/8205407-gabi-shahmaystertag:www.mathworks.com,2005:Question/2973612016-07-27T11:34:37Z2016-07-28T05:54:29ZGUI STANDALONE NOT WORKING WELL<p>HI,
I've created a GUI (on windows XP) which uses serial communication with an external system.
running it on my computer with the matlab installed 2012A everything works well.</p><p>run DEPLOYTOOL and entered the m file and the fig file. got a FOLDER with 2 subdolders:
distr and src. NOR SURE OF THE DIFFERENCE as they both have an EXE file</p><p>i downloaded an MCR for 2012a from mathworks and installed it on another computer.(windows 7)</p><p>launched the EXE file. connected the serial communication and when i try to use different buttons i get like an ERROR SOUND BEEP
and accordingly nothing happens...</p><p>tried it on a 3'rd computer (windows 10) same problem</p><p>any ideas?</p>Danielhttps://www.mathworks.com/matlabcentral/profile/authors/3427522-danieltag:www.mathworks.com,2005:Question/2974442016-07-27T21:13:51Z2016-07-28T05:49:35ZEfficient method for populating a matrix based on its equality with another matrix<p>Hello. I'm having a problem populating a matrix and would greatly appreciate some help.</p><p>If we have:</p><pre class="language-matlab">if true
</pre><pre> A = 10 11 3 4 B = 10 11 NaN NaN
12 11 4 6 12 11 NaN NaN
13 13 2 8 13 11 NaN NaN
end</pre><p>What I want is the following: if A(i,1:2) and B(i,1:2) are the same, then B(i,3:4) = A(i,3:4). So something like this:</p><pre class="language-matlab">if true
</pre><pre class="language-matlab">B = 10 11 3 4
12 11 4 6
13 11 NaN NaN
</pre><pre class="language-matlab">end
</pre><p>I've managed to create a loop that achieves this result. Which is the following:</p><pre class="language-matlab">if true
</pre><pre> for i = 1:length(B);
for j = 1:length(A);
if B(i,1) == A(j,1) && B(i,2) == A(j,2);
B(i,3) = A(j,3);
end
end
end</pre><pre class="language-matlab">end
</pre><p>The problem is, the two arrays I'm working with have close to 3 million rows so a double conditioned loop is extremely slow. Is there a vectorised way to achieve the same result that is significantly quicker?</p><p>Any help would be greatly appreciated.</p><p>Thanks</p><p>Andrew</p>Andrew Barndenhttps://www.mathworks.com/matlabcentral/profile/authors/6890888-andrew-barndentag:www.mathworks.com,2005:Question/2974762016-07-28T05:48:16Z2016-07-28T05:48:16Zhow to find eigenvector value of the given image?<p>Sir's</p><p>any one help me how to find eigevector value for the given image using matlab function</p><p>my problem is</p><p>i want to find 50 images eigenvector value for train the machine</p>suresh khttps://www.mathworks.com/matlabcentral/profile/authors/6227735-suresh-ktag:www.mathworks.com,2005:Question/2970312016-07-25T09:00:06Z2016-07-28T05:47:16ZHow to use 'jar' in matlab m file?<p>I have the 'jar' file and
the usage of (the classes contained in jar) in java code is like the following:</p><p>[code java]
import kr.hyosang.coordinate.*;</p><p>........</p><p>CoordPoint pt = new CoordPoint(126.97553009053178, 37.56456569639763);</p><p>CoordPoint ktmPt = TransCoord.getTransCoord(pt, TransCoord.COORD_TYPE_WGS84, TransCoord.COORD_TYPE_KTM);</p><p>[/code]</p><p>------------------------------------------------------------------</p><p>And this is my matlab code which has a problem to run.</p><p>clc; clear all;</p><p>javaaddpath('TransCoord.jar')</p><p>import kr.hyosang.coordinate.*;</p><p>CP=CoordPoint</p><p>methods(CP)</p><p>pt=CP(126.97553009053178, 37.56456569639763)</p><p>clear import</p><p>clear java</p><p>-----------------------------------------------------</p><p>I know nothing whatever about JAVA.
But the only ting I want to do is</p><p>CoordPoint pt = new CoordPoint(126.97553009053178, 37.56456569639763);</p><p>CoordPoint ktmPt = TransCoord.getTransCoord(pt, TransCoord.COORD_TYPE_WGS84, TransCoord.COORD_TYPE_KTM);</p><p>to run these two lines in my matlab code.</p>Youngyong Parkhttps://www.mathworks.com/matlabcentral/profile/authors/8461988-youngyong-parktag:www.mathworks.com,2005:Question/2974752016-07-28T05:41:13Z2016-07-28T05:42:34ZDoes MATLAB R2015a run in Ubuntu 12.04LTS?<p>I installed it and activated the license but couldn't run Matlab. All I got was the initial splash screen (with the logo) while the terminal remains blank (I ran by double clicking on matlab).
I hit ctrl-C, and the window MATLAB System Error pops up , the details report "segmentation violation detected".
Installed was using image file downloaded from MATLAB.</p>Cboonhttps://www.mathworks.com/matlabcentral/profile/authors/7930193-cboontag:www.mathworks.com,2005:Question/1344812014-06-15T06:05:42Z2016-07-28T05:37:34ZHow to combine two features HOG and LBP to get better accuracy?<p>Dear all,,</p><p>I am working on people detection with training datasets. I used two different different feature extraction, HOG and LBP. Each of them will extract 324 feature vector (HOG) and 59 feature vector (LBP) for each training image. I am currently using simple concatenation to combine bothe features and then the results will be feed into SVM classifier to be classified. However, seems like this method gives a domination to HOG.</p><p>I have tried to find out another method, which is using fusion features, yet I have no knowledge how to do the algorithm. I really need help from the expert who know about the fusion feature to combine two features.</p><p>Really thank you</p>Indrahttps://www.mathworks.com/matlabcentral/profile/authors/3553716-indratag:www.mathworks.com,2005:Question/2974672016-07-28T03:31:01Z2016-07-28T05:23:06ZHow to translate 32-bit number to float number<p>The acquired data is expressed as '6D61803F', this may be a little-endian. I translated it to '3F80616D', then I got the float number 1.002973, this was the real data!</p><p>Now I used</p><pre class="language-matlab">q = quantizer(q);
hex2num(q, '6D61803F') or hex2num(q, '3F80616D')
</pre><p>Both of those did not get the real one!</p><p>What's the problem?</p><p>Thanks</p>ANG MQhttps://www.mathworks.com/matlabcentral/profile/authors/2433049-ang-mqtag:www.mathworks.com,2005:Question/2974592016-07-28T01:20:59Z2016-07-28T05:10:50ZActxserver unable to locate Excel workbook<p>I am having issues getting the ActiveX application to open an existing Excel doc for editing.</p><p>My current code looks like:</p><pre class="language-matlab">file_name = 'Excel_Book.xlsx';
xl = actxserver('Excel.Application');
xlb = xl.Workbooks.Open(file_name);
</pre><p>This returns the error:</p><pre class="language-matlab">Error
Invoke Error, Dispatch Exception:
Source Microsoft Excel
Description: 'Excel_Book.xlsx' could not be found
</pre><p>I know that the file exists, as I can read it with</p><pre class="language-matlab">xlsread(file_name)
</pre><p>I have even changed the MATLAB directory to be seeing the folder with the Excel_Book file in it, and yet the ActiveX refuses to read the document.</p><p>Similar problems were encountered using:</p><pre class="language-matlab">xlb = xl.Workbooks.Item(file_name);
or
xlb = xl.get('Workbooks',file_name);
</pre>Parker Phillipshttps://www.mathworks.com/matlabcentral/profile/authors/7983890-parker-phillipstag:www.mathworks.com,2005:Question/2974712016-07-28T04:23:29Z2016-07-28T05:08:34ZSolve for a matrix in a generic matrix equation?<p>My past experience with MATLAB was solving for a matrix that has a simple solution (can be solved "as a whole"). For example, solving for X in AX=B is simply X=A\B assuming A is invertible.</p><p>What about solving for X in a complicated (or more generic) equation, where there is no simple solution like the one above? For example, \sum_{i=1}^{N} A_i*X'*X*A_i = B (just an illustrative example made up on the fly -- hopefully, there is no simple solution).</p><p>In this case, we need to spell out all the entries of X and form many equations to solve for each entry of X. Is there a clean way in MATLAB of doing this?</p>Eric Zhanghttps://www.mathworks.com/matlabcentral/profile/authors/5042475-eric-zhangtag:www.mathworks.com,2005:Question/2974732016-07-28T05:03:20Z2016-07-28T05:03:20ZI am getting negative time domain data using following MATLAB code ,which is used to extract FFT from time domain. Please help me out to solve this problem<pre> Hi iam attaching the matlab code for extracting frequency domain from time domain data.however after running this code i am getting negative time domain.i had attached one time domain data of sample and also image of time domain and frequency domain.I had marked it. Please help me out in solving this problem</pre><p>y= load('E:\MATLAB\time domain MATLAB\Water.m');</p><p>z=(y - 0.024);</p><p>z1=medfilt1(z,30);</p><p>subplot(2,1,1); plot(z);</p><p>xlabel ('Time(micro-sec)');
ylabel('Intensity');</p><p>z1=z(1:5000);
z1_fft=(fft(z1,5002));
z1_fft(1)=[];
lg_x=(0:4095)*5000/8192;
sum(abs(z1_fft))</p><p>subplot(2,1,2);plot(lg_x,(abs(z1_fft(1:4096))));
xlabel ('Frequency(Hz)');
ylabel('Intensity');
final_fft= (abs(z1_fft(1:4096)));</p>Raghushaker CRhttps://www.mathworks.com/matlabcentral/profile/authors/7433644-raghushaker-crtag:www.mathworks.com,2005:Question/2974722016-07-28T04:28:09Z2016-07-28T04:53:18ZMultiple Plot and saving as jpg<p>I want to have multiple plots and wants to save as jpg file separately as (i.e. 1.jpg ,2.jpg....)</p>Sadiq Shamsher Malehttps://www.mathworks.com/matlabcentral/profile/authors/7037801-sadiq-shamsher-maletag:www.mathworks.com,2005:Question/2974702016-07-28T04:17:16Z2016-07-28T04:17:16ZUsing c28x DMC library blocks for f28335 processor without fixed point designer licence<p>I have Matlab2014a embedded coder, Simulink coder and matlab coder licence. My processor is f28335 control card with docking station. Do I need fixed point designer licence to run and build the first model-task 1 given in the below link <a href = "http://www.mathworks.com/examples/embedded-coder/mw/texasinstrumentsc2000_product-publish_c2000workflow-motor-control">http://www.mathworks.com/examples/embedded-coder/mw/texasinstrumentsc2000_product-publish_c2000workflow-motor-control</a>
.I am having trouble in defining input data conversion block. Could anyone please advice,how to sort out this issue.</p><p>Thanks & Regards
Blessy J</p>blessy Johnhttps://www.mathworks.com/matlabcentral/profile/authors/6360726-blessy-johntag:www.mathworks.com,2005:Question/2970902016-07-25T16:15:58Z2016-07-28T03:54:03Zwhen I run a python module which imports ssl.py , error occurs . but it's ok to run the straight python.<p>the error information is:
Python Error: ImportError: dlopen(/Users/garyzhang/anaconda2/lib/python2.7/lib-dynload/_ssl.so, 2): Symbol not
found: _SSL_CTX_set_alpn_protos
Referenced from: /Users/anaconda2/lib/python2.7/lib-dynload/_ssl.so
Expected in: /Applications/MATLAB_R2016a.app/bin/maci64/libssl.1.0.0.dylib
in /Users/anaconda2/lib/python2.7/lib-dynload/_ssl.so</p>gary zhanghttps://www.mathworks.com/matlabcentral/profile/authors/7882414-gary-zhangtag:www.mathworks.com,2005:Question/2973872016-07-27T14:28:25Z2016-07-28T03:39:54ZHow to combine 3 videos together<p>I have three video file in .mp4 format, I want them to be played back to back or one after another. Can some body tell me how to do it. I also want to add few picture at the start of the video.</p>kintali narendrahttps://www.mathworks.com/matlabcentral/profile/authors/3404364-kintali-narendratag:www.mathworks.com,2005:Question/2974682016-07-28T03:38:50Z2016-07-28T03:38:50ZHOW TO READ A DETAIL COEFFICIENT OF DECOMPOSITION LEVEL 1<p>Hi, can anybody help me to find a sample number of coefficient as shown in figure below (green color). this is using wavelet toolboxes of multi signal analysis.</p><img src = "/matlabcentral/answers/uploaded_files/56831/coefficient.png">eddy onghttps://www.mathworks.com/matlabcentral/profile/authors/8040708-eddy-ongtag:www.mathworks.com,2005:Question/2973932016-07-27T15:07:19Z2016-07-28T03:35:14ZExtract data of different dimensions from a mixed text and data file (.inp file)<p>I have an Abaqus .inp file of mixed data dimensions and text. The data comes in either 4 or 5 columns with varying amounts of rows, with text in between to differentiate. I want to isolate all of the data and essentially remove all the text, but none of the functions I've been trying work.</p><p>The importdata function has worked the best so far, but it only isolates some of the data, not everything. I am aware of the Import Data gui, but I'd like to hard code something into my program. Any suggestions? Also, is there a way for me to tweak the importdata function,such that I can start reading the specific file from a different location instead of importing from the beginning of the file?</p>Anindita Mukherjeehttps://www.mathworks.com/matlabcentral/profile/authors/6928637-anindita-mukherjeetag:www.mathworks.com,2005:Question/2974402016-07-27T20:42:47Z2016-07-28T03:24:54ZProjection of grid data onto world map<p>Hello all,</p><p>I have grid data (spacing of grid data depends on climate model) that I would like to overlay on WorldMap,
lat[-90 90] & lon [0 360], using scatterm (proportional circle map). When I do this the projection of the data does not look correct. How can I ensure that the data I am projecting onto the World Map is correct? Thank you and I look forward to learning something new!</p>Vespi1https://www.mathworks.com/matlabcentral/profile/authors/8406199-vespi1tag:www.mathworks.com,2005:Question/2974652016-07-28T02:47:07Z2016-07-28T03:18:05ZHow could I display my input function and its indefinite first integral (their graphs as outputs) ? <img src = "/matlabcentral/answers/uploaded_files/56829/Capture.JPG"><p>Tanking in consideration that I want the range for x from -100 to 100.</p><p>Thanks so much. I appreciate it.</p>Rogelio Garciahttps://www.mathworks.com/matlabcentral/profile/authors/7373464-rogelio-garciatag:www.mathworks.com,2005:Question/2966062016-07-21T09:22:46Z2016-07-28T03:07:41ZAbout the Number property of figure function <p>How to set the Number property of figure function of 2015B?
Each time I set like this:
figure('Position', [9 39 900 300], 'Number', 3, 'Name', 'Velocity');
It was wrong but I saw the example just did like this!
Thanks1</p>ANG MQhttps://www.mathworks.com/matlabcentral/profile/authors/2433049-ang-mqtag:www.mathworks.com,2005:Question/2974632016-07-28T02:06:57Z2016-07-28T03:00:00ZHow to create an mxn matrix with a for-loop<p>Hello all,</p><p>I would like to display (x(i),y(j)) in separate columns according to the x(i)'s.</p><p>i.e.:</p><pre class="language-matlab">(0,0) (1,0) (2,0)
(0,1) (1,1) (2,1)
(0,2) (1,2) (2,2), etc.
</pre><p>I am currently using a nested for-loop to calculate all (x(i),y(j)) as follows:</p><pre class="language-matlab">for i = 1:3
a = i-1;
for j = 1:3
b = j-1;
X = [a b];
disp(X);
end
end
</pre><p>I get the output as follows:</p><pre> 0 0
0 1
0 2
1 0
1 1
1 2
2 0
2 1
2 2</pre><p>I tried using reshape to display the output as above, however in fiddling with the program, I discovered that MATLAB considers each line of output to be a separate 1x2 matrix. Do you have any suggestions as to how to get MATLAB to recognize the outputs as a 9x2 matrix? This is an extremely scaled-down version of what I need the program to do.</p><p>Thank you!!</p>Dominique Braseehttps://www.mathworks.com/matlabcentral/profile/authors/8474137-dominique-braseetag:www.mathworks.com,2005:Question/2974552016-07-28T00:06:18Z2016-07-28T02:56:25ZBest practices for large memory requirements: how to read/write to file<p>I'm trying to scale up a FEM problem that a coworker of mine developed. The way the code runs now, we open a vector of N nodes x 413 timesteps, and record the concentration for each node and time step. Previously the problem was tractable to where we could easily store all N x 413 in memory until the main function end, and then write object to file as a .mat file. However, the scale I'm looking at is much larger (~2GB per time step). It is completely unfeasible to store all time steps in memory, so I need to change the code to dump to a file instead of just store it in memory for a dump at the very end of the run.</p><p>To do this, what is a good write method? Ideally I would like to write to the same file to avoid a lot of file I/O opening/closing operations, as that is not optimized on the platform I'm working on. Instead, I'd like to open one file and write to it once per time-step. I could write one unique file to each timestep, but I feel that that would be stressful on the system. Are there any good file I/O methods which can handle writing/reading only portions of a very large file at a time? I know this is getting out of MATLAB's strengths, and we should probably move to an environment better suited to our problem, but learning a little MATLAB I/O is much easier than re-writing something that already works in a new FEM framework.</p>Ryan Woodallhttps://www.mathworks.com/matlabcentral/profile/authors/6829602-ryan-woodalltag:www.mathworks.com,2005:Question/2974582016-07-28T00:52:15Z2016-07-28T02:52:56ZDynamically loading mat files in nested loop<p>Hi, I have several mat files in different directory, the names are organized in the following manner</p><p>"Coluomb_Torque_XX_Speed_YY" where XX = 1:29 and YY=1:31;</p><p>the problem when I create a nested loop and try to load the files by their full name (including the subdirectories), I get an error regarding the index. I appreciate anyone's help</p><pre class="language-matlab">clear
clc
</pre><pre class="language-matlab">XX=1:29;
YY=1:31;
</pre><pre class="language-matlab">for q=1:length(XX)
</pre><pre> for p=1:length(YY)
ff='Coluomb_';
tt='Torque_'; % Referes to Torque Ratio step 1~(-210/200)....end ~(210/200)
uu='_Ratio_'; % Referse to Speed Ratio step 1~(7.5/3)......end~(3/3)
qq=num2str(q);
pp=num2str(p);
filename=[ff,tt,qq,uu,pp]; % File Name: Coluomb_Torque_qq_Ratio_pp
filename = ['C:\Users\folder1\folder2\folder3\folder4\Data Generating\Coluomb\' filename]
load(filename)</pre><pre> %%%% Do your Processing
% figure(1)
% plot(t,t1)
% hold on</pre><pre> % Clear filename from Workspace
end</pre><pre class="language-matlab">end
</pre><p>The error am getting is :</p><pre class="language-matlab">Error using load
Unable to read file
'C:\Users\folder1\folder2\folder3\folder4\DataGenerating\Coluomb\Coluomb_Torque_ *30*_Ratio_31'. No such file or
directory.
</pre><pre class="language-matlab">Error in post_proc (line 18)
load(filename)
</pre><p>as you can see, the loop keeps going beyond the index 29, and this happens only when I use the Load command, i.e if I remove the load command I get the filenames exactly as they should be.</p><p>Thanks</p><p>Alz</p>ALZhttps://www.mathworks.com/matlabcentral/profile/authors/3664962-alztag:www.mathworks.com,2005:Question/2974562016-07-28T00:18:15Z2016-07-28T02:47:51Zfinding zeroes of data<p>How do you find zeroes from data? I have two data sets, a for acceleration and t for time. I plotted acceleration with respect to time, and I want to find when the acceleration hits zero, so at what time. I know there is fzero, but that is mainly for functions and this is just a plot from data. Do I make the data into some sort of function or can I use the find function somehow?</p>Luke Radcliffhttps://www.mathworks.com/matlabcentral/profile/authors/8207473-luke-radclifftag:www.mathworks.com,2005:Question/2974642016-07-28T02:46:33Z2016-07-28T02:46:33ZImport from data from messy text file<p>Hi, I have looked through the questions and answers that are already available for this topic but wasn't able to apply those to my situation.</p><p>For the attached file, I need to extract the data for each "Specimen." The data that i need are the three columns corresponding to the 500+ rows for each specimen. If possible, I would like to save it in to different arrays. One for each specimen.</p>Ezequiel Buenrostrohttps://www.mathworks.com/matlabcentral/profile/authors/7008432-ezequiel-buenrostrotag:www.mathworks.com,2005:Question/2974222016-07-27T18:16:20Z2016-07-28T02:45:58ZHow to get results from symbolic variable integration<p>Pretty straight forward, I'm trying to do integration with symbolic variables.</p><p>I'm doing some complex integration with a mix of high degree polynomials and trig functions.</p><p>This is what I tried so far:</p><pre class="language-matlab">syms x
b4 = (x^127+x^32-x^12+78*x^2-5*cos(x))
int(b4, 0, 1)
</pre><p>I was hoping to get some number for the answer, but instead, I got this:</p><pre class="language-matlab">ans =
int((x^127+x^32-x^12+78*x^2-5*cos(x)), x, 0, 1)
</pre><p>I don't know why this is happening. How do I get the actual answer in numbers?</p>Hosup Songhttps://www.mathworks.com/matlabcentral/profile/authors/6111579-hosup-songtag:www.mathworks.com,2005:Question/2972942016-07-26T22:21:56Z2016-07-28T02:27:18ZUser input file directory<p>I am writing a script that reads all of the files of a certain type in a given directory, and I'm wondering if there is a way to allow the directory location to be a user input.</p><p>Currently the code looks like:</p><p>directory_in = dir('C:\Folder\Bob\*.dat');</p><p>I would like to change it to something more like:</p><p>input_in = input('Enter the directory name: ');</p><p>directory_in = dir(input_in, '*.dat');</p><p>I know this code won't work as written for multiple reasons, but I'm wondering if there is some way I could combine the user input with the file type suffix in order to minimize the amount of editing a future user would need to perform on the script.</p>Parker Phillipshttps://www.mathworks.com/matlabcentral/profile/authors/7983890-parker-phillipstag:www.mathworks.com,2005:Question/2973112016-07-27T02:18:55Z2016-07-28T02:05:49ZSet and get structure field with invalid name<p>I'd like to get and set a structure with potentially invalid field names. Before digging into the mex myself I was wondering if there was already a tool that existed that performed these functions. I swear I've seen this around but my search skills are failing me. Finally, I assume this is possible with mex ....</p><p>Thanks,
Jim</p>Jim Hokansonhttps://www.mathworks.com/matlabcentral/profile/authors/937359-jim-hokansontag:www.mathworks.com,2005:Question/2974572016-07-28T00:34:57Z2016-07-28T02:05:29ZHow to use a matrix of data of B field in a 3D space to calculate the induced current in a closed loop on xy plane<p>Dear all:</p><p>Any one could help me with this problem:</p><p>I want to use a matrix of data which describes the magnetic field(Bx, By, Bz) at point(x, y, z) in a column of space to calculate the the induced current in a closed loop on xy plane. Basically the surface integration of dot product of dB and dS. Is there a way to do that?</p><img src = "/matlabcentral/answers/uploaded_files/56822/Screen%20Shot%202016-07-27%20at%203.01.18%20PM.png"><p>Any one could help please as soon.</p><p>Thanks a lot!
Ruming</p>NeoBeaverhttps://www.mathworks.com/matlabcentral/profile/authors/8441178-neobeavertag:www.mathworks.com,2005:Question/2974602016-07-28T01:27:51Z2016-07-28T02:03:47ZNumerically integrating acceleration properly<p>I'm doing some vibration analysis and I have some acceleration data that I'd like to convert to position. Using cumtrapz doesn't actually give me the correct velocity and position signal - they are shifted up. Take the following code for example:</p><pre class="language-matlab">x=0:.01:2*pi;
y1=sin(2*x);
y2=cumtrapz(x,y1);
y3=-cos(2*x)/2;
plot(x, [y1; y2; y3])
</pre><p>I know y3 is the true velocity signal but the cumtrapz is giving me a shifted up signal. It is in fact the sum but is not in fact physically correct. I can simply correct for by subtracting the max. But this wouldn't be true for more varying signals. like the following:</p><pre class="language-matlab">x=0:.01:2*pi;
y1=sin(2*x^2);
y2=cumtrapz(x,y1);
plot(x, [y1; y2-max(y2)])
</pre><p>you'll see with that plot the the velocity is mostly positive which means the position will diverge. This is not physically possible with this system. So obviously this correction is different for every signal. So how do i properly correct for this?</p>STEPHEN BARRETThttps://www.mathworks.com/matlabcentral/profile/authors/3580997-stephen-barretttag:www.mathworks.com,2005:Question/2974622016-07-28T01:57:47Z2016-07-28T01:58:47ZHow to Draw Multiple Bar Charts Side by Side just like subplot? <p>Can any one suggest how to draw three bar charts side by side, I mean just like subplot. I got three separate bar charts, which I want to draw side by side or one after another. I don't want to draw three separate groups in one bar chart, which is easy to draw.</p>Zubair Shahhttps://www.mathworks.com/matlabcentral/profile/authors/8474152-zubair-shahtag:www.mathworks.com,2005:Question/2974612016-07-28T01:41:02Z2016-07-28T01:41:02Zcomplete separation - convergence issue in GLMs - lassoGLM<p>How can I deal with convergence issue in GLM?</p><p>I tried to use penalized logistic regression. But instead of plots like in the <a href = "http://au.mathworks.com/help/stats/regularize-logistic-regression.html">documentation lassoglm</a></p><p>I get the plots below (code also below). Looks like lambda should be close to zero.</p><p>I guess this is the convergence issue I hoped to avoid using penalized GLM.
My question: why does penalization here not work and how can I make working it?</p><p>Plot 1:</p><img src = "/matlabcentral/answers/uploaded_files/56826/crossValDevianceLassoFit.png"><p>Plot 2:</p><img src = "/matlabcentral/answers/uploaded_files/56827/tracePlotCoefficientsFitLasso.png"><pre class="language-matlab">load('GroundTruth.mat') % attached to question
Ybool = label;
X = features;
[B,FitInfo] = lassoglm(X,Ybool, 'binomial',...
'NumLambda',25,'CV',10);
% figure
lassoPlot(B,FitInfo,'PlotType','CV');
% figure
lassoPlot(B,FitInfo,'PlotType','Lambda','XScale','log')
</pre>Matthiashttps://www.mathworks.com/matlabcentral/profile/authors/5113675-matthiastag:www.mathworks.com,2005:Question/2973642016-07-27T12:12:55Z2016-07-28T01:29:44Zhow to get the coordinate information of the left bottom corner of an image in the figure window.<p>The coordinate of the encircled corner.</p>binbin cuihttps://www.mathworks.com/matlabcentral/profile/authors/8190832-binbin-cui