http://www.mathworks.nl/matlabcentral/answers/questions.atomMATLAB Answers — New Questions20140419T01:58:49Ztag:www.mathworks.nl,2005:Question/12630720140419T01:58:49Z20140419T01:58:49ZRF: Deembed S parameters<p>Hello all,
I have my circuit block diag as shown below:</p><img src = "/matlabcentral/answers/uploaded_files/11583/Capture.JPG"><p>I already have the 's_params' matrix values(measured). I need to deembed this to get the s parameter values of my DUT: 's2_params'.
Using matlab, I have found this equation:</p><pre> s2_params = deembedsparams(s_params,s1_params,s3_params)</pre><p>=> t_params = t1_params * t2_params * t3_params</p><p>And as for the t1_params, t3_params is concerned, I have designed another compensation circuit and have the s paramater values of it (namely s_compensated>s matrix,t_compensated>T matrix).
So, I could say,
t_compensated = t1_params * t3_params
The compensation circuit is actually symmetric. So t1_params = t3_params as for my design.</p><p>My question here is,
in the equation: t_params = t1_params * t2_params * t1_params,
t_params is known and I need values of t2_params.
In the equation: t_compensated = t1_params * t1_params,
t_compensated is known. From this, I need to get values of t1_params and substitute in first equation to get my DUT value (i.e., t2_params).</p><p>But to divide t_compensated matrix value into t1_params*t1_params, I need to take a square root of it, but the square root of matrix yields 4 possible roots, and for each of these I would get different t2_params after substitution. So can someone help me with how to get t2_param values in my case?</p>Rajiv/matlabcentral/answers/contributors/3459322rajivtag:www.mathworks.nl,2005:Question/12630020140418T23:37:48Z20140419T01:57:16ZGetting Error: Unexpected MATLAB expression.<p><b>Question:</b> Use Newton's method to �nd three roots of x^3  5x + 1 = 0
accurate to within 10^14.</p><p><b>My Matlab Code:</b></p><pre class="languagematlab">format long
x=0.5
for I = 1:10
x=x((x.^3)5.x+1)/(3.(x.^2)5),
end
x=x((x.^3)5.x+1)/(3.(x.^2)5),

