https://ww2.mathworks.cn/matlabcentral/answers/questionsMATLAB Answers — New Questions2019-06-18T07:03:53Ztag:ww2.mathworks.cn,2005:Question/4676132019-06-18T07:03:53Z2019-06-18T07:03:53ZWhich Simulink block can receive different types of Signals as Input and give output accordingly?Hi Community Members!
Which Simulink block can receive different types of Signals as Input and give output accordingly? Sunil Kumar Girihttps://ww2.mathworks.cn/matlabcentral/profile/authors/8494475-sunil-kumar-giritag:ww2.mathworks.cn,2005:Question/4676092019-06-18T05:54:56Z2019-06-18T06:58:23ZHow to plot an ellipse with known center and vectors denoting the length of principal axis?Hello,
I have been given the center of the ellipse, the length of the major and minor axis, and the vector which represents these axes. How should I go about this question? Please helpKartikeya Sharmahttps://ww2.mathworks.cn/matlabcentral/profile/authors/15661081-kartikeya-sharmatag:ww2.mathworks.cn,2005:Question/4676122019-06-18T06:55:59Z2019-06-18T06:55:59ZHow to find eigenvalue of a matrix having three variables?I have a 33X33 matrix with three variables (KA1, KA2, KA3). I want to take its eigenvalues. The eigenvalue should be a function of these three variables. Any idea? Thanks.
A =
[ -0.1754, -0.01261, 0.005666, 0.03756, 0.02875, 0.01006, -0.04169, -0.002683, 0.000833, -0.02971, -0.02183, -0.01673, 0.004094, -0.002681, -0.001413, 0, 0, 0, 0.1116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[ -0.2057, -13.31, -0.0657, 0.03443, 13.41, -0.1167, 0.5673, 0.00206, -0.000514, 0.4043, 0.01676, 0.01032, -0.1771, 0.2988, -0.1217, 0, 0, 0, 0, 0.1667, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[ 0.1378, -0.09722, -1.388, -0.02306, 0.2217, 1.044, -0.3221, -0.004694, -1.429e-5, -0.2296, -0.03819, 0.0002871, 0.1011, 0.06514, -0.1663, 0, 0, 0, 0, 0, 0.1698, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[ 10.12, 0.5683, -0.2554, -8.933, -1.296, -0.4534, 1.879, 0.121, -0.03755, 1.339, 0.984, 0.7541, -0.1846, 0.1209, 0.06369, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[ 1.076, 30.76, 0.3436, -0.1801, -32.16, 0.6101, -2.967, -0.01077, 0.002688, -2.114, -0.08764, -0.05399, 0.9263, -1.563, 0.6364, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[ 5.039, -3.556, 21.52, -0.8434, 8.11, -27.88, -11.78, -0.1717, -0.0005228, -8.397, -1.397, 0.0105, 3.699, 2.383, -6.082, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[ 0, 0, 0, 0, 0, 0, -3.226, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[ -0.3163, 0.07269, -0.02432, 0.05294, -0.1658, -0.04318, -0.3983, -16.94, -0.01262, -0.2839, -15.62, 0.2534, 0.112, -0.2546, 0.1426, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[ 0.1245, -0.001107, 0.01228, -0.02083, 0.002524, 0.0218, 0.2527, -0.01684, -10.82, 0.1801, -0.137, -8.9, -0.0731, -0.08933, 0.1624, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[ -0.3569, 0.9731, -0.3902, 0.05974, -2.219, -0.6928, -38.3, -0.03862, 0.02101, -36.0, -0.3142, -0.4219, 2.197, -1.111, -1.086, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[ -2.2, 0.5057, -0.1692, 0.3683, -1.153, -0.3004, -2.771, -13.36, -0.08779, -1.975, -17.17, 1.763, 0.7792, -1.771, 0.992, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[ -1.458, 0.01296, -0.1438, 0.244, -0.02957, -0.2554, -2.961, 0.1973, -5.191, -2.11, 1.605, -8.184, 0.8565, 1.047, -1.903, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[ -2.86, -11.95, 4.807, 0.4787, 27.26, 8.535, 86.55, 0.4028, -0.2332, 61.68, 3.277, 4.683, -26.26, 13.27, 12.99, -0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7.974, 0, 0, 0, 0, 0]
[ 3.478, 74.73, 10.82, -0.5822, -170.4, 19.21, -170.5, -4.851, -1.489, -121.5, -39.46, 29.91, 51.65, -95.45, 43.8, 0, -0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29.45, 0, 0, 0, 0]
[ 18.45, -61.83, -61.2, -3.087, 141.0, -108.7, -349.2, 6.465, 5.145, -248.9, 52.59, -103.3, 106.1, 92.13, -198.2, 0, 0, -0.3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62.62, 0, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -3.365, 0, 0, 0, 0, 0, 3.185, 0, 0, 0, 0, 0, 0, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -3.947, 0, 0, 0, 0, 0, 3.185, 0, 0, 0, 0, 0, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -3.536, 0, 0, 0, 0, 0, 3.185, 0, 0, 0, 0, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5143, 0, 0, -2.857, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5143, 0, 0, -2.857, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5143, 0, 0, -2.857, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[ -5.322*KA1, 0.2824*KA1, -0.1263*KA1, 0.8907*KA1, -0.6439*KA1, -0.2243*KA1, -0.2677*KA1, 0.05718*KA1, -0.01764*KA1, -0.1908*KA1, 0.4652*KA1, 0.3543*KA1, -0.06187*KA1, 0.04441*KA1, 0.01746*KA1, 0, 0, 0, -0.9*KA1, 0, 0, 5.0*KA1, 0, 0, -5.0, 0, 0, 0, 0, 0, 0, 0, 0]
[ -1.192*KA2, 1.977*KA2, -0.2315*KA2, 0.1995*KA2, -4.509*KA2, -0.411*KA2, 0.816*KA2, 0.4063*KA2, -0.02598*KA2, 0.5816*KA2, 3.305*KA2, 0.5217*KA2, -0.2788*KA2, 0.3427*KA2, -0.06391*KA2, 0, 0, 0, 0, -0.9*KA2, 0, 0, 5.0*KA2, 0, 0, -5.0, 0, 0, 0, 0, 0, 0, 0]
[ -1.237*KA3, 0.541*KA3, -0.8733*KA3, 0.207*KA3, -1.234*KA3, -1.55*KA3, 0.8115*KA3, 0.09036*KA3, -0.1336*KA3, 0.5783*KA3, 0.7351*KA3, 2.683*KA3, -0.2786*KA3, -0.01786*KA3, 0.2965*KA3, 0, 0, 0, 0, 0, -0.9*KA3, 0, 0, 5.0*KA3, 0, 0, -5.0, 0, 0, 0, 0, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -10.0, 0, 0, 10.0, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -10.0, 0, 0, 10.0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -10.0, 0, 0, 10.0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1.061, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -20.0, 0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1.061, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -20.0, 0]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1.061, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -20.0]
Ismaelhttps://ww2.mathworks.cn/matlabcentral/profile/authors/1344148-ismaeltag:ww2.mathworks.cn,2005:Question/4676082019-06-18T05:53:25Z2019-06-18T06:53:14ZGetting a variable and its value from a csv file Hi,
i got a csv file with several colums in the form of
a parameter 1
b species 2
c parameter 3
etc. For now i am using
datastart = readtable('input_parameter_example.csv');
ds = datastart{1:128,{'value'}};
var1=str2double(cell2mat(ds(1,1)));
which gets the number value for a specific column from the table, i set the name and attach the value by using str2double(cell2mat()). But thats not what i want in the end. What i want is that this happens automatically, so i want to read from the table that the paramater named "a" has the value "1", and i want to use this parameter later on in a another script. So i want to read dynamically the variable name and its value, and when i call the script, the variable and its value should be known. I did google a lot but cannot find a solution.
Thanks Nicolas Fischerhttps://ww2.mathworks.cn/matlabcentral/profile/authors/10391322-nicolas-fischertag:ww2.mathworks.cn,2005:Question/4673612019-06-16T22:15:11Z2019-06-18T06:38:41Zhow to extract data from the fixed-width-field format using fscanf or textscanI am trying to parase large file, containing among others numerical data fixed in fixed-width-fields format without whitespaces (or any other separators) between the fields. Consider the example:
1223244
55 6 788
1122 3 4
In this text each line contains four numbers each - two digits wide. Expected result after parsing this flie is:
1 22 33 44
55 6 7 88
11 22 3 4
The prerformance is important for me, as the files I read may be hunreds of MBs large. From my experiments I discovered, that fgetl() is drammatically slower, than fscanf (I did not check the performance, but I expect, that textscan should also be significantly faster.
The problem is that I cannot find the way to parse data like this with fscanf or textscan. Could someone tell, if it is possible at all? If not, is there any other way to parse such a text file with good performance?
P.S. format of actual string is, of course, somewhat more complicated. Example string is:
1101332.18685714711829.064533733772535.874264373485 0 0
this string should be parsed into the numbers with the following widths: 8, 16, 16, 16, 8, 8, which in this particular case would result in the following numbers:
110
1332.18685714711
829.064533733772
535.874264373485
0
0
P.S.2: Differnence between the performance of fgetl and fscanf: On my laptop for the file, which contains 35597 lines the following code with fscanf complete in 0.253614 seconds
function [data] = test_fscanf_nodes_only_01()
file_name = 'myfile.txt';
file_id = fopen (file_name, 'rt');
cleanup_obj = onCleanup(@() fclose(file_id));
data = fscanf(file_id, '%8d%16f%16f%16f%8f%8f', [6, Inf]);
end
while the following code with fgetl needs 6.343209 seconds to complete, even though it does much less
function [data] = test_fscanf_nodes_only_02()
file_name = 'myfile.txt';
file_id = fopen (file_name, 'rt');
cleanup_obj = onCleanup(@() fclose(file_id));
lines_count = 0;
while ~feof(file_id)
current_line = fgetl(file_id);
lines_count = lines_count + 1;
end
data = 1;
fprintf('Lines count: %d', lines_count);
end
The main problem with the first snippet is that it returns wrong result (because for fscanf the width of the field counts from the first digit it finds and not from the current position of the file pointer (which means, that the leading whitespaces are not counted as field width).
EDIT: The dimension in fscanf is changed from [5, Inf] to [6, Inf] according to Jan's comment.Dmitrii Semikinhttps://ww2.mathworks.cn/matlabcentral/profile/authors/15367413-dmitrii-semikintag:ww2.mathworks.cn,2005:Question/1591512014-10-18T04:00:00Z2019-06-18T06:37:25ZWhy do I receive an error that states 'Invalid distance - too far back' when installing MATLAB?I am installing MATLAB, and during the installation I receive an error mentioning 'Invalid distance too far back' and a file name. What can I do to resolve this error?
MathWorks Support Teamhttps://ww2.mathworks.cn/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:ww2.mathworks.cn,2005:Question/4676102019-06-18T05:55:31Z2019-06-18T06:30:25ZWhat is the meaning of following code?Hi I would lioke to know the meaning of the following code
NewRes(:,:,Channel,:) = Residuals([1:2:size(Residuals,1)],[1:2:size(Residuals,1)],Channel,:);
what is the syntax here is suggesting. I would like to repesent this in Python.
ThanksPriyanka Bharadwajhttps://ww2.mathworks.cn/matlabcentral/profile/authors/15313945-priyanka-bharadwajtag:ww2.mathworks.cn,2005:Question/4674282019-06-17T09:44:45Z2019-06-18T06:26:13ZI have IgorTime data in which time:units = "seconds since 1904-01-01". I would like to convert this seconds to datevc.I have attached the file (IgorTime).
Thank youVishnu Dhakadhttps://ww2.mathworks.cn/matlabcentral/profile/authors/11106145-vishnu-dhakadtag:ww2.mathworks.cn,2005:Question/4676112019-06-18T06:17:14Z2019-06-18T06:17:14ZChange attributes of object handles from python in MatlabHello,
is there any possibility of updating/changing the attributes of a Matlab object handle from python without creating a set function?
I mean, to read the attributes it can be done using the wrokspace as follows:
eng.workspace['wx'] = x
height = eng.eval['wx.height']
This will return the height of the object x. Is there any other way of changing the height? I ask this because I should not change the script from which I am using the values and objects
Thanks!Eduardo Villaloboshttps://ww2.mathworks.cn/matlabcentral/profile/authors/6993010-eduardo-villalobostag:ww2.mathworks.cn,2005:Question/166882011-09-25T15:32:34Z2019-06-18T06:12:57Zhow to draw a hyperboloid?Hai,
I need to draw a hyperboloid in matlab. How is it I could do it?
BSDbsdhttps://ww2.mathworks.cn/matlabcentral/profile/authors/2934341-bsdtag:ww2.mathworks.cn,2005:Question/4675962019-06-18T04:34:13Z2019-06-18T06:11:46ZNeed source code of this paper " Particle Swarm Optimization for Object-Based Feature Selection of VHSR Satellite Images"Need source code of this paper " Particle Swarm Optimization for Object-Based Feature Selection of VHSR Satellite Images"
OR
This paper " A Novel Approach for Multispectral Satellite Image Classiﬁcation Based on the Bat Algorithm "Seema Hullattihttps://ww2.mathworks.cn/matlabcentral/profile/authors/15503435-seema-hullattitag:ww2.mathworks.cn,2005:Question/4648212019-05-30T17:56:16Z2019-06-18T06:11:32ZSurface Lighting in App Designer not Showing ProperlyI've recently begun to move a MATLAB GUI that I've been working on into App Designer. However, I have gotten to a point where a 3D surface plot (using trisurf) is not coming out as it did in my Guide GUI. I believe it has to do with the lighting property as the image comes up as a 2D blob rather than a 3D object with edges. Here is what it looks like:
This image is what it looks like in my old Guide GUI:
Here are the few lines of code that actually plot the image in App Designer:
trisurf(tri, outXYZ(:,1), outXYZ(:,2), outXYZ(:,3),'FaceColor','yellow','EdgeColor','none','FaceAlpha',1, 'FaceLighting', 'gouraud','Parent', app.KneeMask);
view(3)
axis tight;
camlight;
I used to specify the lighting outside of the trisurf call by putting
lighting gouraud
I tried moving it inside of the trisurf call in case it had anything to do with not specifying the axes (which wasn't an issue in Guide GUI), but this didn't help either. I also re-ran the code once and saved the trisurf as a variable in order to observe the lighting property and it was indeed gouraud, so I'm not sure why it's coming out as a blob. Any help with this would be much appreciated. Thank you!Nathan Knodelhttps://ww2.mathworks.cn/matlabcentral/profile/authors/10757839-nathan-knodeltag:ww2.mathworks.cn,2005:Question/4675742019-06-17T21:59:22Z2019-06-18T06:11:23Zhow to change the code to make work the solution for this integral
can you help me solve this integral with simpson ?Xhenis Bordullahttps://ww2.mathworks.cn/matlabcentral/profile/authors/15651792-xhenis-bordullatag:ww2.mathworks.cn,2005:Question/4676072019-06-18T05:51:42Z2019-06-18T06:07:34ZMaking loop calculate-ablen = 450*450;
for i = 0:1:n
for j = 0:1:n
i = mod (i+1,n+1);
j = mod (j + S(i+1), n+1);
S([i+1 j+1]) = S([j+1 i+1]);
end
end
I need to run this code for initial sequence S = {1,2,3,...,450*450}, but due to very high computation matlab is not able to do this. Is there any way to acheive this using less calculations?Zeeshan Abbashttps://ww2.mathworks.cn/matlabcentral/profile/authors/15085187-zeeshan-abbastag:ww2.mathworks.cn,2005:Question/4028582018-05-28T08:41:48Z2019-06-18T06:05:31Zhow to plot latitude and longitude data on map??Please find the attachment.
Vishnu Dhakadhttps://ww2.mathworks.cn/matlabcentral/profile/authors/11106145-vishnu-dhakadtag:ww2.mathworks.cn,2005:Question/4676022019-06-18T05:18:51Z2019-06-18T05:59:09ZCould anyone help me to display the non zero numbers with respect to each columncode:
C =[ 0 254.1128 0 ;
233.3050 0 0 ;
0 0 79.3894]
A=find(C~=0)
when i run the code it gives the following result
A = 2
4
9
It gives the place of the non zero numbers
Coud anyone help me how to get the place of non zero numbers with respect to each column in the following manner
A= 2 1 3
Could anyone please help me on thisjaah navihttps://ww2.mathworks.cn/matlabcentral/profile/authors/11695462-jaah-navitag:ww2.mathworks.cn,2005:Question/2640072016-01-16T16:59:53Z2019-06-18T05:51:27ZHow to receive rgb values for each frame of the video?Hello, everyone.
I am having trouble with getting RGB values for all frames of my video. What I need to do is to find what average value of red (of all pixels) each of my frames has. I've tried to use impixel, but it makes me specify the width&length, which have to be the same, but in my case, my video is 1040X1400 size..
I appreciate any advice! Thank you
My code is:
%Reading the video file
video=VideoReader('video.mov');
vidHeight=video.Height;
vidWidth=video.Width;
k=1;
while hasFrame(video)
allframes(k).cdata = readFrame(video);
k = k+1;
end
i=1;
while hasFrame(video)
frames(i,:)=impixel(allframes(i).cdata,1:vidHeight-1,1:vidHeight-1);
i=i+1;
end
Anar Alshanbayevahttps://ww2.mathworks.cn/matlabcentral/profile/authors/6960854-anar-alshanbayevatag:ww2.mathworks.cn,2005:Question/4674392019-06-17T10:45:41Z2019-06-18T05:48:45ZSampling of the received signal vectors in matlabThe transmitted signal is in LTE frequency range. I need to convert the received band pass signal to complex base band. The received signal has to be converted to digital form. So If I need to sample it, what should be the sampling frequency.? Moreover as In Matlab, I have received signal vectors how to calculate the sampling frequency ? If I use resample function in Matlab then how to use itRajanish Bhairannawarhttps://ww2.mathworks.cn/matlabcentral/profile/authors/3548985-rajanish-bhairannawartag:ww2.mathworks.cn,2005:Question/4675992019-06-18T05:06:28Z2019-06-18T05:48:15ZHaving an issue with enhancing colour images
I have been having an issue with the [X,map] code! I am not sure what I should put or do as I am new the MatLab community!
Please assist so that I can understand the process and what is required?
Thank you so much in advance for acknowledging my digital presenceMatthew Parrishttps://ww2.mathworks.cn/matlabcentral/profile/authors/15452778-matthew-parristag:ww2.mathworks.cn,2005:Question/4676062019-06-18T05:46:22Z2019-06-18T05:46:22ZWhy I can't tune/design PID for a vehicle modelled with simscape? Hi all,
the model is a conventional car with multi-speed transmissoin. It is build using simscape and the control objective is 'reference tracking' of input drive cycle.
For more than a year, I have been trying methods and solutions offered in MATLAB documentation. But It has been fruitless so far and I can't get a good result from simulatoin.
The model and a written report of my work is attached to this inquiry, Please have a look. Thank you, in advance.
Looking forward to hearing from you.
Regards,
Sajjad
Sajad A.Anbaranhttps://ww2.mathworks.cn/matlabcentral/profile/authors/6089565-sajad-a-anbarantag:ww2.mathworks.cn,2005:Question/4676042019-06-18T05:33:00Z2019-06-18T05:39:02Zangle detection in imageAs im working on image face detection. how to get a angle between straight face and slightly turned face with certain angle ?HARISH K GOWDAhttps://ww2.mathworks.cn/matlabcentral/profile/authors/9092406-harish-k-gowdatag:ww2.mathworks.cn,2005:Question/4676052019-06-18T05:36:47Z2019-06-18T05:36:47ZWhat extension do I use to save my MATLAB file on ATOMS script editor?I really like using Atoms. I attempted to save my script both in ".m" and ".mat" file extensions. However, it is not a one to one to that of MATLAB built in script editor. Is there a similar or popular script editor for MATLAB that one can suggest giving it a try?
Thanks,Suleman Jalalhttps://ww2.mathworks.cn/matlabcentral/profile/authors/9669272-suleman-jalaltag:ww2.mathworks.cn,2005:Question/4362582018-12-18T06:38:08Z2019-06-18T05:28:41ZHow to classify these images as straight, left oriented, right oriented. Which method i can apply.? Couldn't find any methods after a lot of searching. can you help me.karthikhttps://ww2.mathworks.cn/matlabcentral/profile/authors/11636146-karthiktag:ww2.mathworks.cn,2005:Question/4676032019-06-18T05:24:29Z2019-06-18T05:24:29ZWhy is GoogLeNet classifying all inputs to the same output class?Hi,
I seem to be having a problem classifying with GoogLeNet. I am using vibration data (420-by-10002 matrix) sampled at 10 KHz. CWT of the vibration data were taken and the scalograms were obtained.These scalograms were used to train the GoogLeNet to classify among the six output categories: 'TEN', 'TWENTY', 'THIRTY', ‘FORTY’, ‘FIFTY’ and 'SIXTY'. But I am getting the output ‘TWENTY’ irrespective of the inputs.
I am using cwtfilterbank to plot scalograms. For GoogLeNet, I have only used default conditions,
80% for validation and 20% for testing
MiniBatchSize = 15
MaxEpochs = 50 to 200
InitialLearnRate = 1e-4
ValidationFrequency = 10
I have found the optimal number of MaxEpochs as the one with the highest validation accuracy.
I am using the example code given in Mathworks website for ECG Classification problem (CWTGoogLeNet). I have also attached my network layer graph.
What am I doing wrong here? Any help would be great.
Thanks. vanrapahttps://ww2.mathworks.cn/matlabcentral/profile/authors/4095679-vanrapatag:ww2.mathworks.cn,2005:Question/4672912019-06-16T05:23:57Z2019-06-18T05:19:50ZInterpolation of a scatter plot Hello ;I would be most grateful if someone could give me a helping hand. i have a scatter plot where the the third variable is velocity color coded for each pair of (x,y)I woud like to interpolate this plot to have more points.below is a figure of what i have and my code as well . thanks in advance.
the interpolated points are the red piont of the second figure is having just 9 pionts. i would like to apply that to the first figure which is what i have .
plotTypes = {'mean_velocity','std_velocity','mean_pd', 'std_pd'};
for i = 1: length(plotTypes)
figure
plotType = plotTypes{i};
%subplot(1,length(plotTypes), i);
hold all ;
legendLabels = cell(1,length(plotData));
for j = 1:length(plotData)
xPlot= plotData{j}.data(:, idx.x);
yPlot= plotData{j}.data(:, idx.(plotTypes{i}));
plot(xPlot,yPlot, '-o','color',k(j,:));
legendLabels{j} = ['Y = ', num2str(plotData{j}.y)];
end
legend(legendLabels);
title(plotTypes{i}, 'Interpreter', 'none');
xlabel('x position')
ylabel(plotTypes{i}, 'Interpreter', 'none')
end
%% Generating the 3D color plot
% figure
for i = 1: length(plotTypes)
figure
legendLabels = cell(1,length(plotData));
% subplot(1,length(plotTypes), i);
hold all
for N=1:size(plotData,2)
pz =150;
plotData{1,N}.data();
x=plotData{1,N}.data(:,1);
y= plotData{1,N}.data(:,2);
%if i ==3
% z= plotData{1,N}.data(:,(i+2));
%end% Z(:,N) =plotData{1,N}.data(:,(i+2));
scatter(x,y,pz,plotData{1,N}.data(:,(i+2)),'filled')
legendLabels{N} = ['Y = ', num2str(plotData{N}.y)];
end
%%Interpolation into a gridded data
%F =scatteredInterpolant(x,y,Z);
%[xq,yq]=meshgrid(linspace(20,230,100));
%cq =F(xq,yq);
%h=pcolor(xq,yq,cq)
%legendLabels{N} = ['Y = ', num2str(plotData{N}.y)];
legend(legendLabels);
title(['3D plot of position against ',plotTypes{i}], 'Interpreter', 'none')
xlabel('X(mm)')
ylabel('Y(mm)')
H = colorbar;
ylabel(H, plotTypes{i});
end
Yannick Tabot Njamihttps://ww2.mathworks.cn/matlabcentral/profile/authors/9913485-yannick-tabot-njamitag:ww2.mathworks.cn,2005:Question/4673902019-06-17T05:31:29Z2019-06-18T05:19:11ZWhat exactly is method in "Receive data from a method in an Android app." ?Hello all !
I have been trying to understand how to let my android application made in Simulink communicate with a device connected to my android phone via an USB-OTG.
I notice there are two blocks called "FromAppMethod" and "ToAppMethod"
https://www.mathworks.com/help/supportpkg/android/ref/fromapp.html
https://www.mathworks.com/help/supportpkg/android/ref/toapp.html
These 2 links are the links describing their functions.
However, i am unable to understand what is meant by
a method in an android app?
the method must exist in the default activity ?
Does this mean that this is trying to read and send data to another application running at the same time ?
From what i understand is that, the applications created by Simulink cannot be run simultaeneously on an Android device. Simply minimising the application will require you to restart the application.
Best regards all.
Thank you !Kiat Nern Yeohttps://ww2.mathworks.cn/matlabcentral/profile/authors/15491826-kiat-nern-yeotag:ww2.mathworks.cn,2005:Question/4676012019-06-18T05:16:21Z2019-06-18T05:16:21ZGenerating two dimensional random variables and compute expectation of some two-dimensional function using it.I need to generate many two-dimensional random variables and then calculate the expectation of a two-dimensional functions with respect to those. How can I do that?Paramahamsa Kolaganihttps://ww2.mathworks.cn/matlabcentral/profile/authors/11017186-paramahamsa-kolaganitag:ww2.mathworks.cn,2005:Question/4676002019-06-18T05:13:12Z2019-06-18T05:13:12ZCreating 3D image and processing using sensori want to design Laparoscopic instrument( grasper scissors) and with sensor i want to open and close the graspers, please can any body help me to design 3D image in matlab ( matlab code)Chander Pawarhttps://ww2.mathworks.cn/matlabcentral/profile/authors/15251263-chander-pawartag:ww2.mathworks.cn,2005:Question/4663242019-06-10T14:20:46Z2019-06-18T05:05:52ZTuning a PID controller with real time sensor input ?Hi all
I understand that it is possible to tune a PID controller according to various inputs, such as a RNG source block, a sine wave block, CSV value files etc.
However, how does one tune a PID controller using real time sensor data, especially from an android phone's sensors ? For example an accelerometer.
Can a PID controller be tuned interactively with the user moving and rotating the phone around ?
Cheers !!Kiat Nern Yeohttps://ww2.mathworks.cn/matlabcentral/profile/authors/15491826-kiat-nern-yeotag:ww2.mathworks.cn,2005:Question/4675882019-06-18T02:33:10Z2019-06-18T04:46:36Zcould anyone help me to solve the issue with respect to the codecode:
A=1:7
B=length(A)
idx=randperm(B,1)
disp(idx)
the above code run one time and it displays idx value.
Could anyone help me to run the above code 5 times and for each time idx value should needs to be different.jaah navihttps://ww2.mathworks.cn/matlabcentral/profile/authors/11695462-jaah-navitag:ww2.mathworks.cn,2005:Question/4675292019-06-17T17:51:23Z2019-06-18T04:38:07ZHow do I explain the random functions to my professor?ok.. so the works I do usually do not require using Matlab, but in one case, I had to generate random values for several distributions such as normal, lognormal, weibull...
I am sure all the random value generating distribution function work the same way.
I am to generate 3 random arrays. For example:
A=normrnd(3,10,[1,5])
B=normrnd(30,100,[1,5])
C=normrnd(300,1000,[1,5])
So... i get 1x5 vector named A, B, and C.
Everything going well and then my professor, who does not know anything about Matlab or coding but clames himself as an expert, heard something from someone about the random function, and now is tackling me with stuff that he can't explain. The sad part is his words might have a point since he probabily did hear this from someone who knows Matlab.
He said he does not know how matlab generates random values from rand functions, but the random function picking all 5 values at once([1,5] for the above example) is different from picking 1 value each for 5 times.
Also, it will be different from picking one value each from A,B,C for 5 times compared to picking all 5 from A, then moving on to B, then C. Now this part does not make sense, since I know matlab finishes generating vector for A and goes to B and C.
For the first part, in other words, he is saying if the random function picks one value each for 5 times, the generation of random value is affected by the previously generated value. I asked him if he is talking about permutation/combination situation, but he said it's more complicated than that.
This professor... this is the guy who says Minitab generates random function in 'right way', not because he knows the generation algorithm and process, but because this program is strictly made for statistical analysis, unlike the Matlab. I told him I will generate the values from the Minitab as he likes then use the values in Matlab, but he said 'That is not the researcher's way of doing things'...
I tried to look at the documents related to rand functions, but honestly I cannot understand.
Can anyone help me convince this professor so I can just use these functions?Young Chan Junghttps://ww2.mathworks.cn/matlabcentral/profile/authors/13085094-young-chan-jungtag:ww2.mathworks.cn,2005:Question/4675972019-06-18T04:36:16Z2019-06-18T04:36:16ZSimulink communication with DJI Spark controller ?Hello all
I am trying to study how the DJI spark controller works and i understand that it is communicating via wifi.
Is it possible to use the TCP/IP , demux and data displays to see what numerical value is the controller sending when i shift any of the two controller sticks ?
Does anyone have any experience that they would like to share ?
Best regards all !
CheersKiat Nern Yeohttps://ww2.mathworks.cn/matlabcentral/profile/authors/15491826-kiat-nern-yeotag:ww2.mathworks.cn,2005:Question/4675012019-06-17T15:59:20Z2019-06-18T04:32:33Zcould anyone help me to solve the issue in the following codecode:
particles=10;
users=4;
dimensions=2;
for particle=1:particles
clusters= randi(users,1);
swarm_pos = rand(clusters,dimensions);
DDD=partitions(users,clusters);
total_number_of_partitions = length(DDD);
idx=randperm(total_number_of_partitions,1);
iwant= DDD(idx);
partdisp(iwant)%remains tha same for more than one particle in some cases.But it should be different.
end
When i run the code it executes.But partdisp remains the same for more than one particle in some cases.I actually need to have different partdisp for each and every particle.Could anyone please help me on this
jaah navihttps://ww2.mathworks.cn/matlabcentral/profile/authors/11695462-jaah-navitag:ww2.mathworks.cn,2005:Question/4672882019-06-16T03:23:25Z2019-06-18T04:27:47ZLog likelihood is initially high in FOCE but as the iteration proceeds to greater than 3500 the log likelihood reduces and finally ends with error that maximum iteration has been achieved.I am trying to develop a population pharmacokinetic model using Simbiology,
My settings are
Estimation method: Estimating mixed effects model with nlmefit
Error model is proportional
Method to approximate non-linear mixed effect model likelihood is FOCE.
The FOCE model fitting progress shows a loglikelihood of around -200 (that is good) till iteration of 3500 but after that suddenly the loglikelihood goes to around -900.
Then it keeps on proceeding, untill finally a error comes that the maximum iteration has been obtained. Now the final model has loglikelihood of around -900.
But initially till 3500 iteration, it had a loglikelihood of -200. So finally should i take loglikelihood as -200 or -900?
Praveen Kumar Mhttps://ww2.mathworks.cn/matlabcentral/profile/authors/8711788-praveen-kumar-mtag:ww2.mathworks.cn,2005:Question/4675902019-06-18T02:59:54Z2019-06-18T04:21:34Zcreating a cell with serial namesHello,
I want to create a list (1x15 cell) of 15 names (sometimes more than that) with names of following pattern;
AB_01, AB_02, AB_03,....AB_15.
Is there an easy way to do this , in a loop like, rather than type it each.
Thanksdarshani Thotagamuwagehttps://ww2.mathworks.cn/matlabcentral/profile/authors/3726595-darshani-thotagamuwagetag:ww2.mathworks.cn,2005:Question/3056972016-10-04T13:56:18Z2019-06-18T04:18:57ZProblem with solving equation with 'FSOLVE'Hello,
I am solving a system of equations with FSOLVE.
I generated starting points with
x0 = rand(2,1);
However, for some x0s, there's an error message saying
Error using trustnleqn (line 28)
Objective function is returning undefined values at initial point. FSOLVE cannot continue.
It seems that for some starting points, the fsolve cannot find solutions.
However, I want FSOLVE to immediately retry with a new random starting point rather than stopping and showing an error message. How can I do that?ByungChul Minhttps://ww2.mathworks.cn/matlabcentral/profile/authors/3417294-byungchul-mintag:ww2.mathworks.cn,2005:Question/4675922019-06-18T03:33:05Z2019-06-18T04:18:48ZHow to manipulate the spaces of the x and y axes in the HIST function in MATLAB?In this examble, the spaces is 500 in 500, how to modify this?
I want, for example, 100 in 100!
I use: hist(image, 0:250) for X axes, but don't work hist(image, 0:250, 0:250) for x and y.
Weslley Eduardohttps://ww2.mathworks.cn/matlabcentral/profile/authors/15675005-weslley-eduardotag:ww2.mathworks.cn,2005:Question/4675852019-06-18T01:20:15Z2019-06-18T04:17:48ZHow could I find the heading angle here please?HAITHAM AL SATAIhttps://ww2.mathworks.cn/matlabcentral/profile/authors/14143346-haitham-al-sataitag:ww2.mathworks.cn,2005:Question/4675952019-06-18T04:09:34Z2019-06-18T04:09:34ZI am acquiring the EEG data online by using Lab Streaming Layer (Python to Matlab). The values are displaying in Matlab Command Window but not reflecting in Workspace. How to get it in Workspace of MATLAB?Openbci_MatlabSridhar Sutravehttps://ww2.mathworks.cn/matlabcentral/profile/authors/12214286-sridhar-sutravetag:ww2.mathworks.cn,2005:Question/4675862019-06-18T01:20:43Z2019-06-18T03:58:57ZMatlab 2018a Editor no longer showing code sectionsWith no apparent cause, my Matlab editor stopped showing section breaks and cannot "Run Section" anymore as a result. This is only happens for one script (and the most recent versions of it). I have older versions of it with minor changes which do not have this section issue. Using the Compare tool with the "working-section" scripts to the latest versions where sections don't appear shows no obvious cause. This happens for the same scripts on multiple computers (Windows 10 machines). It is a relatively large script (4,000 lines). I've tried restarting Matlab and my computers. I've tried re-saving the Script. Autoformatting has section breaks ticked.
Other Matlab users report this can be due to an error in the code but there is no error in the code and the script runs just fine.
Edit: Since other scripts work fine I opened a new script, select all non working code and pasted. Did not work. Then I took the first half of my code, pasted it into a new script. Sections work. Added second half, stop working. New Script. Second half, works. New Script, first half, works. Start adding second half section by section. Work up until I get to this bit of code:
%% Plot each subjects's break attempts for each session
[breakSortAtt, breakSortAttIdx] = sort(out.(groups{currG}).breakAttempts);
allRatNames_breakSortAtt = out.(groups{currG}).ratID(breakSortAttIdx);
figure;
hold on
for i = 1:length(allRatNames)
plot(-1:0,'color',cmap(i,:),'linewidth',7);
end
legNames = [allRatNames; {'avg'}];
line([0 length(out.(groups{currG}).breakAttempts)]+1, [avgBreakAtt_all avgBreakAtt_all],'LineStyle','--','color',[0.5 0.5 0.5])
legend(legNames,'Location','northwest');
b = bar(breakSortAtt,1,'FaceColor','flat');
legend(legNames);
for i = 1:length(allRatNames)
currRat = allRatNames{i};
indexRats = strfind(allRatNames_breakSortAtt,currRat);
index = find(not(cellfun('isempty',indexRats)));
for j = 1:length(index)
b.CData(index(j),:) = cmap(i,:);
end
end
hold off
ylim([0 max(breakSortAtt)+5]);
ylabel('Quit attempts #');
title(groups{currG});
xticklabels([]);
up until and with this section of code I can paste in new sections of code and sections work. After this bit of code I can still create new sections. However, if I paste in some sections of code from the non-working script, Sections seems to stil work fine. However, if I paste multiple other sections of code, Sections will stop working. New pasted in sections are not recgonzied and I can't manually add in new sections. However! If I delete some white space/empty lines, Sections will come back, sort of, but then adding further code will break it again.
Blake Porterhttps://ww2.mathworks.cn/matlabcentral/profile/authors/8208253-blake-portertag:ww2.mathworks.cn,2005:Question/4675942019-06-18T03:58:41Z2019-06-18T03:58:41ZTrouble opening an app created in app designer 2018 with Matlab version 2019aHello community,
I made a GUI in app designer 2018. Now, after updating to 2019a and trying to open my app, I received the message "undefined function 'appdesigner.internal.componentcontroller.DesignTimeController' for input argument of type 'matlab.ui.control.Label'.
I received a similar message trying to open another app created with 2018 Matlab version.
The great problem is that I cannot edit the code to try to solve the problem, because it doesn't open.
Any suggestion?
Thank you in advance,
EnzoEnzo Brunettihttps://ww2.mathworks.cn/matlabcentral/profile/authors/1849274-enzo-brunettitag:ww2.mathworks.cn,2005:Question/4658722019-06-06T15:27:51Z2019-06-18T03:58:19ZConvert distance matrix to a tableHow can I convert the output matrix Z to a table with the following structure?
Object1 Object2 Distance
1 2 0.2954
1 3 1.0670
2 1 0.2954
2 3 0.9448
3 1 1.0670
3 2 0.9448
Code:
rng('default') % For reproducibility
X = rand(3,2);
D = pdist(X)
Z = squareform(D)
dan kinhttps://ww2.mathworks.cn/matlabcentral/profile/authors/3735616-dan-kintag:ww2.mathworks.cn,2005:Question/4662922019-06-10T09:36:32Z2019-06-18T03:51:33ZHow to get the positions and put a marker (rectangle or oval) on the image?How to get the positions of only white pixel values and put a marker (rectangle or oval) in the images attached. When searched I found this link https://in.mathworks.com/matlabcentral/answers/110230-drawing-a-rectangle-on-top-of-an-image. But the position I have to get automatically. Can you help me.?
Reference images have attached. The seconf image I got using edge operator.
I = imread('im.jpg');
E1 = edge(I,'Sobel');
imshowpair(I,E1,'montage')karthikhttps://ww2.mathworks.cn/matlabcentral/profile/authors/11636146-karthiktag:ww2.mathworks.cn,2005:Question/3529452017-08-16T13:09:51Z2019-06-18T03:46:12ZUsing DropoutLayer in neural network (not only in CNN)hey guys,
i am using matlab to create a Neural Network for a Regression Problem.
to avoid overfitting i want to add a dropoutLayer after the Input layer, but i see only examples for CNN.
did someone knows, how to add a dropoutLayer in noraml neural Network or Setting the Options of neural Network(not CNN)
thanksAndy_daodaohttps://ww2.mathworks.cn/matlabcentral/profile/authors/5864010-andy_daodaotag:ww2.mathworks.cn,2005:Question/4675892019-06-18T02:37:56Z2019-06-18T03:27:43Zreadtable requires column formats?I cannot seem to use readtable('filename.csv') without having to specify column formats. Others using the exact same code don't seem to have this problem. Is there someplace where I have explicitly set some option that requires formats? Any ideas?
I have this problem anytime I use readtable (and on multiple machines I control). We've tested the same scripts/functions on other machines and they don't need the explicit formats specified.
Thanks.Derrick Hasterokhttps://ww2.mathworks.cn/matlabcentral/profile/authors/4387130-derrick-hasteroktag:ww2.mathworks.cn,2005:Question/4675912019-06-18T03:10:24Z2019-06-18T03:10:24ZHow to create html report after using detect design error??Hi bros,
I used simulink design verifier for check my model.
It seem OK when I use Analysis > Design Verifier > Detect Design Error > Model.
But whenI use Analysis > Design Verifier > Detect Design Error > Selected Subsystem, report output is xml file only.
Do any one know that it can generate html report ?galaxyhttps://ww2.mathworks.cn/matlabcentral/profile/authors/15063927-galaxytag:ww2.mathworks.cn,2005:Question/4670072019-06-14T00:40:40Z2019-06-18T02:57:46ZBackslash error ''Warning: Matrix is singular to working precision." I have a very large sparse matrix, Amat (192611x192611), that has a density of 6.7190e-05 . When I am trying to use the backslash command with this matrix (cnew =Amat/rhs, where rhs is a column vector (192611 x 1) with small values, around 1e-13) on matlab 2019a, I get an error that says ''Warning: Matrix is singular to working precision." and the output array is full of NaN. However, when I run the same command on matlab 2011b (the code was made in 2011) or matlab 2014a, I get the same error, but I don't get these Nan values. Instead, I get small values, around 1e-14. My questions are the following :
1) Has the backslash command changed between these versions?
2) Are the values that I'm getting with the other versions reliable?
Mathieu Walshhttps://ww2.mathworks.cn/matlabcentral/profile/authors/15419869-mathieu-walshtag:ww2.mathworks.cn,2005:Question/4675802019-06-18T00:05:37Z2019-06-18T02:54:43ZError only in 2012 versionI'm trying to use some code to play a video but I keep hitting an error. The error says "Attempt to reference field of non-structure array"
while ishandle(hFig) && ~bKillAll
set(hText,'String',['frame ' num2str(fr) '/' num2str(macroDat.nofFrames) ' target FPS: ' num2str(curTargetFrameRate)]);
switch behavior(startFr)
case 0, hText.String = [hText.String ' SLEEPING'];
case 5, hText.String = [hText.String ' EXPLORATION'];
end
and the other place in the code where hText shows up at all is here:
hText = title(axHandle,['frame ' num2str(macroDat.fileReadPointer-1) '/' num2str(macroDat.nofFrames) ' target FPS: ' num2str(macroDat.targetFramerate)]);
However this error does not exist in the 2019 version of Matlab, but we need it to run on our 2012 version. I was told it might have something to do with handles, but I'm not sure about that. Any advice?Rebecca Somachhttps://ww2.mathworks.cn/matlabcentral/profile/authors/15468994-rebecca-somachtag:ww2.mathworks.cn,2005:Question/777932013-06-03T05:50:56Z2019-06-18T02:52:55Zis wavelet transform is done before or after fft?i am processing a human vital sign data obtained from doppler radar at 1 Ghz. i want to use wavelet transform for the detection of heartbeat and respiration rate. the same can be done by fft also.
can we use both fft and wavelet transform together to find out the heartbeat and respiration rate?
if yes, then which transform is done first?
and how do we interpret the wavelet transformed signal?lynette t.https://ww2.mathworks.cn/matlabcentral/profile/authors/2177861-lynette-ttag:ww2.mathworks.cn,2005:Question/4413202019-01-24T16:43:33Z2019-06-18T02:52:38ZMatlab is not recognizing sections %%I am working with Matlab 2018a and for some reason Matlab stop recognizing my sections (%%). Maybe I did something after messing in Home>Preferences, but I'm not really sure. Has anyone had this problem before? I've look online and people say "Enable Cell Mode", but I have no idea how to do this in 2018a.
thanks in advance. Taylor Nicholshttps://ww2.mathworks.cn/matlabcentral/profile/authors/6036280-taylor-nichols