https://jp.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2017-04-26T23:26:46Ztag:jp.mathworks.com,2005:Question/3375162017-04-26T23:26:46Z2017-04-26T23:26:46ZFind value of a certain overshoot from rlocus<p>I am using rlocus to plot the root locus to a system that</p>Alex Filiphttps://jp.mathworks.com/matlabcentral/profile/authors/10226392-alex-filiptag:jp.mathworks.com,2005:Question/3375152017-04-26T23:21:03Z2017-04-26T23:21:03ZNot enough input arguments<p>Hi so Im writing a code for plotting a satilite path in 3D. (I use here the 4th order Runge Kutta method)
my main file is:</p><pre class="language-matlab">y0=[-6035,-3480,2500,-3.437,6.618,2.523];
tspan=[1 9000];
[t3out,y3out]=RK(ode_function,tspan,y0,100,4);
</pre><p>The RK function is as follows:</p><pre class="language-matlab">function [tout,yout]=RK(ode_function,tspan,y0,h,rk)
i=1;
.
.
elseif rk==4
for t=tspan(1):h:tspan(2)
[k11,k12]=ode_function(y0(i,:));
ytemp(1:3)=y0(i,1:3)+k11*h/2;
ytemp(4:6)=y0(i,4:6)+k12*h/2;
[k21,k22]=ode_function(ytemp);
ytemp(1:3)=y0(i,1:3)+k21*h/2;
ytemp(4:6)=y0(i,4:6)+k22*h/2;
[k31,k32]=ode_function(ytemp);
ytemp(1:3)=y0(i,1:3)+k31*h;
ytemp(4:6)=y0(i,4:6)+k32*h;
[k41,k42]=ode_function(ytemp);
y0(i+1,1:3)=y0(i,1:3)+1/6*(k11+k21*2+k31*2+k41)*h;
y0(i+1,4:6)=y0(i,4:6)+1/6*(k12+k22*2+k32*2+k42)*h;
i=i+1;
end
tout=[tspan(1):h:tspan(2)];
yout=y0;
end
</pre><p>which outputs a time vector and the y vector which contains position (1:3) and velocity (4:6) components</p><p>and calls to the ode function which calculates the needed derivatives as follows:</p><pre class="language-matlab">function [f1,f2]=ode_function(y)
%y is a 1x6 row vector containing position (1:3) and velocity (4:6) components
u=3.98716708*10^5;
R=6378.137;
J=0.0010826267;
r=sqrt(y(1)^2+y(2)^2+y(3)^2);
a=[-3*J*u*R^2*y(1)/2/r^5*(1-5*y(3)^2/r^2),-3*J*u*R^2*y(2)/2/r^5*(1-5*y(3)^2/r^2),-3*J*u*R^2*y(3)/2/r^5*(1-5*y(3)^2/r^2)];
f1=y(4:6);
f2=-u*y/r+a;
end
</pre><p>anyways when i run this there is always an error in the RK function stating:</p><p>Not enough input arguments. (on the line beginning with r=)</p><p>any solutions to this please?</p>Andrew Shepherdhttps://jp.mathworks.com/matlabcentral/profile/authors/8635768-andrew-shepherdtag:jp.mathworks.com,2005:Question/3375142017-04-26T23:04:14Z2017-04-26T23:12:06Zerror while evaluating unicontrol callback!!!!<p><b><<what is the problem here !!!</b></p><img src = "/matlabcentral/answers/uploaded_files/76250/Untitled.png"><img src = "/matlabcentral/answers/uploaded_files/76249/Untitled1.png"><p>>></p>shatha Azzazihttps://jp.mathworks.com/matlabcentral/profile/authors/10212021-shatha-azzazitag:jp.mathworks.com,2005:Question/1021452013-05-07T21:21:00Z2017-04-26T23:07:55ZWhy do I get the error 'Subscript indices must either be real positive integers or logicals. ' ?<p>Why do I get the following error message:</p><pre class="error"> </pre><pre> Subscript indices must either be real positive integers or logicals. </pre>MathWorks Support Teamhttps://jp.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:jp.mathworks.com,2005:Question/3375132017-04-26T23:03:12Z2017-04-26T23:03:12ZHow to plot using the mod function?<p>I'm trying to plot an energy graph, and I'm having trouble plotting using the mod function. I don't understand why I cannot plot each point when mod(t,etime) == 0. Could someone please help me figure this out?</p><pre> function MDTest(T,sigma,m,dt,rc,L,k,etime)
tempcontrol=input('Would you like Temperature Control? [Y/N] \n','s');
while (tempcontrol ~= 'n' && tempcontrol ~= 'y')
tempcontrol=input('Would you like Temperature Control? [Y/N] \n', 's');
end</pre><pre> [xpos,ypos,vx,vy]=Initialize(sigma,L,k);
t=0;
count=0;
h=cell(length(vx));
while T > t
t=t+1;
count=count+1;
[xpos,ypos,vx,vy,U_tot,K_avg_tot,E_tot]=Step(xpos,ypos,vx,vy,dt,m,L,sigma,rc,k,tempcontrol);
if mod(t,etime) == 0</pre><pre> disp(['Total Energy is: ', num2str(E_tot)])
disp(count);</pre><pre> plot(t,(U_tot))
axis equal
%scatter(t,E_tot);
%set(ph, 'XData', t);
%set(ph,'YData', U_tot);
%,t,K_avg_tot,'-',t,E_tot,'-')</pre><pre> end</pre><pre> end</pre><pre> % </pre>Akhil Vasvanihttps://jp.mathworks.com/matlabcentral/profile/authors/7894695-akhil-vasvanitag:jp.mathworks.com,2005:Question/3375122017-04-26T23:01:11Z2017-04-26T23:11:22Zhow to solve a function to find local max. , local. min and absolute in a given interval<pre class="language-matlab">function E(f)
double x;
E=diff(f,x)
solve(E)
ezplot(E)
grid on
</pre>haneen ahmedhttps://jp.mathworks.com/matlabcentral/profile/authors/10226304-haneen-ahmedtag:jp.mathworks.com,2005:Question/3375112017-04-26T22:58:14Z2017-04-26T22:58:14ZHow to find the product of each row vector<p>THIS IS AN OLD TEST QUESTION OF MINE. I could not figure this out on the test. I would like to know how to solve this in its entirety please.</p><p>Write a program that calculates the product of each row of a matrix and stores the results in a column vector called prod_vec. The program should then calculate the difference between the minimum and maximum values in the prod_vec vector. Display your result using an fprintf statement. Program must work for any size vector. <b>*cannot use built in sum or sort functions to solve*</b></p><p>Test using vector B</p><p>B=[-3 4 7; 9 11 -13; -17 19 -23; -29 31 37; 39 41 47]</p>Devon Bloomhttps://jp.mathworks.com/matlabcentral/profile/authors/9961217-devon-bloomtag:jp.mathworks.com,2005:Question/3375102017-04-26T22:57:25Z2017-04-26T22:57:25ZHow do I use fft2 to compute the spatial frequency and temporal frequency for a 1D travelling wave? <p>I have 2 dimensional data for a travelling wave u(x,t) known over the rectangular domain [x,t]= [x1, x2] and [0, t2].</p><p>I want to compute the spatial and temporal frequnecy of the wave. Every wave (linear) can be represented as a sum of waves of the form exp(1i (kappa_i x - omega_j t) ). Here kappa_i is the ith spatial frequency present in u(x,t) and omega_j is the jth temporal frequency present in u. How do I obtain these using fft2?</p>Aditya Nandahttps://jp.mathworks.com/matlabcentral/profile/authors/8513295-aditya-nandatag:jp.mathworks.com,2005:Question/3375092017-04-26T22:55:15Z2017-04-26T22:55:15ZSimulink Series Elastic Actuator Dual Motors<p>Hello,
I will try to explain my problem the easist as possible.
I have a test bench evaluating the effect of a series elastic actuator. The SEA is actuated by a DC motor and a load is applied on it by another DC motor at the opposite extremity of the shaft in dual configuration ( so the two motor are opposite and I have so the representation DC moteur_act-Elastic link-DC moteur_load.
I want to represent the model on Simulink ( I know all the inertia, friction, damping, stiffness parameters). Since I have two motors the system has 2 dof's and the system is a matrix system 2x2 and I have 4 transfer functions : omega1=H1*Tau1 + H2*Tau2; omega2=H3*Tau1+H4*Tau2
The problem is that the load motor is controlled by torque (Tau2 = known) while the actuation motor is controlled by speed (omega1=known).How should I represent the system on Simulink since I don't know Tau1 and omega2 and that the inverse transfer function have a bigger degree on the numerator than on the denominator ( so not controllable...)
Thank you!
Tim</p>Jean Fabricechorizohttps://jp.mathworks.com/matlabcentral/profile/authors/9039702-jean-fabricechorizotag:jp.mathworks.com,2005:Question/3375032017-04-26T21:47:55Z2017-04-26T22:50:58ZButtonDownFcn on Axes after imshow<p>My ButtonDownFcn for my axes does not work after I call imshow</p><pre class="language-matlab">ax = axes;
set('ButtonDownFcn', @(h,e) disp('Hello'));
imshow(img, 'Parent', ax);
</pre><p>Of course I've read the myriad other post with the same problem and the solution seems to be something like this:</p><pre class="language-matlab">ax = axes;
set('ButtonDownFcn', @(h,e) disp('Hello'));
hold on
h = imshow(img, 'Parent', ax);
set(h, 'HitTest', 'off');
</pre><p>When I do this, it does indeed turn off the hittest for the image, but unfortunately when I click the image I am hitting the figure, not the axes. This is confirmed by the following:</p><pre class="language-matlab">>> hittest()
</pre><pre class="language-matlab">ans =
</pre><pre class="language-matlab">Figure (1) with properties:
</pre><pre> Number: 1
Name: ''
Color: [0.9400 0.9400 0.9400]
Position: [1232 1208 570 450]
Units: 'pixels'hittest()</pre><p><b>So how do I force my click to hit the axes and not the figure?</b> My only work around is to set the ButtonDownFcn for the image itself, but this is really not desirable because after some user input I need to overlay (with transparency) a new image which then becomes the top image. I could then set an identical ButtonDownFcn on this new image, but I'm hoping for a better solution than this work around.</p>Michael Vaianahttps://jp.mathworks.com/matlabcentral/profile/authors/7297328-michael-vaianatag:jp.mathworks.com,2005:Question/1955992015-04-01T12:04:14Z2017-04-26T22:49:43ZError starting MATLAB R2015a<p>Hello,
when i start the program appears an error window which says: "Error using eval undefined function 'workspacefunc' for input arguments of type 'struct'" and in the command window appears the following things:</p><pre class="language-matlab">Undefined function or variable 'computer'.
</pre><pre class="language-matlab">Error in matlabrc (line 76)
if strncmp(computer,'PC',2)
</pre><pre class="language-matlab">Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.mathworks.mlwidgets.graphics.ModelStateFactory.createNoSelectionModelState(ModelStateFactory.java:251)
at com.mathworks.mlwidgets.graphics.PlotToolSetFactory$3.parseComplete(PlotToolSetFactory.java:123)
at com.mathworks.mlwidgets.graphics.ModelStateFactory$ProductInfoListener$1$1.run(ModelStateFactory.java:1032)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
com.mathworks.jmi.MatlabException: Undefined function or variable 'computer'.
at com.mathworks.jmi.NativeMatlab.SendMatlabMessage(Native Method)
at com.mathworks.jmi.NativeMatlab.sendMatlabMessage(NativeMatlab.java:266)
at com.mathworks.jmi.MatlabLooper.sendMatlabMessage(MatlabLooper.java:120)
at com.mathworks.jmi.Matlab.mtFeval(Matlab.java:1710)
at com.mathworks.jmi.MatlabWorker.feval(MatlabWorker.java:197)
at com.mathworks.appmanagement.GetAppInstallDirectoryWorker.doOnMatlabThread(GetAppInstallDirectoryWorker.java:20)
at com.mathworks.appmanagement.GetAppInstallDirectoryWorker.doOnMatlabThread(GetAppInstallDirectoryWorker.java:7)
at com.mathworks.appmanagement.AbstractAppManagementMatlabWorker.runOnMatlabThread(AbstractAppManagementMatlabWorker.java:21)
at com.mathworks.jmi.MatlabWorker$2.run(MatlabWorker.java:79)
at com.mathworks.jmi.NativeMatlab.dispatchMTRequests(NativeMatlab.java:475)
</pre><p>I don't know how to fix it and I need to use MATLAB right now, please someone help me.
Thank you</p>Miguel Cruzhttps://jp.mathworks.com/matlabcentral/profile/authors/6291720-miguel-cruztag:jp.mathworks.com,2005:Question/3375082017-04-26T22:48:47Z2017-04-26T22:59:19ZHow do you write a program that sorts an entire matrix in increasing order?<p>THIS IS AN OLD TEST QUESTION THAT I COULD NOT FIGURE OUT. I would like to know how to solve this in its entirety please.</p><p>The values mus increase in the same order that a book is read. the program must work for any sized matrix. <b>cannot use any built in sum functions or sort functions</b></p><p>Test with matrix B</p><p>B = [ -3 4 7; 9 11 -13; -17 19 -23; -29 31 37; 39 41 47]</p>Devon Bloomhttps://jp.mathworks.com/matlabcentral/profile/authors/9961217-devon-bloomtag:jp.mathworks.com,2005:Question/3373262017-04-26T04:28:22Z2017-04-26T22:48:41ZImport mixed-format text file of unknown number of columns<p>Hi,
How do I import a text file that has unknown number of columns and contains various format? For example,</p><p>header1, header2, header 3, header4,...headerN</p><p>number, number, number, string,...number</p><p>number, number, number, string,...number</p><p>number, number, number, string,...number</p><p>...</p><p>I think the best bet is using fgetl and textscan, however I don't know how to deal with the unknown number of columns and therefore unknown pattern of format. I only know the first three and the last column are numeric.</p><p>Thank you very much</p>Jason Yanghttps://jp.mathworks.com/matlabcentral/profile/authors/10199034-jason-yangtag:jp.mathworks.com,2005:Question/3375072017-04-26T22:41:17Z2017-04-26T22:41:17ZComparing matrices of different size in matlab and storing values that are close<p>I have two matrices A and B. A(:,1) corresponds to an x-coordinate, A(:,2) corresponds to a y-coordinate, and A(:,3) corresponds to a certain radius. All three values in a row describe the same circle. Now let's say...</p><p>A =</p><p>[1,4,3]</p><p>[8,8,7]</p><p>[3,6,3]</p><p>B =</p><p>[1,3,3]</p><p>[1, 92,3]</p><p>[4,57,8]</p><p>[5,62,1]</p><p>[3,4,6]</p><p>[9,8,7]</p><p>What I need is to be able to loop through matrix A and determine if there are any rows in matrix B that are "similar" as in the x value is within a range (-2,2) of the x value of A (Likewise with the y-coordinate and radius).If it satisfies all three of these conditions, it will be added to a new matrix with the values that were in A. So for example I would need the above data to return...</p><p>ans =</p><p>[1,4,3]</p><p>[8,8,7]</p><p>Please help and thank you in advance to anyone willing to take the time!</p>Isaiah Stefan Englehttps://jp.mathworks.com/matlabcentral/profile/authors/8827749-isaiah-stefan-engletag:jp.mathworks.com,2005:Question/3375002017-04-26T21:19:28Z2017-04-26T22:35:06ZMatlab standalone can't find mclmcrrt9_0_1.dll, even though it's in my path. Permission problem? How do I fix this?<p>I compiled a standalone version of my code (Matlab R2016a, Runtime v9.0.1), and it runs perfectly on the computer that compiled it. However, I'm having issues running the standalone on another computer. In particular when I try to run the standalone from my home directory on the target computer, I get an error message saying</p><pre class="language-matlab">Could not find version 9.0.1 of the MATLAB Runtime
Attempting to load mclmcrrt9_0_1.dll
Please install the correct version of MATLAB Runtime.
</pre><p>However, I <i>do</i> have Runtime 9.0.1 installed on the target computer (I can see C:/Program Files/MATLAB/MATLAB Runtime/v901/runtime/win64/mclmcrrt9_0_1.dll). Also, C:/Program Files/MATLAB/MATLAB Runtime/v901/runtime/win64/ is in the path on the target computer (typing 'path' in Command Prompt shows it).</p><p>Further, the standalone <i>does</i> run if it's located in C:/Program Files/ instead of my home directory. However this leads to a problem where I don't have write permission in C:/Program Files/, meaning the standalone crashes with a "Permission denied" error.</p><p>To sum up:</p><p>1. If I run the standalone from C:/Program Files/, the dll is found, but the standalone crashes due to permission problems.</p><p>2. If I run the standalone from my home directory, it can't find the dll.</p><p>How do I solve this?</p>Greghttps://jp.mathworks.com/matlabcentral/profile/authors/3110703-gregtag:jp.mathworks.com,2005:Question/1022202011-12-16T16:59:00Z2017-04-26T22:24:58ZHow do I place errorbars on my grouped bar graph using function ERRORBAR in MATLAB 7.13 (R2011b)?<p>I use the following to create a grouped bar graph:</p><pre> model_series = [10 40 80; 20 50 90; 30 60 100];</pre><pre> model_error = [1 4 8; 2 5 9; 3 6 10];</pre><pre> bar(model_series, 'grouped');</pre><pre> hold on</pre><pre> errorbar( model_series,model_error)</pre><p>The result is a grouped bar graph with error bars placed in between each group of bars.</p><p>I would like to have ERRORBAR place the error bar in the center of each bar.</p>MathWorks Support Teamhttps://jp.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:jp.mathworks.com,2005:Question/3374102017-04-26T12:52:28Z2017-04-26T22:03:00ZHow can i save some data from GUI to show later in the same GUI?<p>I've Write a GUI code which will create an array and put some numbers inside it but my problem is how can i save this array (with some other data like name and age) to use it when running the GUI again, like adding SAVE and LOAD button to my GUI</p>Mouhammad Dabbashttps://jp.mathworks.com/matlabcentral/profile/authors/9964007-mouhammad-dabbastag:jp.mathworks.com,2005:Question/3374252017-04-26T14:18:59Z2017-04-26T22:00:22ZWhat is the difference between Scope and Floating Scope ?<p>What is the difference between Scope and Floating Scope ?</p>Mr.Beherahttps://jp.mathworks.com/matlabcentral/profile/authors/5921721-mr-beheratag:jp.mathworks.com,2005:Question/3375062017-04-26T21:58:16Z2017-04-26T21:58:16ZHow do i load a .mat file into matlab workspace when using matlab engine and calling from python?<p>Im calling a matlab function from python using matlab engine. Everything works fine except varialbles stored in a .mat file wont load to the matlab workspace, i get 'undefined or missing variable'. I tried loading from the matlab function and from python. It is not a path problem and i am confident i have isolated the problem to the loading of the .mat file.</p>Patrik Holmberghttps://jp.mathworks.com/matlabcentral/profile/authors/8863320-patrik-holmbergtag:jp.mathworks.com,2005:Question/3374352017-04-26T14:48:11Z2017-04-26T21:57:50ZHow can I read the output value of a Unit Delay block after a simulation?<p>I would like to break a simulation in few parts, so I need to save the final value of the Unit Delay blocks present in my Simulink model and write it in the initial value field for the next simulation.</p>Annachiara Palmisanohttps://jp.mathworks.com/matlabcentral/profile/authors/3140220-annachiara-palmisanotag:jp.mathworks.com,2005:Question/3374432017-04-26T15:10:40Z2017-04-26T21:56:35ZHow to model a variable RL branch?<p>Hi,
I would like to implementing a current controlled variable RL branch using integrator. I have one using
i(t) = integ( v(t) - i(t)*R ) / L, but this would develop an algebraic loop, which I want to avoid. Any ideas?</p><img src = "/matlabcentral/answers/uploaded_files/76231/2017-04-26_8-12-56.png">Kun Menghttps://jp.mathworks.com/matlabcentral/profile/authors/9534027-kun-mengtag:jp.mathworks.com,2005:Question/3375052017-04-26T21:54:17Z2017-04-26T21:54:17ZGaussian Process trains well, but always returns 0 on test set?<p>I am using the Statistics and Machine Learning toolbox function fitrgp() to try to generate a regression model that maps an input image and an estimate of a position within that image an actual point in that image. For example, imagine a picture of a dog. One input to the Gausssian Process is a function that estimates the position of the dog's nose in the image. The other input is the image of the dog. It should output a better estimate of the position of the dog's nose than the nose-finding function alone. The GP is trained on a set of images of dogs and hand-selected nose positions.</p><p>fitrgp() successfully trains on one set of images and estimated positions, and provides an excellent predictor of actual position. However, when we train on another set of images (slightly different size, contrast), the function always outputs a position of (0,0).</p><p><b>My question:
Where could this issue of always mapping to (0,0) regardless of input possibly be coming from?</b></p><p>The fitrgp line in the code looks like this:</p><pre class="language-matlab">parfor ii = 1:length(Model)
Model{ii} = fitrgp(dog_image_scan, positions(:, ii), 'KernelFunction', ...
'squaredexponential', ...
'Standardize', 1, 'Sigma', 1, 'BasisFunction', 'none');
end
</pre>Daniel Dichekhttps://jp.mathworks.com/matlabcentral/profile/authors/8605813-daniel-dichektag:jp.mathworks.com,2005:Question/3375042017-04-26T21:51:35Z2017-04-26T21:51:35Zmodulation and demodulation with psd function<p>hello some one help me with modumation and demodulation fsk ask maq with function of psd</p>hocine leaderhttps://jp.mathworks.com/matlabcentral/profile/authors/10226039-hocine-leadertag:jp.mathworks.com,2005:Question/3373552017-04-26T07:52:02Z2017-04-26T21:48:15ZType-Safe Interface とは何ですか？<p>MATLAB Compiler SDK の.NET アセンブリの統合で提供されている Type-Safe Interface のメリットは何ですか？</p>Takafumihttps://jp.mathworks.com/matlabcentral/profile/authors/1892029-takafumitag:jp.mathworks.com,2005:Question/3061742016-10-07T06:31:21Z2017-04-26T21:43:58ZCan't get MWNumericArray out of c#<p>I have this very simple test C# code that is supposed to get the number 24 into MATLAB</p><p>public MWNumericArray test()
{
int data = 24;
MWNumericArray array = data;
return array;
}</p><p>When I run test from MATLAB I get this error:</p><p>Error using mbm.sqlApache_Cassandra/test (line 24)
Message: The type initializer for 'MathWorks.MATLAB.NET.Arrays.MWNumericArray' threw an exception.
Source: MWArray
HelpLink:</p><p>When I get the full errorcode from c# it looks like this:</p><p>{System.TypeInitializationException: The type initializer for 'MathWorks.MATLAB.NET.Arrays.MWNumericArray' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MathWorks.MATLAB.NET.Arrays.MWArray' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MathWorks.MATLAB.NET.Utility.MWMCR' threw an exception. ---> System.Exception: Trouble initializing libraries required by .NET Assembly.</p><pre> at MathWorks.MATLAB.NET.Utility.MWMCR..cctor()
--- End of inner exception stack trace ---
at MathWorks.MATLAB.NET.Arrays.MWArray..cctor()
--- End of inner exception stack trace ---
at MathWorks.MATLAB.NET.Arrays.MWNumericArray.get__Inf()
at MathWorks.MATLAB.NET.Arrays.MWNumericArray..cctor()
--- End of inner exception stack trace ---
at MathWorks.MATLAB.NET.Arrays.MWNumericArray.op_Implicit(Int32 scalar)
at cassandra_sql.csql.test() in c:\Mercurial\MBM\c#\cassandra_sql\cassandra_sql\csql.cs:line 81}</pre><p>Any idea what to do ?</p>Danhttps://jp.mathworks.com/matlabcentral/profile/authors/1283916-dantag:jp.mathworks.com,2005:Question/3375022017-04-26T21:38:12Z2017-04-26T22:36:47ZError executing [ap, recall, precision] = evaluateDetectionPrecision(results, expectedResults);<p>I have modified the FasterRCNN tutorial and have successfully created a detector, however when I get to the testing step I cannot execute the final code. The errors I get are below :</p><pre> Error using vision.internal.detector.evaluationInputValidation>checkGroundTruthTable (line 101)
Invalid bounding box in row 1, column 1 of the training data table: Cell contents reference from a non-cell array
object.</pre><pre class="language-matlab">Error in vision.internal.detector.evaluationInputValidation (line 8)
checkGroundTruthTable(groundTruth, height(detectionResults), mfilename);
</pre><pre class="language-matlab">Error in evaluateDetectionPrecision (line 94)
vision.internal.detector.evaluationInputValidation(detectionResults, ...
</pre><pre class="language-matlab">Error in RAT_DeepLearningFasterRCNNObjectDetectionExample (line 318)
[ap, recall, precision] = evaluateDetectionPrecision(results, expectedResults);
</pre><p>I have looked my results table and it seems to be in the correct format, with the boxes, the scores for each and the labels. What could be causing this error?</p>Audrey Eastonhttps://jp.mathworks.com/matlabcentral/profile/authors/7654586-audrey-eastontag:jp.mathworks.com,2005:Question/2166962015-05-14T14:57:44Z2017-04-26T21:36:56ZCommand Window gone crazy ( scrolls on it's own )<p>My command window has lost its mind.
It behaves normally but after I type some commands and get some output, the command window automatically scrolls up until I can't see what I just typed. The only way out is to type clc. But even that doesn't completely help.I tried typing "home" but that seems to have made things worse (I <b>think</b> it's now scrolling to a different position... or something).</p><p>How can I get back to normal?
I checked all the Matlab preferences and... nuttin!</p><p>Help?</p><p>Dan</p>Danhttps://jp.mathworks.com/matlabcentral/profile/authors/13437-dantag:jp.mathworks.com,2005:Question/3374992017-04-26T21:09:51Z2017-04-26T22:31:33Zhow can I generate a 3D surface having 3 equations with some inequalities? I have had no luck with this type of figures<pre class="language-matlab">% Plot the surface in 3D of the following equations, the figure is supposed to look as a mobius band making a triangular shape.
</pre><pre class="language-matlab">%Equation1=((u-(sqrt(3).*v))/2);
</pre><pre class="language-matlab">%Equation2=(3.141592-(8/sqrt(3))- (2*cos((sqrt(3).*u+v)/4)));
</pre><pre class="language-matlab">%Equation3=(2*sin(((sqrt(3)).*u+v)/4));
</pre><pre class="language-matlab">%u and v are parameters of the surface, but they are also inequalities.
</pre><pre class="language-matlab">%inequality 1 : -1 <= v <= 1;
</pre><pre class="language-matlab">%inequality 2 : ((-2*3.141592-v)/sqrt(3))) <= u <= ((2*3.141592-v)/sqrt(3)));
</pre><pre class="language-matlab">%%CODE
</pre><pre class="language-matlab">syms v u ;
</pre><pre class="language-matlab">X = ((u-(sqrt(3).*v))/2);
</pre><pre class="language-matlab">Y = (3.141592-(8/sqrt(3))- (2*cos((sqrt(3).*u+v)/4)));
</pre><pre class="language-matlab">Z = (2*sin((sqrt(3).*u+v)/4));
</pre><pre class="language-matlab">I=(v>=-1) & (v<=1) & (u>=((-2*3.141592-v)/sqrt(3))) & (u<=((2*3.141592-v)/sqrt(3)));
</pre><pre class="language-matlab">ezsurf(X(I),Y(I),Z(I));
</pre>Juan Albarracinhttps://jp.mathworks.com/matlabcentral/profile/authors/4963995-juan-albarracintag:jp.mathworks.com,2005:Question/3368282017-04-23T17:32:55Z2017-04-26T21:08:17ZError using loadlibrary when trying to load dll<p>I'm trying to use <a href = "http://www.robots.ox.ac.uk/~timork/NPWindowsMarginals.zip">Dr. Kadir's NP windows code</a>. He says it's MATLAB code written in C/C++ and there are .m and .dll files. More specifically, I'm trying to use PDF1DLinear. But when I do loadlibrary('PDF1DLinear'), I get an error: Undefined function or variable 'PDF1DLinear_proto'. Am I not loading the library properly? Am I missing a file?</p>light_darkhttps://jp.mathworks.com/matlabcentral/profile/authors/4530883-light_darktag:jp.mathworks.com,2005:Question/3374982017-04-26T21:06:10Z2017-04-26T21:06:10ZGet inverse of scalar in hdl code generation<p>hi,</p><p>I am implementing an algorithm in matlab for hdl code generation which requires inverse of a variable scalar e.g 1/x . Most articles state that the divisor must be a constant and a power of two. Only thing I can find is reciprocal block but it is available in simulink and my design is in matlab mfile.</p><p>Is their any function or way of doing this in matlab mfile?</p>taaha saleem bajwahttps://jp.mathworks.com/matlabcentral/profile/authors/3415314-taaha-saleem-bajwatag:jp.mathworks.com,2005:Question/3374972017-04-26T21:05:50Z2017-04-26T21:05:50ZCell String length limitation on Table<p>Hello,
I am using a table to store information. One of the variables is a string of the path to a file that was used to derive the information on that row. The point is I need to access the full data later, but need to keep track of some statistical computations in the table.
The problem is, the variable is set to a specific size (apparantly the first entry of the first row) If i try editing the entry to add a longer or shorter cell string, I get the error:
"Subscripted assignment dimension mismatch for table variable 'XX_LOC'"
I've tried several approaches like indexing the actual char locations like:
TABLE(ROW,:).XX_LOC(1:length(LOCATION)) = LOCATION
This solves the problem for shorter cells but crashes for longer (since I am referencing a location larger than the variable length).</p><p>Any Ideas how I can work with text in a variable of a table?</p><p>Thanks</p>Ziad Abou wasahttps://jp.mathworks.com/matlabcentral/profile/authors/9796235-ziad-abou-wasatag:jp.mathworks.com,2005:Question/1094322013-12-11T13:51:21Z2017-04-26T21:03:07ZSimulink - Serial Receive - Header<p>Hey,</p><p>I'm reading serial data from a Interial Measurement Unit and dont know how to define a header properly.
One frame is 56byte long (with 48byte of data). On the picture you can see the Block Parameters on the left and the Data on the right. The first 2 bytes (255 2) are the header, ending is 3.</p><p>I don't know the synatx to define the header, when i simply type 255 into header, i get only zeros for data.</p><p>Thanks for helping!</p><img src = "/matlabcentral/answers/uploaded_files/5673/Simulink.png">Kaihttps://jp.mathworks.com/matlabcentral/profile/authors/4581404-kaitag:jp.mathworks.com,2005:Question/3374732017-04-26T19:13:06Z2017-04-26T21:00:18ZHow do I join individual scatter points with a line?<p>I'm trying to plot a set of 10 data points, and connect corresponding pairs of them together, each with different colour. I'm very unexperienced, so be prepared for horrendously inefficient code:</p><pre class="language-matlab">x1 = 0.967;
x1b = 0.960;
y1 = 0.14;
y1b = 0.172;
x2 = 0.952;
x2b = 0.942;
y2 = 0.272;
y2b = 0.331;
x3 = 0.937;
x3b = 0.925;
y3 = 0.397;
y3b = 0.479;
x4 = 0.923;
x4b = 0.909;
y4 = 0.516;
y4b = 0.619;
x5 = 0.910;
x5b = 0.894;
y5 = 0.630;
y5b = 0.751;
</pre><pre class="language-matlab">sz1 = 40;
sz2 = 30;
c1 = 'k';
c2 = 'b';
c3 = 'g';
c4 = 'r';
c5 = 'c';
sym = 'o';
xlim([0.89 1.01])
ylim([0 0.8])
scatter(x1,y1,sz1,c1,sym,'filled'); hold on;
scatter(x1b,y1b,sz2,c1,sym,'filled'); hold on;
scatter(x2,y2,sz1,c2,sym,'filled'); hold on;
scatter(x2b,y2b,sz2,c2,sym,'filled'); hold on;
scatter(x3,y3,sz1,c3,sym,'filled'); hold on;
scatter(x3b,y3b,sz2,c3,sym,'filled'); hold on;
scatter(x4,y4,sz1,c4,sym,'filled'); hold on;
scatter(x4b,y4b,sz2,c4,sym,'filled'); hold on;
scatter(x5,y5,sz1,c5,sym,'filled'); hold on;
scatter(x5b,y5b,sz2,c5,sym,'filled'); hold on;
line(x1,x2); hold on;
</pre><p>I have no doubt there is a much more efficient way to do this, but I couldn't figure it out, so I went for the brute force method. All there's left to do is connect the pairs together. I'd like to connect a line between the points (x1,y1) and (x1b, y1b), another line between the points (x2,y2) and (x2b,y2b), and so on. How do I do this?</p>David Anthonyhttps://jp.mathworks.com/matlabcentral/profile/authors/9349930-david-anthonytag:jp.mathworks.com,2005:Question/3374962017-04-26T20:55:46Z2017-04-26T20:55:46ZHow to access Intensity from ROS PointCloud2 message?<p>I am able to access xyz using readxyz function from ROS PointCloud2 message. How can I access Intensity and ring values?</p>Rita Chattopadhyayhttps://jp.mathworks.com/matlabcentral/profile/authors/5586150-rita-chattopadhyaytag:jp.mathworks.com,2005:Question/3374952017-04-26T20:55:45Z2017-04-26T21:20:51ZMeasurement Computing DAQ: USB-1608FS-PLUS not recognized.<p>I have the latest version of Matlab 2017a (9.2) installed with</p><ul><li><a href = "https://se.mathworks.com/products/daq.html?s_tid=AO_PR_info">Data Acquisition Toolbox version 3.11</a></li><li><a href = "https://se.mathworks.com/hardware-support/measurement-computing.html">Data Acquisition Toolbox Support Package for Measurement Computing Hardware version 17.1.0</a></li><li><a href = "https://se.mathworks.com/hardware-support/nidaqmx.html?s_tid=AO_HS_info">Data Acquisition Toolbox Support Package for National Instruments NI-DAQmx Devices</a></li></ul><p>According to the documentation for the <a href = "https://se.mathworks.com/hardware-support/measurement-computing.html"><i>Support Package for Measurement Computing</i></a> , it is supposed to support the <i>USB-1608FS-PLUS</i> DAQ. But Matlab doesn't seem find the DAQ. I'm sure that I have the packages installed correctly.</p><pre class="language-matlab">>> daq.getVendors()
ans =
Number of vendors: 2
index ID Operational Comment
----- --- ----------- ---------------------------
1 ni true National Instruments
2 mcc true Measurement Computing Corp.
</pre><p>I've been using National Instruments USB-6008 Data Acquisition DAQ with no trouble.</p><p>When using the DAQami software from MCC - I find the USB-1608FS-PLUS DAQ and am able to acquire the signal as expected.</p><p>I would really want to use Matlab for acquiring the data. Can anyone help me on this?</p>Bjartmar Harðarsonhttps://jp.mathworks.com/matlabcentral/profile/authors/2987353-bjartmar-hardarsontag:jp.mathworks.com,2005:Question/145252011-08-25T16:51:38Z2017-04-26T20:54:32Zvolatility of intraday (minute data)<p>Hi there,</p><p>I was wondering on how to calculate the volatility on 1 day prices which are minute by minute? If anybody could help me I would appreciate it.</p><p>Reason why I want to know as I want to check during the day graphically the most volatile times.</p><p>Best,</p>Mate 2uhttps://jp.mathworks.com/matlabcentral/profile/authors/2664792-mate-2utag:jp.mathworks.com,2005:Question/3374942017-04-26T20:52:42Z2017-04-26T20:55:05ZHelp developing an image frame sequence generator<p>Hi all,</p><p>I am doing a project where I have to create frames of images, to show a track path of an object and detect it. The end goal of my code is to create a line that shows the track path of the object as it moves and a box to detect the object at it's final position on the image (original image and desired output image that I would like is shown as an example).</p><p>In order to do this, I need help with generating the frames with different object positions. I have already created an object from an array (using the zeros function) with a set intensity value and have overlayed it on to the original background image (using imadd(image, object)), so it is at a starting position. Any idea on how I can move the object
and produce frames with the different positions? Also showing a streak to show the track path?</p><p>I would really appreciate any help with this.</p><p>Kind regards,</p><p>Vanessa</p>Vanessahttps://jp.mathworks.com/matlabcentral/profile/authors/10146013-vanessatag:jp.mathworks.com,2005:Question/3374922017-04-26T20:47:17Z2017-04-26T20:49:16ZHow to get the reminder of a vector divided by matrices<p>I try to get the reminder but not sure how to do so.
Generally,
f(z) = A(z)*fo(z) + r(z), f(z), fo(z), and r(z)are vertical 1 by n vectors of polynomials contain z, A are n by n matrices of polynomials contain z.The reminder r(z)needs to have a lower order than A(z). If only f and A are known, how to find r?
for example,
[z^2+1; 1]=[z 0; 0 1]*[z 1]+[1 0], f=[z^2+1; 1], A=[z 0; 0 1], fo=[z 1], r=[1 0].</p>DmArcherhttps://jp.mathworks.com/matlabcentral/profile/authors/8393199-dmarchertag:jp.mathworks.com,2005:Question/3374932017-04-26T20:48:57Z2017-04-26T20:48:57ZI am using the 3 phase dynamic load and want to put in my own P and Q values for each phase. Is there anyway to add values for each phase individually, and not the same values for all 3 phases? <p>I have been trying to trick the dynamic 3 phase load by connecting the b and c phase to ground or to each other. I have also tried the single phase dynamic load, but it does not have the option for external P and Q. I am replicated a situation that occurred in the past based on acquired data and need these values in the simulation.</p>Kale Kauwehttps://jp.mathworks.com/matlabcentral/profile/authors/9687515-kale-kauwetag:jp.mathworks.com,2005:Question/3365062017-04-21T12:32:12Z2017-04-26T20:47:32ZaddTriggerConnection to mcc analog input device<p>I am trying to create a program for acquiring data with an MCC USB-1602 device.
This has not been possible with the session-based approach until Matlab 2017a. I now have this version, and have downloaded Measurement Computings hardware support package.
I can now create a session and add channels to it. I can use it to gather data. So far everything is ok.
The problem is that I cannot add triggers to the session object.
When I use the function "addTriggerConnection" I get the following error:
"Method 'addTriggerConnection' is not supported on objects of class 'daq.sdk.Session'."</p><p>Is this a bug? Or is the hardware support package for MCC not complete?
When I try to debug, I feel like there are things missing from the vendor specific session subclass.</p><p>Any advice is greatly appreciated!</p><p>/
Patrik</p>Patrikhttps://jp.mathworks.com/matlabcentral/profile/authors/4613014-patriktag:jp.mathworks.com,2005:Question/3374822017-04-26T20:15:43Z2017-04-26T20:46:24Zimshow index issues with display<p>I currently have a 423x27x501 3D grayscale image, which I want to view slice by slice. The image is stored in a variable called Cell.</p><p>I want imshow to show me the different slices of Cell along the 'xz' plane, so in this case each image would be a 423x501 image.
If I want to view slices of the xy plane, I can simply write my code as follows</p><pre class="language-matlab">for i=1:27
figure(i)
imshow(Cell(:,:,i))
end
</pre><p>In each iteration of the above loop, Cell(:,:,i) is stored as a 453x27 uint8 variable, which is friendly to imshow.</p><p>However, if I do something similar for the xz plane,</p><pre class="language-matlab">for i=1:27
figure(i)
imshow(Cell(:,i,:))
end
</pre><p>Then instead I get an error complaining about the size of the image.
In the second loop, Cell(:,i,:) is stored as a 453x1x501 uint8 variable, which confuses imshow because it thinks of this as a rank 3 tensor instead of a 2D matrix, even though it is essentially a plane.</p><p>So, is there a way to get my script to display the relevant planes via use of indexing? Or alternately is there a way to convert from a 453x1x501 variable to a 453x501 variable so that imshow can accept the input?</p><p>Thanks in advance!</p>Pratik Samanthttps://jp.mathworks.com/matlabcentral/profile/authors/6797958-pratik-samanttag:jp.mathworks.com,2005:Question/3374872017-04-26T20:28:22Z2017-04-26T20:43:46ZMultiple outputs in function not showing. <p>I'm trying to write a function for calculating the fixed point iteration for a system of 2 equations. Although my function works it only displays the x-output. My code is below:</p><pre> %%Solves a system of 2, 2 variable equations using the fixed point
%%iteration method.
%Fx=function of two variables of the form x=g(x,y)
%Fy=function of two variables of the form y=g(x,y)
%Xest=initial estimate for x-value of root
%Yest=initial estimate for y-value of root
%imax=number of iterations
%Xs=output of FixedIterationRoot, stores all values of x.
%Ys=output of FixedIterationRoot, stores all values of y.</pre><pre> function [Xs , Ys]= FixedIterationRoot_sys2(Fx,Fy,Xest,Yest,imax)
Xi(1)=Xest;
Yi(1)=Yest;
syms x y
dFx=diff(Fx,x);
dFy=diff(Fy,y); %finds derivative of Fun
if abs((subs(dFx,Xest))+abs(subs(dFy,Yest)))>=1 %Stating the condition of convergence.
disp('Error: algorithm does not converge')
return
else
for i=2:imax % Calculating the solutions to fixed point equation.
Xi(i)=subs(Fx,[x,y],[Xest,Yest]);
Yi(i)=subs(Fy,[x,y],[Xest,Yest]);
Xest=Xi(i);
Yest=Yi(i);
end</pre><pre> end
Xs=Xi;
Ys=Yi;
end</pre>Amanda Chunhttps://jp.mathworks.com/matlabcentral/profile/authors/10081403-amanda-chuntag:jp.mathworks.com,2005:Question/3374772017-04-26T19:42:44Z2017-04-26T20:43:40ZHow can I create a cell array whose cells are strings based on a sequence of integers 1:N (for any N)?<p>I want my function to add a legend to a plot where the legend has a variable number of items depending on N: e.g. '1', '2', '3' if N=3. The help file tells me I can use a matrix or a cell array: legend(M). But I can't find a way of creating a suitable array without fixing the number of cells. For example,</p><pre class="language-matlab">num2cell(1:N)'
</pre><p>doesn't help because legend() only seems to accept cell arrays containing strings, not numeric values. And int2str() doesn't help because it adds spaces in between the numbers.</p>Richard Guntonhttps://jp.mathworks.com/matlabcentral/profile/authors/9842073-richard-guntontag:jp.mathworks.com,2005:Question/3374722017-04-26T18:55:11Z2017-04-26T20:40:43ZDesign a graphic user environment using MATLAB that contains an axis which can acquire a signal upon a mouse click. For each mouse click, MATLAB code has to remember the coordinate position and finally, when a double mouse click is pressed, the coorD<p>Design a graphic user environment using MATLAB that contains an axis which can acquire a signal upon a mouse
click. For each mouse click, MATLAB code has to remember the coordinate position and finally, when a
double mouse click is pressed, the coordinates are to be connected and signal will be displayed in the axis as a
discrete time signal. Include a button “Sketch My Signal” to acquire the signal and include the radio buttons
“Continuous” and “Discrete” to choose between continuous time and discrete time signals. Model of a GUI looks
something like the one shown in project number 1. Key functions are
function [Sig1] = Aquire_Discrete_Signal1()
function [Sig2] = Aquire_Discrete_Signal2()</p>CHAITANYA GONEhttps://jp.mathworks.com/matlabcentral/profile/authors/10225381-chaitanya-gonetag:jp.mathworks.com,2005:Question/3374782017-04-26T19:43:40Z2017-04-26T20:40:42ZCreating a matrix by sorting the colums of another matrix<pre class="language-matlab">0 4;
5 3;
1 3;
0 5;
0 1
</pre><p>I have a matrix like this. Its size is 3x2 but it can be nx2. I want to sort it like that; [0 4; 0 1 3;0 5 3]. What i mean by that is the code should create row which starts from 0 and follows the next number. If the next number is stored also in the first column then the row should take the next next number and so on. How can i write the code? Thx</p>qwe asdhttps://jp.mathworks.com/matlabcentral/profile/authors/8918323-qwe-asdtag:jp.mathworks.com,2005:Question/3372402017-04-25T17:02:58Z2017-04-26T20:39:15ZWriting N+1 by N+1 Matrix in MATLAB<p>How can i write and use the attached matrix in MATLAB for any value of N?</p><img src = "/matlabcentral/answers/uploaded_files/76150/Matrix.png">R shahhttps://jp.mathworks.com/matlabcentral/profile/authors/8356530-r-shahtag:jp.mathworks.com,2005:Question/3374912017-04-26T20:37:16Z2017-04-26T20:39:33ZCan the IP address and port of UDP blocks be changed at run-time?<p>Is there a way to change where a UDP block is sending data at run-time?</p><p>This UDP block can be the one in the Instrument Control Toolbox, Raspberry Pi Hardware Support Package, etc.</p><p>It doesn't matter, I just need any UDP send block that can have it's parameters changed at run-time.</p><p>Note: it must be supported for code generation.</p><p>Regards,</p><p>Tyler</p>Tylerhttps://jp.mathworks.com/matlabcentral/profile/authors/8307952-tylertag:jp.mathworks.com,2005:Question/3374902017-04-26T20:36:41Z2017-04-26T20:36:41ZSolving a System of 2nd Order Linear ODE? "Explicit solutions cannot be found"<p>I've been trying to solve the linear 2nd order system below, but Matlab keeps saying there isn't a solution. Clearly, there's a solution because the solution will be the intersection of two sine and cosine waves of the same amplitude and phase shift. Because of this, I'm assuming the error is coming from syntax instead of from the math. Can someone take a look at it? Thanks in advanced.</p><p>This is the systems of equations I'm trying to solve:</p><p>x'' = G*M*sin(theta + 2*pi*t)/(x^2 + y^2)</p><p>y'' = G*M*cos(theta + 2*pi*t)/(x^2 + y^2)</p><p>Here's the code:</p><p>% variables</p><p>G = 6.674 * (10.^(-11));</p><p>M = 1.9886 * (10.^30);</p><p>t = 0:.005:.7;</p><p>xi = .44503 * 149.598 * 10.^9; % Initial x dist (AU --> m)</p><p>yi = .88106 * 149.598 * 10.^9; % Initial y dist (AU --> m)</p><p>thetai = atan((yi/xi)); % Initial angle from x-axis</p><p>% Calculations</p><p>syms x(t) y(t)</p><p>odex = diff(x) == diff(((G*M)./(x.^2 + y.^2)) .* cos(thetai + (2*pi).*t));</p><p>odey = diff(y) == diff(((G*M)./(x.^2 + y.^2)) .* sin(thetai + (2*pi).*t));</p><p>odes = [odex; odey]</p><p>S = dsolve(odes) % Returns not solvable here</p>Praxis Bayshttps://jp.mathworks.com/matlabcentral/profile/authors/10225749-praxis-baystag:jp.mathworks.com,2005:Question/2836242016-05-11T00:51:52Z2017-04-26T20:36:25Zsimulink serial receive header<p>I'm reading serial data from FPGA (RS232).But I dont know how to define a header properly.
Thanks for helping!</p>tjh thttps://jp.mathworks.com/matlabcentral/profile/authors/8174452-tjh-ttag:jp.mathworks.com,2005:Question/3361402017-04-19T16:54:18Z2017-04-26T20:35:36ZCan Instrument Control Toolbox use NI-SCOPE driver to acquire from two devices in parallel?<p>We have two PXIe NI digitizers using the NI-SCOPE platform. We are able to acquire from one individually in MATLAB but would like to coordinate acquisition with both at the same time in parallel. Is this possible with MATLAB?</p>Clayhttps://jp.mathworks.com/matlabcentral/profile/authors/2295765-clay