Error: Unexpected MATLAB expression.
</pre><p><b>Problem:</b> I am getting the aforementioned error and therefore, cannot find roots of the given equation in the question. Please can you find the problem and help me out? I am new to Matlab and I am learning this software. Thanks a lot! Appreciate it. :)</p><p><b>MATLAB Version:</b> MATLAB R2013a</p><img src = "/matlabcentral/answers/uploaded_files/11582/1.png">John/matlabcentral/answers/contributors/5264881johntag:www.mathworks.nl,2005:Question/12630120140419T00:30:31Z20140419T01:53:52ZMeaning of "DAE appears to be of index greater than 1"?<p>I am having some trouble getting ODE15s to run on a 10x10 system, continuing to receive the error "This DAE appears to be of index greater than 1." I do not think this is the case though. Internet research tells me that normally initial conditions are the problem, but I am defining my IC's for the 2 algebraic equations such that they agree with equations 2 and 3.</p><p>The system mass matrix is:</p><p>1 0 0 0 0 0 0 0 0 0</p><p>0 0 0 0 0 0 0 0 0 0</p><p>0 0 0 0 0 0 0 0 0 0</p><p>0 0 0 1 0 0 0 0 0 0</p><p>0 0 1 0 0 0 1 0 0 0</p><p>0 1 0 0 0 0 0 0 1 0</p><p>0 0 0 0 0 0 0 0 0 0</p><p>0 0 0 0 0 0 0 1 0 0</p><p>0 0 0 0 0 0 0 0 0 0</p><p>0 0 0 0 0 0 0 0 0 1</p><p>The right hand side is: (note, I am using the syntax y(x) instead of y(t) here)</p><p>[a(x)</p><p>b(x)  y2(x)</p><p>c(x)  y3(x)</p><p>d(x)</p><p>e(x)</p><p>f(x)</p><p>0</p><p>y7(x)</p><p>0</p><p>y9(x)],</p><p>Where a(x), b(x), etc. are all defined functions of x.</p><p>Any help would be greatly appreciated. I can post the code if necessary but first I am wondering if I am doing something fundamentally wrong.</p>Matthew Krott/matlabcentral/answers/contributors/5264877matthewkrotttag:www.mathworks.nl,2005:Question/12630620140419T01:47:02Z20140419T01:47:02ZQuestion about mex setup<p>Hi</p><p>I ahve two versions of Matlab running on my computer. One is 2011b and the other one is 2014a. I am trying to setup compilers. I was able to do that sucessfully on 2011b. When I run set up on 2011b, I get</p><p>>> mex setup</p><p>Welcome to mex setup. This utility will help you set up
a default compiler. For a list of supported compilers, see <a href = "http://www.mathworks.com/support/compilers/R2011b/win64.html">http://www.mathworks.com/support/compilers/R2011b/win64.html</a></p><p>Please choose your compiler for building MEXfiles:</p><p>Would you like mex to locate installed compilers [y]/n?</p><p>++++++++++++++++</p><p>For the 2014a I get the following message. I do not get the options to choose sdk7.1 or visuall C++. I want to select visual C++.</p><p>mex setup
MEX configured to use 'Microsoft Windows SDK 7.1 (C)' for C language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^321 elements. In the near future
you will be required to update your code to utilize the
new API. You can find more information about this at:
<a href = "http://www.mathworks.com/help/matlab/matlab_external/upgradingmexfilestouse64bitapi.html">http://www.mathworks.com/help/matlab/matlab_external/upgradingmexfilestouse64bitapi.html</a>.</p><p>To choose a different language, select one from the following:
mex setup C++
mex setup FORTRAN</p><p>I will appreciate if some one can tell why do I not get the options on in 2014a and how can I change the default from sdk to visual c++.</p><p>Thnaks</p>Muzammil/matlabcentral/answers/contributors/2708784muzammiltag:www.mathworks.nl,2005:Question/12618020140417T22:28:57Z20140419T01:46:56ZRegression Equation from artificial neural network<p>Hi, I have 3 Input Data (temperature, moisture content, and frequency) set of 168 and</p><p>my target data (dielectric constant) set of 168.</p><p>I used an artificial neural network toolbox to get a regression model to generate simulated data.</p><p>I trained(70%), validated (15%), and tested(15%) it. I got reasonable result.</p><img src = "/matlabcentral/answers/uploaded_files/11540/regression.jpg"><img src = "/matlabcentral/answers/uploaded_files/11541/result.jpg"><p>Once i got the result is it possible to extract the regression equation from result.</p><p>If it is possible, which section should I click to get the regression model??</p><p>If I am not able to get the regression model directly, how can I get other information like bias, weight, and structure of neural network model to generate the regression model in directly or manually?</p>daeung Yu/matlabcentral/answers/contributors/5262343daeungyutag:www.mathworks.nl,2005:Question/12630520140419T01:40:23Z20140419T01:40:23ZWindow size or length<p>I came about a program that in order to set the window size, it mentions that as follows for instance:</p><p>window_size = 20;</p><p>What does 20 represent here? What should I look for in my image for instance to set such value? Maybe this is length rather than size? But, also, how is it measured?</p><p>Thanks.</p>medsweng/matlabcentral/answers/contributors/1414040medswengtag:www.mathworks.nl,2005:Question/12630420140419T01:30:04Z20140419T01:30:12ZHannibal Season 2 Episode 8 SuZakana Online Free <p><a href = "http://xiotime.uservoice.com/knowledgebase/articles/350763">http://xiotime.uservoice.com/knowledgebase/articles/350763</a></p><p><a href = "http://xcloudgame.com/forum.php?mod=viewthread&tid=166039">http://xcloudgame.com/forum.php?mod=viewthread&tid=166039</a></p>tracy carver/matlabcentral/answers/contributors/5264993tracycarvertag:www.mathworks.nl,2005:Question/12619820140418T03:34:49Z20140419T01:15:36ZHow to find when a surface deviates from other surface(s)<p>Hi guys,</p><p>I have 3 surfaces. I want to find out values for x and y, where each of the three surfaces deviates from the other two by more than 0.5 value on the z axis. Is this a simple enough thing?</p><p>I can imagine it being super easy to do with only two surfaces because you could just substract one from the other. But how do I do it with 3 surfaces? Any ideas?</p><p>Ideally, I'd like to see [x,y] points for each surface where it deviates from other surfaces on zaxis by > 0.5.</p><p>It would be great to be able to graphically see this 'deviation' as well perhaps as another surface?</p><p>A member on the forum recommended the following method, however my inexperience with matlab means that I'm not sure how to interpret the logical array and/or see it as a plotted surface.</p><pre class="languagematlab">>> x = [10:10];
>> y = [10:10];
>> test1 = x + 0.5*y;
>> test2 = x + y;
>> test3 = x + 1.5*y;
>> testI = meshgrid(test1);
>> testII = meshgrid(test2);
>> testIII = meshgrid(test3);
>> surf(x,y,testI);
>> hold on
>> surf(x,y,testII);
>> surf(x,y,testIII);
*>> OfInterest = any(diff( sort( cat(3, test1, test2, test3), 3), 3) > 0.5, 3);*
>> OfInterest
OfInterest =
Columns 1 through 15
0 0 0 0 0 0 0 0 1 1 0 0 0 0 0
Columns 16 through 18
0 0 0
>> image(OfInterest);
>> colormap(gray(2));
</pre><p>Thanks</p>A/matlabcentral/answers/contributors/4874440atag:www.mathworks.nl,2005:Question/12630320140419T00:55:48Z20140419T00:55:48Zhow can i findi the probability density function of two signals <p>i have to signals X and Y
i need to prove that they are independence
using the following equation</p><p>Px,y(X,Y) = P(X)*P(Y)</p><p>so how can i find the joint Pdf Px,y(X,Y)
and the marginal Pdf of X and the marginal Pdf of Y</p><p>pls help me
thank you</p>anwar anwar/matlabcentral/answers/contributors/4439995anwaranwartag:www.mathworks.nl,2005:Question/10280220091118T16:33:00Z20140419T00:49:32ZWhy does MATLAB crash when I type into the search bar in the Help menu?<p>When I go to the Help menu and start to type into the search bar, MATLAB crashes. How can I avoid this?</p>MathWorks Support Team/matlabcentral/answers/contributors/4622813mathworkssupportteamtag:www.mathworks.nl,2005:Question/12606120140417T01:30:14Z20140419T00:48:57ZImage steganography in matlab:Retrieve hidden Image<p>I am trying to retrieve the image hidden in another image. This is the code I have so far but it is not working correctly. Can anyone tell me what Im doing wrong?</p><pre> I1 = imread('c:/df/img/Lena1.png');
I2=I1;</pre><pre> output_stream="";
data_size_s=""; %In bytes and as a string </pre><pre> %We read the size of the target from the stego image (first 16 bits)
k=1;
for i=1:rows(I2)
for j=1:columns(I2)
if (k<18) s=dec2bin(double(I2(i,j,1)),8); data_size_s=strcat(data_size_s,s(8)); k++; endif
if (k<18) s=dec2bin(double(I2(i,j,2)),8); data_size_s=strcat(data_size_s,s(8)); k++; endif
if (k<18) s=dec2bin(double(I2(i,j,3)),8); data_size_s=strcat(data_size_s,s(8)); k++; endif
end
end</pre><pre> %We pass the size of the target image from string to integer
target_rows=uint32(bin2dec(substr(data_size_s, 1,8)));
target_columns=uint32(bin2dec(substr(data_size_s,9,8)));
data_size_int=target_rows*target_columns; % Data Size in bytes as integer</pre><pre> %We read the output_stream from the stego image
total_data_size=(8*data_size_int)+16; % Total length of the output stream (header + target data)</pre><pre> k=1;
for i=1:rows(I2)
for j=1:columns(I2)
if (k<=(total_data_size)) s=dec2bin(double(I2(i,j,1)),8); output_stream=strcat(output_stream,s(8)); k++; endif
if (k<=(total_data_size)) s=dec2bin(double(I2(i,j,2)),8); output_stream=strcat(output_stream,s(8)); k++; endif
if (k<=(total_data_size)) s=dec2bin(double(I2(i,j,3)),8); output_stream=strcat(output_stream,s(8)); k++; endif
end
end</pre><pre> I3_rows=uint32(bin2dec(substr(output_stream,1,8)));
I3_columns=uint32(bin2dec(substr(output_stream,9,8)));
k=17;</pre><pre class="languagematlab">I3=uint8(zeros(I3_rows,I3_columns,3));
</pre><pre class="languagematlab">% We create a empty creyscale image with the dimensions of the target
total_data_size=(8*data_size_int)+16;
</pre><pre class="languagematlab">for i=1:I3_rows
for j=1:I3_columns
if (k<=total_data_size) I3(i,j,1)=uint8(bin2dec(substr(output_stream,k,8))); k=k+8; endif
if (k<=total_data_size) I3(i,j,2)=uint8(bin2dec(substr(output_stream,k,8))); k=k+8; endif
if (k<=total_data_size) I3(i,j,3)=uint8(bin2dec(substr(output_stream,k,8))); k=k+8; endif
</pre><pre> end
end</pre><pre> %We show the hidden image.
imshow(I3);</pre>Jessica/matlabcentral/answers/contributors/5259672jessicatag:www.mathworks.nl,2005:Question/12616420140417T18:44:33Z20140419T00:43:27Zhow to take out extreme event annually from the data.<p>sir i have program who calculate extreme event annually for whole 95 years but this program works only for those who does not include leap years it means data size is 20x22x34675(lon,lat,time)(365*95) but i want to calculate extreme event annually for those data who include leap years (it mean 365 Or 366 then 365 Or 366 ....each separate years) then what will be change in this program for doing this? my data size is (prec_all_years) 20x22x34698(lon,lat,time)(365*95+23).this is daily data.please help me sir.thank you.</p><p>prec_all_years = prec_all_years*86400; % rainfall in mm/day</p><p>bins = [64.5 124.5 244.5 Inf];</p><p>% Reshape into lat/lon/day/year, and bin over 3rd dimension (days)</p><p>counts = histc(reshape(prec_all_years,20,22,365,95),bins,3);</p><p>% Extract the counts for each of the 3 categories</p><p>hr = squeeze(counts(: , : , 1 , : ));</p><p>vhr = squeeze(counts(: , : , 2 , : ));</p><p>ehr = squeeze(counts(: , : , 3 , : ));</p><p>% Extract a region</p><p>xe = 13:20; ye = 11:16;% xe is x for east,ye is y for east</p><p>% Extract counts for each category</p><p>count_hr_east = sum(reshape(hr(xe , ye , : ) , [] , 95 ));</p><p>count_vhr_east = sum(reshape(vhr(xe , ye , : ) , [] , 95 ));</p><p>count_ehr_east = sum(reshape(ehr(xe , ye , : ) , [] , 95 ));</p>ravi/matlabcentral/answers/contributors/5225094ravitag:www.mathworks.nl,2005:Question/12630220140419T00:31:21Z20140419T00:31:21ZHow to deactivate some of the elements of my variable matrix in fmincon<p>I have a 4D matrix of variables in my nonlinear model.
Not all variables are valid in my model depending on the example. There was no way for me to make a less complicate matrix of variables since I need to cover different levels of a factory(each level has a dimension) and I want my model to be in general form to be able to cover models that include full number of variables(the whole 4D matrix)</p><p>I tried setting zero for some elements of the 'ub' but in Matlab ub is greater than(<) the x values and not greater than or equal to(>=) them. that forces me to set a very small value(0.000000001) for the upper bounds of the invalid variables. but that doesnt stop Matlab from changing the values of those variables and that means I do not get an optimum and feasible solution.</p><p>Thanks in advance.</p>saman Tayari/matlabcentral/answers/contributors/4972296samantayaritag:www.mathworks.nl,2005:Question/12629920140418T23:33:21Z20140418T23:49:00ZTo approximate an expression with exact values<p>1) 1.0/3*exp(1)*sin(2)</p><pre> ans =</pre><pre> 0.8239</pre><p>BUT when I used command,</p><p>2) float(1.0/3*exp(1)*sin(2))</p><pre class="languagematlab">Error using float (line 46)
The input argument to float was not a supported type. The only recognized strings are 'single'
and 'double'. The input type was 'double'.
</pre><p>How can I get an expression with exact values?</p>adibbakarrudin/matlabcentral/answers/contributors/5040469adibbakarrudintag:www.mathworks.nl,2005:Question/12629820140418T23:25:30Z20140418T23:37:02Zerror  unexpected matlab expression<p>I have the following call to a function:</p><pre> callfun(I1, I2, [X Y ones(n,1)], w, m)</pre><p>But, I'm getting:</p><pre> Error: File: callfun.m Line: 20 Column: 3
Unexpected MATLAB expression.</pre><p>Why is that?</p><p>Thanks.</p>medsweng/matlabcentral/answers/contributors/1414040medswengtag:www.mathworks.nl,2005:Question/12629720140418T23:12:06Z20140418T23:33:40ZEvaluating with quad error<p>I can't seem to get my function to work! I'm getting a not enough inputs error.</p><pre class="languagematlab">function f=f6(r)
f=r.*(1.(r/.5)).^(1/8);
</pre>B/matlabcentral/answers/contributors/5188407btag:www.mathworks.nl,2005:Question/12439520140403T20:02:47Z20140418T23:17:06Zpolyfit along a given dimension<p>The <tt>mean</tt> function allows the user to specify a dimension along which to calculate the mean. Can I do something similar with <tt>polyfit</tt>? I have a big 3D data set. It's essentially a stack of gridded values that have evolved through time, and I'd like to make a map of the linear trend without using a loop.</p>Chad Greene/matlabcentral/answers/contributors/1062128chadgreenetag:www.mathworks.nl,2005:Question/12628120140418T20:37:38Z20140418T23:08:45ZUndefined function or method 'audioread' for input arguments of type 'char'.<p>hi,i want to play mp3 file using audioread on windows 7</p>zaryab arif/matlabcentral/answers/contributors/5263450zaryabariftag:www.mathworks.nl,2005:Question/12628520140418T21:14:51Z20140418T23:06:41ZDisplaying output as a vector?<p>I am using a for loop to find the squares of the numbers 15. However, my answer needs to be in a 5 element vector. When I run it, it shows each individual answer like so:</p><p>x=1</p><p>x=4</p><p>x=9</p><p>x=16</p><p>x=25</p><p>I need to find a way to have it shown as a 5 element vector such as: x= 1 4 9 16 25</p><p>Any help?!?!</p>Matthew Quinones/matlabcentral/answers/contributors/5176061matthewquinonestag:www.mathworks.nl,2005:Question/12629620140418T22:59:03Z20140418T23:04:35ZWhat does this parameter mean?<p>I came about this parameter passed to a function in `MATLAB`:</p><pre> [X Y ones(n,1)]</pre><p>Assume X: xdimension; Y: ydimension; n: size</p><p>What does the above mean?</p><p>Thanks.</p>medsweng/matlabcentral/answers/contributors/1414040medswengtag:www.mathworks.nl,2005:Question/12629520140418T22:54:55Z20140418T22:54:55ZMemory usage in sparse matrix<p>Hi,
Sparse matrices store only the nonzero elements and their position indices. Using sparse matrices can significantly reduce the amount of memory required for data storage.
But surprisingly I noticed that my computer runs out of memory when I try something like >>sparse(zeros(80000)) or a matrix having more elements.In zeros(), as there is no nonzero element, the sparse matrix should not have used any memory in this case at all!
I would really appreciate if anyone can elucidate this issue...
thanks.</p>tanmoy/matlabcentral/answers/contributors/3728253tanmoytag:www.mathworks.nl,2005:Question/12627320140418T19:28:34Z20140418T22:47:50ZHow to rearrange an array ? (only unique numbers in a column)<p>How to rearrange matrix: A = [1 1;1 4;2 3;2 7;3 5;4 2;5 6] To make it looks like: B= [1 1 4;2 3 7; 3 5 0; 4 2 0; 5 6 0]</p><p>The idea is to have only unique values in first column and if (in this example "1" and "2") value used twice to keep both numbers? Thanks</p>aleksandr nikolaev/matlabcentral/answers/contributors/5264552aleksandrnikolaevtag:www.mathworks.nl,2005:Question/12629420140418T22:45:04Z20140418T22:45:04ZIs it possible to solve an ODE with boundary condition using a matlab solver?<p>My question is very simple: I want to plot a graphic for the deflection of a beam, with consists of a solution of an ODE using a Matlab solver, such as:</p><p>%Call Solver > Linear</p><p>[x y] = ode45(@MyFunctionL,xspan, x0);</p><p>x0 = [0 0];</p><p>xspan = [0 Lg];</p><p>function dy = MyFunctionL(x,y)</p><p>global Fg Lg EI;</p><p>dy = zeros(2,1);</p><p>dy(1) = y(2);</p><p>dy(2) = (Fg/EI)*(Lg  x);</p><p>return</p><p>It works perfectly at first, but in another case in which I have to set a condition such as y´(Lg/2)=0 I am having some trouble. It should result in a sort of Parabolic y(x) if I could "insert" this boundary condition.</p><p>I wish to know if I can do it using a MATLAB solver or only with bvp4c. (I am interested in doing with a solver because later I have to compare the linear solution with a non linear solution)</p><p>Thanks very much!</p>Daniel Clemente/matlabcentral/answers/contributors/4812059danielclementetag:www.mathworks.nl,2005:Question/12629320140418T22:30:51Z20140418T22:30:51ZUsing getpts to get selected points<p>I'm trying to use `getpts` to get the location of the selected points by the user.</p><p>I used it as follows:</p><pre> [X,Y] = getpts(imread('xyz.jpg'));</pre><p>But, got the following error:</p><pre> Error using getpts (line 46)
First argument is not a valid handle.</pre><pre> Error in program (line 7)
[X,Y] = getpts(imread('xyz.jpg'));</pre><p>Why is that?</p><p>Thanks.</p>medsweng/matlabcentral/answers/contributors/1414040medswengtag:www.mathworks.nl,2005:Question/12629220140418T22:23:28Z20140418T22:23:28Z[Matlab R2013a] Publish PDF problem<p>Hi all,
i've a problem,
when i try to publish a script (mfile), in pdf i got this error:</p><pre class="languagematlab">>> publish('HW1_Santoro_Davide','pdf')
Error using publish>fopInitialize (line 582)
Java exception occurred:
java.net.MalformedURLException: Illegal character in path at index 32:
file:///C:/Users/Davide/Dropbox/[CN]/Homework1/html/
</pre><pre class="languagematlab"> at org.apache.fop.apps.FOURIResolver.checkBaseURL(FOURIResolver.java:105)
</pre><pre class="languagematlab"> at org.apache.fop.apps.FopFactory.setBaseURL(FopFactory.java:358)
</pre><pre class="languagematlab">Error in publish>publishToPdf (line 514)
[fopDriver, fopOutputStream] = fopInitialize(options,outputAbsoluteFilename);
</pre><pre class="languagematlab">Error in publish (line 198)
publishToPdf(dom,options,outputAbsoluteFilename)
</pre><p>How i can solve it?
I need to do this pdf (homework), for next week.</p><p>Waiting for your answers,
Thanks you.</p><p>Bye,
David.</p>Davide/matlabcentral/answers/contributors/3916958davidetag:www.mathworks.nl,2005:Question/12629120140418T22:12:18Z20140418T22:12:18ZHow can i get the transfer function for an Hinfinity contrller using State space matrices?<p>Hello,</p><p>I have four state space matrices A,B, C and D. I need to use the 'hinf' command in matlab to get the controller transfer function in this form:
K(z) = 0.02367z4 + 0.0003702z3 − 0.01514z2 + 0.007138z − 0.001015/z4 + 2.811z3 + 3.268z2 + 1.918z + 0.4738</p><p>I do not understand how to use Hinf to make my plant P and get to K(z). i need the k(z) equation as given above but i cant get past mksys(A,B,C,D,'tss') which gives me a long weird number. I think i am going wrong, i thought mksys would give me the plant P. can i get some direction, i am totally lost and new to control theoretic approaches in matlab.</p><p>Thanks!</p>Malik/matlabcentral/answers/contributors/3697174maliktag:www.mathworks.nl,2005:Question/12627620140418T20:00:13Z20140418T22:11:09ZRead files from directory, load function causing error<p>from the code below, when I run it and select the files I want, I get this error, I seem to be lost and cant figure out whats causing it> It seems to be reading letters of the file instead of the name of the file:
??? Error using ==> load
Unable to read file G: No such file or directory.</p><p>G is the first letter of the file I selected.</p><p>The other problem is if i select more than one files i get this error:</p><p>??? Error using ==> fprintf
Function is not defined for 'cell' inputs.</p><p>Error in ==>at line 34
fprintf('You have selected: %s\n\n',files2get)</p><p>Can someone help me?</p><pre> when I change the load functions code to:</pre><p>matrix = load(files2get{i,1},'%c%e%g%s%f');
i get this:</p><p>??? Cell contents reference from a noncell array object.</p><p>Error in ==> twinleaf at 38
matrix = load(files2get{i,1},'%c%e%g%s%f');</p><p>Question=input('Do You Want To Select Files: y/n \n\n', 's')</p><pre> Prompt=Question;</pre><pre> if strcmp(Prompt,'y')</pre><pre> fprintf('You selected: %s \n\n',Prompt)</pre><pre> fprintf('Please select the file type in the directory \n\n')</pre><pre> files2get = uigetfile('*.*','MultiSelect','on');</pre><pre> files2get={};</pre><pre> fprintf('You have selected: %s\n\n',files2get) </pre><pre> nfiles = size(files2get,1);</pre><pre> for i = 1:nfiles </pre><pre> matrix = load(files2get(i,1),'%c%e%g%s%f');</pre><p>end
elseif strcmp(Prompt,'n')</p><pre> fprintf('You selected: %s\n\n GOODBYE',Prompt)</pre><pre> end</pre>Mini Me/matlabcentral/answers/contributors/3875439minimetag:www.mathworks.nl,2005:Question/12613120140417T15:25:57Z20140418T21:35:59ZSCFDE continuous time transmission in MATLAB<p>Hello all,</p><p>I attached a file that contains the math of transmitting single carrier (SC) modulated signal over frequency selective channels. I need to implement this in MATLAB as it is in continuous time. In particular, I need to generate the baseband received signal as in eq. (1.3), the received samples as the second line in eq. (1.5), and the channel coefficients as in eq. (1.6a). I use the following parameters:</p><pre class="languagematlab">N=128; %Number of symbols
fc=12*10^3; %Carrier frequency
B=1000; % Bandwidth
Ts=1/(2*B);%Nyquist Sample Time
nsamp=10^3;%Oversampling factor
Ta=Ts/nsamp;%Sample time after oversampling
K=N*nsamp;%Number of symbols in sample time Ta
tau=[0 5 7 20].*10^3;%Pathe delays
h=[1 0.8 0.7 0.5];%Fixed channel coefficients.
</pre><p>If more math details are needed I will provide them on demand.</p><p>I appreciate your help.</p><p>Thanks</p>S. David/matlabcentral/answers/contributors/2168282sdavidtag:www.mathworks.nl,2005:Question/12629020140418T21:32:28Z20140418T21:32:28ZError solving simultaneous PDEs.<p>I am trying to solve a set of 2 PDEs but am getting stuck with this error:
??? Error using ==> daeic12 at 77
This DAE appears to be of index greater than 1.</p><p>I am unable to figure out the problem in the code. I am enclosing the code here:</p><pre class="languagematlab">clc; clear all;
m=0;
x = linspace(0,1,10);
t = linspace(0,20,10);
sol = pdepe(m,@eqn5,@initial5,@bc5,x,t);
u1 = sol(:,:,1)
u2 = sol(:,:,2)
u3 = sol(:,:,3)
u4 = sol(:,:,4)
u5 = sol(:,:,5)
function [c,b,s] = eqn5(x,t,u,DuDx)
c=[3.79995;4.3425475];
b = [0;0];
s = [73010;25842].*DuDx + [11.8333*(u(2)u(1));11.8333*(u(2)u(1))];
end
function [pl,ql,pr,qr] = bc5(xl,ul,xr,ur,t)
pl = [ul100;0];
ql = [0;0];
pr = [0;ur200];
qr = [0;0];
end
function value = initial5(x)
value = [100;390];
end
</pre>Shrishti/matlabcentral/answers/contributors/4679251shrishtitag:www.mathworks.nl,2005:Question/12626720140418T18:11:19Z20140418T21:29:58ZHow do I count the number of zeros in a matrix?<p>I have data imported from excel into a matrix and want to count the number of zeros in the file to work out the time.</p>Caroline/matlabcentral/answers/contributors/4930210carolinetag:www.mathworks.nl,2005:Question/12590320140415T21:14:48Z20140418T21:29:33ZHTMLbased image display in uitable works on PC but not Mac? <p>I'm making a GUI for visualizing the images (.JPGs) in a database and allowing searches on them. To implement the visualization, I make a uitable of images. To do this, I set the <i>Data</i> property to HTML code that displays the image. It looks like this.</p><pre class="languagematlab">>> tableCode{1,1}
</pre><pre class="languagematlab">ans =
<html><center><img height=60 width=60 src="Users/lab/Documents/blah.jpg"></center></html>
</pre><pre class="languagematlab">>> set(handles.uitable2, 'Data', tableCode);
</pre><p>This compiles and works well on Windows computers, but the images are all broken on Macs. I checked and the path works and opening a document with the same HTML from tableCode in Safari shows the image correctly. How can I fix this?</p>Wilma/matlabcentral/answers/contributors/3076736wilmatag:www.mathworks.nl,2005:Question/12628920140418T21:29:05Z20140418T21:30:04ZInvalid MEXfile The specified module could not be found (R2010a)<p>Hi,
I am a french guy, sorry for my English ...
I am on MATLAB R2010a and i want to use Openni and Nite to have a tracker for the kinect.</p><p>I follow these instruction <a href = "http://www.mathworks.com/matlabcentral/fileexchange/30242kinectmatlab">http://www.mathworks.com/matlabcentral/fileexchange/30242kinectmatlab</a> but i have an error when i try to execute example.m, after 4 hour i will surrend ...
I get this error :</p><p>??? Invalid MEXfile
'C:\OpenNI1\Mex\mxNiCreateContext.mexw64': Le module
spécifié est introuvable.
.
Error in ==> Example at 9
KinectHandles=mxNiCreateContext(SAMPLE_XML_PATH);</p><p>I try to use dependswalker to see if dlls files miss, i download all of these files and the error stay here ...
I use the compiler Microsoft Visual C++ 2010 Express with Windows SDK 7.1.</p><p>If you know how to fix this error, please tell me how !</p><p>Thank you,</p><p>Souil002</p>Maxence/matlabcentral/answers/contributors/5264761maxencetag:www.mathworks.nl,2005:Question/12628820140418T21:25:35Z20140418T21:25:35ZI work on network system building on XPC, is there any tool or method to measure the throughput of the system in XPC?<p>I work on network system building on XPC, is there any tool or method to measure the throughput of the system in XPC?</p>Abdulaziz Marei/matlabcentral/answers/contributors/4591586abdulazizmareitag:www.mathworks.nl,2005:Question/5683320121218T01:35:22Z20140418T21:24:20ZHow can I run 2 stepper motors simultaneously connected to an arduino Uno using Matlab?<p>Hi all,</p><p>I am using a motor shield with the arduino Uno.</p><p>I want to be able to run 2 stepper motors simultaneously.</p><p>This is a code that runs the 2 motors, but not simultaneously, as in, for motor 2 to start, it has to wait for motor 1 to stop.</p><p>I have tried to use 'parfor' loops instead of 'for' loops, that didn't do the trick.</p><p>I have tried uploading an edited version of the srv.pde to integrate the I2C and AccelStepper libraries, but I'm not getting a simultaneous movement either...</p><p>I added to the srv.pde:</p><pre class="languagematlab">#include <Wire.h>
#include <AccelStepper.h>
</pre><p>and to the void loop (), I added:</p><pre class="languagematlab">Wire.beginTransmission (100);
</pre><p>and uploaded that as to the master arduino.</p><p>and uploaded to the slave arduino:</p><pre class="languagematlab">#include <Wire.h>
</pre><pre class="languagematlab">void setup()
{
Wire.begin(100);
Wire.onReceive(receiveEvent);
}
</pre><pre class="languagematlab">void loop()
{}
</pre><pre class="languagematlab">void receiveEvent( int howMany)
{
while (Wire.available())
{}}
</pre><p>I need help modifying the srv.pde so that when I upload it, I would be able to run the stepper motors simultaneously. Or another way, without having to modify the srv.pde file, to be able to run the motors simultaneously...</p><p>Thank you.</p><p>[Merged information from duplicate Question]</p><p>Hi, I have 2 arduinos, 2 motor shields, and 2 stepper motors.
I want the 2 motors to run simultaneously, when I connect the 2 steppers to one arduino, the motors do not run at the same time. For example, in a for loop like this, motor 1 will run, stop, then moto 2 will run, stop.</p><p>for k=1:3;</p><p>a.stepperStep(1,'forward','double',200);</p><p>a.stepperStep(2,'forward','double',200);</p><p>end</p><p>The same issue occurs if I have 2 arduinos connected. For example, the for loop would be like this:</p><p>for k=1:3;</p><p>a.stepperStep(1,'forward','double',200);</p><p>b.stepperStep(1,'forward','double',200);</p><p>end</p><p>with "b." representing a different arduino than the "a."</p><p>Is there a way to make the 2 motors run at the same time?</p><p>Thank you.</p>Ejri/matlabcentral/answers/contributors/1501130ejritag:www.mathworks.nl,2005:Question/12628720140418T21:18:24Z20140418T21:20:55ZHow to speed up Matlab code for analyzing frames (Video)?<p>Hi, I have an infrared camera looking at a near infrared lazer pointer that I keep moving it within a white board, so the only thing seen by the camera is a white thick point moving within the board.
My goal here is to trace this lazer point by finding the maximum intensity in every frame (my camera takes 30 frame/second), so the problem here is my code take sometimes to analyze a frame which means I miss finding the highest intensity of several frames therefore I do not get a continuous line in my Matlab figure same way I move my lazer.</p><p>Any help regarding speeding up the analysis of frames would be appreciated.
Bellow is my code:</p><p>%% Running camera
obj = videoinput( 'macvideo', 2, 'YCbCr422_1280x720');
set(obj,'ReturnedColorSpace','grayscale');
preview(obj);</p><p>%% Trace Lazer by high intensity point</p><p>% Allocating Memory
frame=zeros(720,1280);
i=zeros(1,30);</p><p>for i=1:30
frame= getsnapshot(obj);
maximum=max(frame(:));
% spy for the highest intensity point
spy(frame==maximum,20)
axis off
axis image
hold on
end
hold off</p>Yassine/matlabcentral/answers/contributors/3367816yassinetag:www.mathworks.nl,2005:Question/12623720140418T13:50:58Z20140418T21:18:54Zhow i do retrieve data set of website in matlab?<p>source code for open one website in matlab is:
% Read website in variable
urlread(url)</p><p>% Open Website in MATLAB browser
web(url)</p><p>how i do call data set of website in matlab?</p>nafise/matlabcentral/answers/contributors/5263611nafisetag:www.mathworks.nl,2005:Question/12628020140418T20:35:08Z20140418T21:15:36ZUndefined function or method 'imsharpen' for input arguments of type 'uint8'.<pre class="languagematlab">if true
% code
d1=imread('j.jpg');
</pre><p>b = imsharpen(d1);</p><p>subplot(2,2,4);
imshow(b);
title('Sharpened Image');
end</p>zaryab arif/matlabcentral/answers/contributors/5263450zaryabariftag:www.mathworks.nl,2005:Question/12628620140418T21:15:19Z20140418T21:15:19ZModel Reference Blocks and systune<p>I have a large simulation which makes extensive use of model references, variants, and
bus cinfig files. Is there a reccomended way to reference control system tuneable parameters
deep in the model reference hierarchy?</p>Jim Farkas/matlabcentral/answers/contributors/4204022jimfarkastag:www.mathworks.nl,2005:Question/12628220140418T20:48:27Z20140418T21:09:34ZHow to split a matrix into n smaller matrices <p>Hello,</p><p>Intro:</p><p>I am importing data from a text file, so depending on the file the size of my matrix changes (number of columns remains the same), and splitting/searching for the values I am looking for by a specified row/column seem to be out of the question; I have a matrix, example:</p><pre class="languagematlab">A =
[2.1 3.4 5.6 1;
2.1 3.3 5.7 1;
3.3 2.2 4.4 2]
</pre><p>Problem:</p><p>I would like to split the matrix into smaller portions based on the value of the last column (i.e. I would like a series of matrices which contain only the values that contain a 1, 2,..., n in their last column)</p><p>Current Approach:</p><p>The best way I can think to do this is by scanning through each row element of column 4 (in this example) and determining when the integer number changes to then split the parent matrix according to which row the integers change at.</p><pre class="languagematlab">if true
% for b = 1:length(A)
if A(b,4) ~= A(b+1,4)
%assign inequality to some variable
end
</pre><p>Thanks</p>Josh/matlabcentral/answers/contributors/5216417joshtag:www.mathworks.nl,2005:Question/12628320140418T21:01:46Z20140418T21:01:46ZQuery about the kNN and SVM classifiers training<p>Hi all,</p><p>could anyone help me how to use the kNN and SVM classifiers where my problem in details as follows :</p><p>1I have two classes of fruit images (Normal and Abnormal)</p><p>2I extracted color feature histogram where bins=250</p><p>3I sorted these extracted features in a matrix of size 250 *100</p><p>4I transposed each matrix like : transposed_matrix= <b>matrix'</b> % for Kmeans clustering purpose</p><p>5I clustered each matrix to 4centers using Kmeans algorithm where each center is a feature</p><p>6 I stored 40 clustered matrices of normal images (each one is represented by 4centers ) in the training matrix to be 160 centers * 250 columns as a training matrix ,also I did the same thing for abnormal images in another training matrix also</p><p>But now I don't know how to give these two training matrices to the kNN and SVM classifiers</p><p>and then test an unknown image taken from the testing set (also represented by 4centers) using</p><p>kNN and SVM classifiers to classify it to normal or abnormal class,could anyone guide me how to</p><p>do that in a matlab code lines because I am new in matlab I saw the svmclassify function on</p><p><a href = "http://www.mathworks.com/help/stats/svmclassify.html">http://www.mathworks.com/help/stats/svmclassify.html</a></p><p>and</p><p><a href = "http://www.mathworks.com/help/stats/svmtrain.html">http://www.mathworks.com/help/stats/svmtrain.html</a></p><p>But I don't know how to adapt these codes for my case,
I attached my test code</p><pre> and thank you so much in advance.</pre>hamed abdulaziz/matlabcentral/answers/contributors/4484950hamedabdulaziztag:www.mathworks.nl,2005:Question/12627220140418T19:27:49Z20140418T21:00:09ZMatlab compiler installer requires internet connection<p>Hi.</p><p>I’m using Matlab R2014a compiler. As you know compiler create “for_redistribution” files for installing designed program. When we start the installation process in first phase the installer must connect to internet (Mathwork website). Is any way to disable it? Because there isn't internet connection on some of computers I’m going to install this program on it.</p><p>Thanks.</p>Jack/matlabcentral/answers/contributors/5193869jacktag:www.mathworks.nl,2005:Question/12627420140418T19:54:03Z20140418T20:51:35ZCalculating the change in water volume by comparing two images<p>I need to calculate the change in water volume by comparing two images. At time=0 the capillary is full and the first photo is taken. At time=30s second photo is taken and the volume of the water in capillary is less than its initial value. Can you help with calculating the volume change just comparing two photos and using capillary geometrical data. During this process all environmental variables will be kept constant.</p><p>Regards,</p>nnparticle/matlabcentral/answers/contributors/5264620nnparticletag:www.mathworks.nl,2005:Question/12626820140418T18:19:22Z20140418T20:39:36ZUsing Optical Flow Velocity Component  value too low?!<p>Hello,</p><p>*Goal : Use the optical flow method to find the displacement of a pixel/edge (not an object) versus time. Thus, it implies tracking this pixel/region. *</p><p>I have now extracted the velocity components (Horizontal and Vertical) with the vision Optical Flow method. I would guess that the unit is the pixel/frame.</p><p>My problem is : the velocities I find are too low. It generally is between 1 and 1 (from 0 to 10^1) even if the pixel moves by 3 pixels for example. I think either it is not the right unit, either I am doing something wrong in my code (wrong function?). I wanted to use the velocity between each frame to find the pixel location in the next frame, but as the values are very low, the location doesn't change.</p><p>How would you track a specific pixel/edge of an object?
Why the velocities I find are lower than expected?</p><p>Thank you</p>Kevyn/matlabcentral/answers/contributors/5210979kevyntag:www.mathworks.nl,2005:Question/12627520140418T19:57:50Z20140418T20:33:07ZUpload data from file and store into variable<p>HI,
So far I have the code that takes the coordinates from the airfoil and stores all of them in a variable to be later used in the code.
However I need to know how many points are being stored in the variables.</p><p>This is the input file</p><pre> 1.0000000 0.0000000
0.9500000 .0074400
0.9000000 .0130900
0.8000000 .0204800
0.7000000 .0236700
0.6000000 .0235600
0.5000000 .0216500
0.4000000 .0191400
0.3000000 .0183300
0.2000000 .0195200
0.1500000 .0207600
0.1000000 .0220100
0.0750000 .0222300
0.0500000 .0218500
0.0250000 .0195800
0.0125000 .0164400
0.0000000 0.0000000
0.0125000 0.0204600
0.0250000 0.0304200
0.0500000 0.0456400
0.0750000 0.0576700
0.1000000 0.0670900
0.1500000 0.0822400
0.2000000 0.0921800
0.3000000 0.1018700
0.4000000 0.0993600
0.5000000 0.0897500
0.6000000 0.0743400
0.7000000 0.0567300
0.8000000 0.0378200
0.9000000 0.0197100
0.9500000 0.0116600
1.0000000 0.0000000</pre><p>This is the code I'm using to get data from the file:</p><pre class="languagematlab">function [x,y]=AirfoilC
</pre><pre class="languagematlab">load Airfoil.dat; % read data into the my_xy matrix
x = Airfoil(:,1); % copy first column of my_xy into x
y = Airfoil(:,2);
</pre><p>So I need another variable that states how many points are being stored in x and output that for later usage.</p>Kartavya/matlabcentral/answers/contributors/5212114kartavyatag:www.mathworks.nl,2005:Question/12556720140412T22:39:12Z20140418T20:30:00ZHow do I solve this particular error? Firsttime MATLAB user<p>This is the code I'm trying to run:</p><pre class="languagematlab">%Blind embedding and linear correlation detection
clear all;
%Generate a reference pattern the same size as the images
wr=randn(112,92);
tm=mean2(wr);
wr=wrtm;%zero mean
ts=std2(wr);
wr=wr/ts;%unit variance
%Show the reference pattern
figure
imshow(wr,[]);
%400 face images, 112 x 92 pixels, in 40 folders of 10 images each
numclass=40;
numface=10;
for s=1:numclass
for i=1:numface
%Read image
c0=double(imread(strcat('C:\facedb_bmp\s',num2str(s),'\', num2str(i),'.bmp')));
%Add reference pattern to the image to embed a 1
wa=double(c0+wr);
%Add negative reference pattern to the image to embed a 0
nwr=wr*1;
nwa=double(c0+nwr);
%Calculate linear correlation for images carrying a 1, a 0,
%or no watermark and store it into a vector
corr1(10*(s1)+i)=sum(sum(wa.*wr))/(112*92);
corr0(10*(s1)+i)=sum(sum(nwa.*wr))/(112*92);
corrN(10*(s1)+i)=sum(sum(c0.*wr))/(112*92);
end
end
%Calculate the histograms for the detectionvalue vectors
[a1,b1]=hist(corr1,3:0.1:3);
[a2,b2]=hist(corr0,3:0.1:3);
[a3,b3]=hist(corrN,3:0.1:3);
%Plot the histograms
figure
plot(b2,a2/400*100,'red');
gtext('m=0');
hold;
plot(b3,a3/400*100,'green');
gtext('No watermark');
plot(b1,a1/400*100,'blue');
gtext('m=1');
xlabel('Detection value');
ylabel('Percentage of images');
</pre><pre class="languagematlab">if true
% code
end
</pre><p>When I click 'Save and Run', it gives me this error:</p><pre class="languagematlab">??? Undefined function or method 'blind' for input arguments of type 'char'.
</pre><p>Can anyone help me out? Also the image I'm using is Lena.tiff. I know I need to change the directory from C: onwards but do I also need to change .bmp to .tiff? Any help would be much appreciated.</p>Blake/matlabcentral/answers/contributors/5247420blaketag:www.mathworks.nl,2005:Question/12620520140418T06:42:45Z20140418T20:27:37ZHow to know an area of object using MATLAB<p><a href = "http://imgur.com/DBiot3W">http://imgur.com/DBiot3W</a></p><img src = "http://i.imgur.com/DBiot3W.jpg"><p>I am currently stuck in this part. What I want to know is the area of an object that is highlighted in the YELLOW region above.</p><p>Please do assist me.</p>Gary/matlabcentral/answers/contributors/2789147garytag:www.mathworks.nl,2005:Question/12625820140418T17:04:18Z20140418T20:17:39ZBoxplot help on a matrix of 24x45x65<p>Hello</p><p>i have 24x45x65 matrix. where the 24 is indicating 24 hours, 45 is 45 days...and 63 customers..where 65 is because some of it is 0 so its why it is 65 instead of 63..</p><p>however when u open this x_weekday.mat file i included. u will see val(:,:,1) it indicates the customer 1's data of 24 hours and 45 days...</p><p>so i want it to boxplot me that customer 1's data of 24 hours of 45 days.. at X label it should show what hour it is the boxplot is plotted. and Y label the amount of kWh. so there is 24 box in that boxplot 1 for each hour.</p><p>is it possible ?</p><p>thanks if u can help me..your the best :D</p>awda/matlabcentral/answers/contributors/4367523awdatag:www.mathworks.nl,2005:Question/12625620140418T16:42:19Z20140418T20:14:35Zdefining the position of input file<p>I have written a code that reads from a .dat file and does some calculation and stores the results in another .dat file. Every time i have to manually edit the position of file. Now is it possible to do it in a loop? Like load('D:\mamun\research\rateconstant\K1\freq.dat'), now when i will run the program everything will remain same only K1 will change to K2, k3 and so on. Is it possible to run it in a loop? or is it possible, it will ask me to give that position?
Thanks</p>Osman mamun/matlabcentral/answers/contributors/5238295osmanmamuntag:www.mathworks.nl,2005:Question/12627920140418T20:14:25Z20140418T20:14:25ZAnimation Lighting Moves with Object<p>I'm attempting to animate a rotating sphere, however the lighting on the sphere rotates with it. I instead want the sphere to rotate with the lighting fixed. Here's a gif of what my code is currently producing: <a href = "http://imgur.com/SiQjLys">http://imgur.com/SiQjLys</a>. Below is the code I used to produce the animation, I'm also open to any advance on how to make it look better/run faster also:</p><pre class="languagematlab">close all
clear all
clc
</pre><pre class="languagematlab">% Simulation Time
time = 0:0.05:5;
</pre><pre class="languagematlab">% Import STL Model Data
fv = stlread('DodecahedralCoil2.stl');
</pre><pre class="languagematlab">% Rotate Coils into Position
coil1 = fv;
coil1.vertices = fv.vertices*ROT(2,pi/2)';
coil2 = fv;
coil2.vertices = fv.vertices*ROT(2,pi/2);
</pre><pre class="languagematlab">% Prep Figure
format compact
set(gcf,'Color',[1 1 1]);
</pre><pre class="languagematlab">% Generate Sphere
[X,Y,Z] = sphere(20);
set(gcf, 'ColorMap', [1,0,0; 0,0,1])
C = Z;
r = 0.75*25.4;
h = surf(r*X,r*Y,r*Z,C,'FaceColor','interp');
rotate(h,[1 0 0],90)
rotate(h,[0 0 1],45)
hold on
</pre><pre class="languagematlab">% Adjust Lighting and Shading
camlight('right')
set(gcf,'Renderer','zbuffer')
set(findobj(gca,'type','surface'),...
'FaceLighting','phong',...
'AmbientStrength',.3,'DiffuseStrength',.8,...
'SpecularStrength',.9,'SpecularExponent',25,...
'BackFaceLighting','unlit','EdgeColor','k')
</pre><pre class="languagematlab">% Create Coils
patch(coil1,'FaceColor', [1 0.1 0.1], ...
'EdgeColor', 'none', ...
'FaceLighting', 'gouraud', ...
'AmbientStrength', 0.15);
hold on
patch(coil2,'FaceColor', [0.1 0.1 1], ...
'EdgeColor', 'none', ...
'FaceLighting', 'gouraud', ...
'AmbientStrength', 0.15);
hold on
</pre><pre class="languagematlab">% Create Coordinate Triad
quiver3(25*ones(3,1),25*ones(3,1),25*ones(3,1),[20;0;0],[0;20;0],[0;0;20],'k','LineWidth',2)
text(3,25,25,'X')
text(25,3,25,'Y')
text(25,25,3,'Z')
hold on
</pre><pre class="languagematlab">% Fix the axes scaling, and set view angle
axis off
axis('image');
view([40 25]);
xlabel('x')
ylabel('y')
zlabel('z')
axis equal
</pre><pre class="languagematlab">% Animate
filename = 'Rotation.gif';
for n = 1:36
tic
rotate(h,[0 0 1],10,[0 0 0])
drawnow
frame = getframe(1);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
</pre><pre> if n == 1;
imwrite(imind,cm,filename,'gif', 'Loopcount',inf,'DelayTime',0.05);
else
imwrite(imind,cm,filename,'gif','WriteMode','append','DelayTime',0.05);
end
toc
end</pre>Josh/matlabcentral/answers/contributors/3997760joshtag:www.mathworks.nl,2005:Question/12627820140418T20:14:18Z20140418T20:14:18ZLinker errors with libeng.lib and 64bit Cygwin g++<p>Greetings.</p><p>I am porting a VS2010 project that embeds a Matlab engine in a C++ program to Cygwin g++ on 64bit Windows. A test program, MServer.cpp, opens a Matlab engine and evaluates a 'clear' command (source file below.)</p><p>When I try to compile and link a test program using the following command line,</p><pre class="languagematlab">g++ MServer.cpp \
I "/cygdrive/c/Program Files/MATLAB/R2013b/extern/include"/ \
L "/cygdrive/c/Program Files/MATLAB/R2013b/extern/lib/win64/microsoft"/ \
llibeng
</pre><p>I get the following errors:</p><p><b>/cygdrive/c/Program Files/MATLAB/R2013b/extern/lib/win64/microsoft//libeng.lib(libeng.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_engEvalString' defined in .idata$5 section in /cygdrive/c/Program Files/MATLAB/R2013b/extern/lib/win64/microsoft//libeng.lib(libeng.dll.b)
/cygdrive/c/Program Files/MATLAB/R2013b/extern/lib/win64/microsoft//libeng.lib(libeng.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_engOpen' defined in .idata$5 section in /cygdrive/c/Program Files/MATLAB/R2013b/extern/lib/win64/microsoft//libeng.lib(libeng.dll.b)
collect2: error: ld returned 1 exit status</b></p><p>I read that 'relocation truncated' is normally related to a segment > 2 Gb, so I added
'mcmodel=large' to the g++ command line  no improvement.</p><p>Help appreciated, thank you.</p><pre class="languagematlab">#include "engine.h"
</pre><pre class="languagematlab">int main (void)
{
Engine *matlab;
if (!(matlab = engOpen("\0")))
return 1;
</pre><pre> engEvalString(matlab, "clear;");
return 0;
}</pre>Al/matlabcentral/answers/contributors/5079511al