https://in.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2019-02-21T10:54:46Ztag:in.mathworks.com,2005:Question/4462102019-02-21T10:54:46Z2019-02-21T10:54:46ZHow do I index into a timeseries using relative datetime valuesHi,
I have a bunch of timeseries of data from an experiment. I want to split each time series (participant data) into sections that reflect experiment intervals. I have a series of time values that represent the start of each interval, and they are imported into matlab as datetime objects which are only time values and the time values are relative to the start of the experiment i.e. 2 mins 4 seconds after the start, 4 mins 8 seconds after the start.
Conventiantly, you cannot index into a timeseries and get an interval of data using a datetime object with the 'getdatabytime' method of the timeseries. More conveniently, unlike datenum, there is no timenum method to get just the absolute number of seconds that have passed since the start of the experiment. This function would ofcourse be a nonsense without a reference datetime from which to draw the duration.
Is there a tidy and convenient way to get the necesary indexing values to get sections of time series data?
Simon Durbridgehttps://in.mathworks.com/matlabcentral/profile/authors/14406937-simon-durbridgetag:in.mathworks.com,2005:Question/4440832019-02-09T17:07:05Z2019-02-21T10:52:55Zismethod(string('test'), 'endsWith') under R2016b and 2018bR2016b:
ismethod(string('asd'), 'endsWith')
ans = logical(1)
R2018b:
ismethod(string('asd'), 'endsWith')
ans = logical(0)
Is this documented? I did not finf in in the release notes.
Actually ismethod uses the class of the first input. But for string there seems to be an exception. Is this the correct usage:
data = string('asd')
ismethod(class(data), 'endsWith')
?Janhttps://in.mathworks.com/matlabcentral/profile/authors/869888-jantag:in.mathworks.com,2005:Question/4462082019-02-21T10:49:23Z2019-02-21T10:52:47ZCustomize the Matlab figure appearance in Release 2018b - How to bring back plot browser icon, zoom icon etc.? Hi,
in my workflow, I need the plot browser very often. Mainly, to easily enable und disable visibility of single/multiple plots while exploring my data. Having to go first to the 'view' menu and then to look for the 'plot browser' needs more clicks and considerably more time than it was with the plot browser icon in the preveaous releases of Matlab. That is very annoying.
The same applies to the toolbar for the zoom icon, datapoints icon etc. Since Release 2018b I have to wait for the fading in animation of the toolbar icons. This is very annoying and slows me down (e.g. when I just need the zoom-tool to enable the zoomfunction that is restricted only to x- or y- axes).
I know, there are some tricky hacks using the 'startup.m' file to customize some appearances of the matlab figure toolbar. This workaround does not always work and maybe needs the knowledge of a mathworks developer. I don't have that knowledge. I would be thankful, if mathworks would provide a patch/update that allows users to easily customize the matlab figure toolbars, icons, etc. like it is in other programms, for example in 'MS Visual Studio'.
Customziablitity would be great, but for now, does anybody knows how to bring back the plot browser icon?
Johannhttps://in.mathworks.com/matlabcentral/profile/authors/5185791-johanntag:in.mathworks.com,2005:Question/4462092019-02-21T10:52:16Z2019-02-21T10:52:16ZSimulink Nonlinear compile time Hello,
I have a simulink model in which i want to simulate multiple objects of a custom subsystem.
The simulation is supposed to run in Accelerator mode, but when I increase the size of subsystem the compile time starts to grow beyond linearly.
The sldiagnostics function shows that this behaviour is caused by the Pre-compile post-eval notifies process.
Is there a reference to what it refers and how to improve this performance?Fabian Pagelhttps://in.mathworks.com/matlabcentral/profile/authors/10615883-fabian-pageltag:in.mathworks.com,2005:Question/4462072019-02-21T10:48:08Z2019-02-21T10:50:37Zhow to give ANN model as a fitness function to GA?Hi all, can any body help me with the code , how to write a fitness function for GA optimisation if I have ANN model.my X data has 5 variables and Y data has 3 variables. i have trained ANN mdel for X data, My objective is to find out optimum values of variables in X data by GA.
can any one help me in this regard?
Thanks in advance.
nelapati dhanahttps://in.mathworks.com/matlabcentral/profile/authors/13618530-nelapati-dhanatag:in.mathworks.com,2005:Question/4462042019-02-21T10:17:08Z2019-02-21T10:48:50ZReading of Slider into text box GUII'm displayin a signal
i have two push buttons next and back
i'm diving the signal into 3 blocks on x-axis
from 0 to 4 and from 4 to and from 8 to 12
i want to print 1 in a textbox when x-axis is from 0 to and 2 when it's 4 to 8
This code doesn't show any thing in the textbox
function Btn_Next_Callback(hObject, eventdata, handles)
% hObject handle to Btn_Next (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%handles.counter=handles.counter+4;
%set(handles.axes1,'XLim',[handles.counter handles.counter+4]);
% save the updated handles structure
%guidata(hObject, handles);
ax = axis;
x1 = ax(1)+ 4;
x2 = ax(2) + 4;
axis ([x1 x2 ax(3) ax(4)]);
if (x1==0) && (x2==4)
set(handles.edit5,'String' ,'1' );
end
Hassan Boshahttps://in.mathworks.com/matlabcentral/profile/authors/14798685-hassan-boshatag:in.mathworks.com,2005:Question/2879012016-06-06T05:34:02Z2019-02-21T10:46:04ZHas anyone connected Matlab to a MS Azure SQL database?Has anyone connected Matlab to a MS Azure SQL database? I normally connect to a local DB via ODBC connection; how would you do this for Azure SQL?Andrehttps://in.mathworks.com/matlabcentral/profile/authors/5500732-andretag:in.mathworks.com,2005:Question/4461902019-02-21T09:13:54Z2019-02-21T10:43:42ZWhy function displays one result, and how to stop it?Hello. I have made function that calculate roots of quadratic function ax^2 + bx +c, and then create graph for this function.
Also I have some text in function that will be printed to the screen. But also, except this text, function displays ans=(some number - first root).
I want just my text to be displayed. Here is the code:
function [x1, x2] = kvadratna(a, b, c)
D = b^2 - 4*a*c;
x = -10:0.2:10; %x osa za grafik
y = a.*x.^2 + b.*x + c; %funkcija
if(D<0)
fprintf('Funkcija nema realne nule');
elseif(D==0)
x1 = -b/(2*a);
x2=x1;
fprintf('Funkcija ima dvije iste realne nule\n');
fprintf('Te realne nule su: %.2f i %.2f\n',x1,x2);
elseif(D>0)
x1 = ((-b+sqrt(D)) / (2*a));
x2 = ((-b-sqrt(D)) / (2*a));
fprintf('Funkcija ima dvije razlicite realne nule\n');
fprintf('Te realne nule su: %.2f i %.2f\n',x1,x2);
end
plot(x,y,'g')
grid on
xlabel('x')
ylabel('f(x)')
title('CRTANJE FUNKCIJE')
end
and here is what it displays:
I dont want this ans=-1 to be displayed. How can I fix this?Faris Hajdarpasichttps://in.mathworks.com/matlabcentral/profile/authors/14824638-faris-hajdarpasictag:in.mathworks.com,2005:Question/4460782019-02-20T17:00:41Z2019-02-21T10:43:27ZMatlab for research purposeCan we use published matlab models, found on file exchange, for our own research? If not, how do we use published models for research purpose?Rudraksh Haranhttps://in.mathworks.com/matlabcentral/profile/authors/9614449-rudraksh-harantag:in.mathworks.com,2005:Question/4462052019-02-21T10:29:09Z2019-02-21T10:43:23ZMatlab Compiler too many input arguments error after compilingHi all,
I am trying to evaluate a Matlab Compiler license.
I have a collection of Matlab scripts that are all compiling and working fine when conventially run with Matlab.
When I use the Matlab Compiler to export a standalone application and then try to open the exported application I receive an error saying
"Too many input arguments" at a specific line. This line indeed holds a function with a big amount of arguments but I have checked again and again and the argument number in the implementation of the function matches the call of the function at that line where the function is called. There is no mismatch in number of arguments.
Furthermore my code scripts run fine when using Matlab to run them, so I do not know what can be going wrong or how to fix the issue.
Is there a different way that the Matlab Compiler interprets input arguments? Are there limitations to the number of arguments or how those are inserted in a function?
Any thoughts or help that can put me to the right direction would be appreciated!Dimitrishttps://in.mathworks.com/matlabcentral/profile/authors/5235921-dimitristag:in.mathworks.com,2005:Question/4459732019-02-20T08:40:31Z2019-02-21T10:42:33Zsort element in cellA={[1,2,3,4,5,8,9,39],[2,3,17,18,25,26,27],[3,4,14,15,16,17,18],[4,5,6,11,12,13,14],[5,6,7,8],...
[10,11,12,13],[16,21,22,23,24],[26,28,29],[2,30],[6,31],[10,32],[19,33],[20,34],[22,35],[23,36],[25,37],[29,38]};
ref=31;
base = cellfun(@(m)any(ismember(m,ref)),A,'uni',0);
base_mes=A{find([base{:}]==1)};
include_base = cellfun(@(m)any(ismember(m,base_mes)),A,'uni',0);
result=cell(1,numel(include_base));
index_other=find([include_base{:}]==1);
for i=1:size(index_other,2)
result{i}=A{index_other(i)};
end
base_mes=[6,31], I want to find 6 and 31 in A, after this sort A according to 31 and 6.
result={[6,31],[4,5,6,11,12,13,14],[5,6,7,8],[1,2,3,4,5,8,9,39],[2,3,17,18,25,26,27],[3,4,14,15,16,17,18],[10,11,12,13],[16,21,22,23,24],[26,28,29],[2,30],[10,32],[19,33],[20,34],[22,35],[23,36],[25,37],[29,38]} Naime Ahmadihttps://in.mathworks.com/matlabcentral/profile/authors/13711668-naime-ahmaditag:in.mathworks.com,2005:Question/4462062019-02-21T10:42:10Z2019-02-21T10:42:10ZGoodness-of-fit for a planeI have a set of (approximately planar) 3D data points, for which I have calculated a best-fit plane using the plane fit function here: https://uk.mathworks.com/matlabcentral/fileexchange/43305-plane-fit
I would like to find the goodness-of-fit, or a measure of how 'planar' the original points actually are. I am unsure how to do this. I can install any toolboxes I need.
I have looked at fitobject (https://uk.mathworks.com/help/curvefit/fit.html) as it has a gof option, but I am not sure you can apply this to fit a plane to my data points.Lucy Collinshttps://in.mathworks.com/matlabcentral/profile/authors/8905228-lucy-collinstag:in.mathworks.com,2005:Question/4456682019-02-18T21:15:25Z2019-02-21T10:40:41ZQuestion on Simulink Stand Alone executable with grt target fileHi , I was trying to generate a windows executable file from a simulink model using the grt system target file. It generated the exe file. This is a simple model I have two inputs and an output. I was wondering how can I call this model executable from Windows command line or say other languages like Python using os.system, and pass in the input arguments and get the corresponding outut. Any help on this will be much appreciated. Please let me know if you need more information.
I am able to run this in command line, but I am not sure how to pass in the arguments and get back the result.
Bibinhttps://in.mathworks.com/matlabcentral/profile/authors/1395499-bibintag:in.mathworks.com,2005:Question/4461992019-02-21T09:50:16Z2019-02-21T10:36:07ZPARROT Mambo Hardware Setup - Can't find Joystick IconHi everyone,
I'm struggeling for I while now to connect my PARROT Mambo to MATLAB.
Due to the instructions of the Hardware Setup the minidrone should appear as twice in the list of Bluetooth Device as you can see in the picture. Then you are supposed to connect to the one labeled as a Joystick. If the Joystick icon does not appear you should search again. But in my case it never found the mabo with the Joystick icon. Only the "wrong" icon always appeared.
I'm using:
MATLAB: R2017b
SUpport package ver: 17.2.4
Platform: Win7
Drone: PARROT Mambo
Bluetooth adapter: Intel ® DUAL Band Wireles-AC 8265
Bluetooth driver ver: 19.30.1649.933
Maybe someone had the same problem or has any idea how to solve this problem.Jonas Franzhttps://in.mathworks.com/matlabcentral/profile/authors/14597257-jonas-franztag:in.mathworks.com,2005:Question/4461972019-02-21T09:49:21Z2019-02-21T10:31:50ZElement wise multiplication .* rounding problemHello,
My name is Robin and I am currently using Matlab to compute some calculations.
But I have an issue. Let's take :
M = 564;
P = sin(5);
disp((M.*10.*P) - (M.*(10.*P)));
The result should be 0. Instead I get :
ans = 9.0949e-13
I understand the gap is very small, but I think Matlab rounding algorithm should finally provide 0.
Can you help me ?Robin L.https://in.mathworks.com/matlabcentral/profile/authors/14841739-robin-ltag:in.mathworks.com,2005:Question/4451312019-02-15T10:33:24Z2019-02-21T10:29:51ZHow can I modify the "Detect and Track face" example in Simulink for acquiring video from an Android device, obtaining the apk file?I've tried in this way ( attached file), but it doesn't work.Elisa Mangiamelihttps://in.mathworks.com/matlabcentral/profile/authors/13456410-elisa-mangiamelitag:in.mathworks.com,2005:Question/648782013-02-25T16:31:39Z2019-02-21T10:28:57ZHow do I close a specific figureI have a GUI. This GUI runs a simulation the at the end of it I open a figure to display results.
When I re-run the simulation - the old figure is kept open.
How do I close the old figure without closing the GUI?
('close all' close all the windows including the GUI).Nimrodbhttps://in.mathworks.com/matlabcentral/profile/authors/4060180-nimrodbtag:in.mathworks.com,2005:Question/2756072016-03-27T00:11:04Z2019-02-21T10:21:39ZHow do I get the workspace window back?Suddenly my workspace window has disappeared. How do I get it back? It is usually in the top right of the screen. My programming/editing, command and "files" windows are still fine, but I need to see my workspace, anybody know how to do this? Helen Kirbyhttps://in.mathworks.com/matlabcentral/profile/authors/5494713-helen-kirbytag:in.mathworks.com,2005:Question/4461822019-02-21T08:27:12Z2019-02-21T10:20:11Zlink this set of equations to a single unknown
A=[a1 a2 a3 a4 0 0 0 0;a5 a6 a7 a8 0 0 0 0;0 0 0 0 a9 a10 a11 a12;0 0 0 0 a13 a14 a15 a16;a17 a18 a19 a20 a21 a22 a23 a24;a25 a26 a27 a28 a29 a30 a31 a32;a33 a34 a35 a36 a37 a38 a39 a40;a41 a42 a43 a44 a45 a46 a47 a48]
B=[C1;C2;C3;C4;C5;C6;C7;C8]
C=[0;0;0;0;0;0;0;0]
A*B=C
1- I want to take this determinant of A matrix and find its roots.
2- I wan to link this set of equations to a single unknown. ( like C1)
I'd be happy if you could help.semih beyçimenhttps://in.mathworks.com/matlabcentral/profile/authors/14519368-semih-beycimentag:in.mathworks.com,2005:Question/4462032019-02-21T10:15:27Z2019-02-21T10:17:11Zmatlab 2015b does not go beyond activation module for 32 bit?MATLAB R2015B DOES NOT GO BEYOND ACTIVATION MODULE EVEN AFER SUCCESSFUL INSTALLATION AND ACTIVATION
senthilkumar uhttps://in.mathworks.com/matlabcentral/profile/authors/14783048-senthilkumar-utag:in.mathworks.com,2005:Question/3335052017-04-04T07:19:43Z2019-02-21T10:15:59Zhow to make classification for video I have a scenario and I need to classify it how can I do that?DSBhttps://in.mathworks.com/matlabcentral/profile/authors/8833451-dsbtag:in.mathworks.com,2005:Question/4462022019-02-21T10:14:48Z2019-02-21T10:14:48ZHow to write an array as an image that uses the full range of colors in the colormap in matlab as a .tif file of 256x256 size????I writing a program for forward scattering in image reconstruction .Can any one help me in finding How to write an array as an image that uses the full range of colors in the colormap in matlab as a .tif file of 256x256 size????
The output images are displayed as follows. i want to use these images for another part of my program which is written as a new script.
figure(2);
imagesc(param.x(1,:),param.y(:,1),real(E_matrix));title('Real Part')
colormap(jet);colorbar;grid on;
%% Plotting Imag Part
figure(3)
imagesc(param.x(1,:),param.y(:,1),imag(E_matrix));title('Imag Part')
colormap(jet);colorbar;grid on;Remya Das P Shttps://in.mathworks.com/matlabcentral/profile/authors/13529455-remya-das-p-stag:in.mathworks.com,2005:Question/4457792019-02-19T10:17:10Z2019-02-21T10:11:08ZRetrieve strings into a structure wihin a loopHi,
I have a series of folders called "storm_1", "storm_2", etc.
Each folder contains a number of *.dat files named as "NUM_SPEC_1978_6_5_0_0.dat_simo.dat", where the numbers are showing a date that I need to retrieve.
I would like to read through the folders and files and get a structure where I can see the dates of all files contained in each folder. For instance storm_1 folder has 13 files, so I would have 13 dates inside. Something like Structure.storm_1()
I attach a couple of folders as an example.
Can I get some help to retrieve the dates as efficiently as possible?
ThanksIsma_gphttps://in.mathworks.com/matlabcentral/profile/authors/8206515-isma_gptag:in.mathworks.com,2005:Question/4318532018-11-25T17:49:54Z2019-02-21T10:08:55ZeCAN loading problems to TI C2000 C28x3x card; are example only for Vector hardwareHi,
I am trying to use CAN communication for loading application to Control Card F28335. I am using CAN Calibration Protocol and External Mode example and Set Up CAN Communication with Target Hardware page as a reference. But this this example requires Vector-Informatik CAN hardware and software. I do not have Vector-Informatik CAN but some other CAN to USB converters. Actually I have two different ones (Lawicel AB's CANUSB and PEAK System's PCAN-USB FD) and both cannot connect to the Control Card and load application. When I Run in External mode I get the folowing message:
Build process completed successfully Searching ASAP2 file for signal information. Searching ASAP2 file for parameter information. Searching DAQ mapping file for DAQ event channel mappings. [�Warning: A Java exception occurred trying to load the com/mathworks/toolbox/ecoder/canlib/vector/VectorCAN class: Java exception occurred: java.lang.UnsatisfiedLinkError: com.mathworks.toolbox.ecoder.canlib.vector.VectorCANJNI.get_CAN_MESSAGE_STANDARD()I at com.mathworks.toolbox.ecoder.canlib.vector.VectorCANJNI.get_CAN_MESSAGE_STANDARD(Native Method) at com.mathworks.toolbox.ecoder.canlib.vector.VectorCAN.<clinit>(VectorCAN.java:16) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at com.mathworks.jmi.OpaqueJavaInterface.findClass(OpaqueJavaInterface.java:181) ]�
In order for CAN comincatin to work are Vector tools required or can I use any other manufacture ant their CAN to USB converters? Automated SImulink process is loading VectorCAN. What if I have different CAN device?
Regards.Mike Bubahttps://in.mathworks.com/matlabcentral/profile/authors/6740797-mike-bubatag:in.mathworks.com,2005:Question/4462012019-02-21T10:08:03Z2019-02-21T10:08:03Zhow to calculate psnr value of rgb imagei want one psnr value of my reconstructed imageaaru srihttps://in.mathworks.com/matlabcentral/profile/authors/13164674-aaru-sritag:in.mathworks.com,2005:Question/4455992019-02-18T15:48:43Z2019-02-21T10:04:27ZValidation Accuracy on Neural networkHello..I wonder if any of you who have used deep learning on matlab can help me to troubleshoot my problem. I don't understand why I got a sudden drop of my validation accuracy at the end of the graph? It's a simple network with one convolution layer to classify cases with low or high risk of having breast cancer. After the final iteration it displays a validation accuracy of above 80% but then suddenly it dropped to 73% without an iteration. I don't understand that.
Here's my code
%set training dataset folder
digitDatasetPath = fullfile('C:\Users\UOS\Documents\Desiree Data\Run
2\dataBreast\training2');
%training set
imdsTrain = imageDatastore(digitDatasetPath, ...
'IncludeSubfolders',true,'LabelSource','foldernames');
%set validation dataset folder
validationPath = fullfile('C:\Users\UOS\Documents\Desiree Data\Run
2\dataBreast\validation2');
%testing set
imdsValidation = imageDatastore(validationPath, ...
'IncludeSubfolders',true,'LabelSource','foldernames');
%create a clipped ReLu layer
layer = clippedReluLayer(10,'Name','clip1');
% define network architecture
layers = [
imageInputLayer([256 256 1]);
% conv_1
convolution2dLayer(3,32,'Stride',1)
batchNormalizationLayer
clippedReluLayer(10);
maxPooling2dLayer(2,'Stride',2)
%fc
fullyConnectedLayer(100)
dropoutLayer(0.7,'Name','drop1');
%fc
fullyConnectedLayer(25)
dropoutLayer(0.8,'Name','drop2');
% fc layer
fullyConnectedLayer(2)
softmaxLayer
classificationLayer];
% specify training option
options = trainingOptions('adam', ...
'InitialLearnRate',0.001, ...
'MaxEpochs',15, ...
'Shuffle','every-epoch', ...
'ValidationData',imdsValidation, ...
'ValidationFrequency',30, ...
'Verbose',false, ...
'Plots','training-progress');
% train network using training data
net = trainNetwork(imdsTrain,layers,options);
% classify validation images and compute accuracy
YPred = classify(net,imdsValidation);
YValidation = imdsValidation.Labels;
%calculate accuracy
accuracy = sum(YPred == YValidation)/numel(YValidation);
Andrik Rampunhttps://in.mathworks.com/matlabcentral/profile/authors/14596665-andrik-rampuntag:in.mathworks.com,2005:Question/4460702019-02-20T16:28:23Z2019-02-21T10:03:35ZEditing zData field of a contour plot via Property Inspector in R2018bIn 2016b you could access and edit the zData used to generate a contour plot via the property inpector by clicking on a yellow matrix icon next to the zData property. In 2018b, the zData field in the property inspector shows the size of the matrix (e.g. 7x8 double ) but there seems to be no way of accessing the matrix values themselves directly from the inspector window.
Is this functionality still available in 2018b? If so, how?GChttps://in.mathworks.com/matlabcentral/profile/authors/2241020-gctag:in.mathworks.com,2005:Question/4455692019-02-18T13:31:52Z2019-02-21T10:03:21ZHow to reuse function and generate less files using HDL coder I have a simulink design that is very repetetive and uses the same subsystems and blocks multiple times.
The HDL coder is generating a huge number of files, for instance I have multiple Image Filter blocks and the coder generates ,for each of them, a number of files for padding, data memory lines, line buffer.... the project becomes unweildy very quickly with over a 1000 files.
Is there a way to reuse functions and subsystems throughout the project?Allahttps://in.mathworks.com/matlabcentral/profile/authors/10293991-allatag:in.mathworks.com,2005:Question/4462002019-02-21T09:57:42Z2019-02-21T10:00:12ZFill certain positions of circular matrix with zerosI am trying to make genetic algorithm and I would like to know if is it possible obtain the children matrix in a shorter and more efficient way.
A = [7 3 1 8 2 4 6 5
4 3 2 8 6 7 1 5
1 5 2 6 3 7 4 8
8 1 6 3 4 7 2 5] %ORIGINAL MATRIX
N = 4;
at = ceil(length(A)*rand(length(A)/2,1))
[r, c] = size (A);
tmp = mod (repmat (0 : c-1, r, 1) - repmat (-at+1, 1, c), c) + 1;
fatherGenes = A(sub2ind ([r, c], repmat ([1 : r].', 1, c), tmp))
fatherGenes = fatherGenes(:,1:N)
children = zeros(N,length(A))
children(:,1:N)=fatherGenes
tmp = mod (repmat (0 : c-1, r, 1) - repmat (at+1, 1, c), c) + 1;
children = children(sub2ind ([r, c], repmat ([1 : r].', 1, c), tmp)) %DESIRED MATRIX
children = [6 5 7 0 0 0 0 4
1 5 4 3 0 0 0 0
4 8 1 0 0 0 0 7
2 0 0 0 0 3 4 7]Izan Segarrahttps://in.mathworks.com/matlabcentral/profile/authors/6999599-izan-segarratag:in.mathworks.com,2005:Question/4450982019-02-15T07:02:21Z2019-02-21T09:59:44ZImage not able to detect SURF featuresI have a image and I am trying to detect SURF features points on image. Instead of detecting features points , I am getting error as :
Operands to the || and && operators must be convertible to logical scalar values.
Error in vision.internal.FeaturePoints/plot (line 152)
if k==1 && ~wasHeld
Error in SURFPoints/plot (line 172)
h = plot@vision.internal.FeaturePoints(this, ...
Error in surf_features (line 31)
plot(selectStrongest(boxPoints, 50));
boxImage1 = imread('C:\Users\prayag\Desktop\images-capstone\gandhi_crop.jpg') ;
boxImage = rgb2gray(boxImage1) ;
boxPoints = detectSURFFeatures(boxImage);
figure;
imshow(boxImage);
title('50 Strongest Feature Points from Box Image');
hold on;
plot(selectStrongest(boxPoints, 50));
This is the code I am using.
and below is the image I am using.
Prayag Bhatiahttps://in.mathworks.com/matlabcentral/profile/authors/7208494-prayag-bhatiatag:in.mathworks.com,2005:Question/4461632019-02-21T05:24:41Z2019-02-21T09:55:31ZAfter running the code for (f ') w.r.t x , we need to draw( f ' ) w.r.t G (in X-axis) while varying n=0, 0.5, 1function main
Pr=1;K=1;L=-1;S=0.1;
n=input('n=');
a=linspace(0,6,100);
G=linspace(0,7,100);
solinit=bvpinit(a,G,[0 1 0 1 0 0 1]);
sol=bvp4c(@ode,@bc,solinit);
xint=a;
sxint=deval(sol,xint);
function res=bc(ya,yb,G)
res=[ya(1)-S; ya(2)-L; ya(4)+n*ya(3); ya(6)-1; yb(2)-1; yb(4); yb(6);];
end
function dydx=ode(x,y,G)
dydx=[y(2); y(3);(y(2)^2-1-y(1)*y(3)-K*y(5)-G*(1-y(2)))/(1+K);y(5);2*(y(2)*y(4)-y(1)*y(5)+K*(2*y(4)+y(3)))/(2+K);y(7);-Pr*y(1)*y(7)];
end
plot(xint,sxint([2],:),'Linewidth',2); %for f'
xlabel('\eta');
ylabel('f^\prime');
hold on
end
ERROR occurs as:
n=0
Error using bvparguments (line 108)
Error in calling BVP4C(ODEFUN,BCFUN,SOLINIT):
The derivative function ODEFUN should return a column vector of length 100.
Error in bvp4c (line 130)
bvparguments(solver_name,ode,bc,solinit,options,varargin);
Error in (line 7)
sol=bvp4c(@ode,@bc,solinit);
MINATIhttps://in.mathworks.com/matlabcentral/profile/authors/10813789-minatitag:in.mathworks.com,2005:Question/4461962019-02-21T09:44:33Z2019-02-21T09:52:57ZHelp me to sort out this problem.I am facing this problem continously, how to sort out this issueZaigham Abbashttps://in.mathworks.com/matlabcentral/profile/authors/6838243-zaigham-abbastag:in.mathworks.com,2005:Question/4461982019-02-21T09:49:59Z2019-02-21T09:52:26Zsymbolic definition disabled in MATLAB r2017bHi,
I am using MATLAB r2017b and upated recently with Update 9.
By the way I am still facing the trouble with symbolic definition (e.g. syms x y(t) somthing like these)
How can I fix it?
Best regards,
SungSungsoo Limhttps://in.mathworks.com/matlabcentral/profile/authors/10816787-sungsoo-limtag:in.mathworks.com,2005:Question/4449022019-02-14T06:53:54Z2019-02-21T09:50:47ZHow can i choose the k initial centroids far away from each other in k-means clustering based image segmentationThe steps performed for k-means clustering are as follows:
Choose k initial centroids
Compute the distance from each pixel to the centroid
Recalculate the centroids after all the pixels have been assigned
Repeat steps 2 and 3 until the same points are assigned to each cluster in consecutive rounds.
How can i choose the k-initial centroids, such that they are far from each other. sumaiya khanhttps://in.mathworks.com/matlabcentral/profile/authors/9728390-sumaiya-khantag:in.mathworks.com,2005:Question/4461942019-02-21T09:33:39Z2019-02-21T09:50:42Z3D point cloudI am trying to get a 3D point cloud using the following code:
output_dir = 'C:\Users\HITESH\Desktop\Matlab';
%%set up webcam
delete(imaqfind)
leftCam = imaq.VideoDevice('winvideo', 2, 'YUY2_640x480');
rightCam = imaq.VideoDevice('winvideo', 1, 'YUY2_640x480');
%%load stereo parameters if required
if ~exist('stereoParams', 'var')
load stereocalibration.m;
end
ax = axes;
maxDepth = 5;
clear maxdepth;
while true
imageLeft = step(rightCam);
imageRight = step(leftCam);
[J1, J2] = rectifyStereoImages(imageLeft, imageRight, stereoParams);
disp = disparity(rgb2gray(J1), rgb2gray(J2), 'DisparityRange', [0, 112]);
pointCloud = reconstructScene(disp, stereoParams) ./1000;
z = pointCloud(:,:,3);
z(z<0) = NaN;
z(z>maxDepth) = NaN;
pointCloud(:,:,3) = z;
if ~ishandle(ax)
break;
else
showPointCloud(pointCloud, J1, 'VerticalAxis', 'Y', 'VerticalAxisDir', 'Down', 'Parent', ax);
xlabel('X (m)');
ylabel('Y (m)');
zlabel('Z (m)');
xlim(ax, [-.8, .8]);
ylim(ax, [-.8, .8]);
zlim([ax, maxDepth]);
drawnow;
end
end
release(leftCam);
release(rightCam);
ERROR:
Error using matlab.graphics.axis.Axes/horzcat
Cannot convert double value 5 to a handle.
MATLAB R2015a
Hitesh Phttps://in.mathworks.com/matlabcentral/profile/authors/14613530-hitesh-ptag:in.mathworks.com,2005:Question/4163842018-08-27T13:54:38Z2019-02-21T09:40:52ZError in readMessages from generated ROS messageHi all,
I have some custom ROS messages that I have loaded into MATLAB utilizing the rosgenmsg routine. Everything went fine and they show up when calling rosmsg list.
When I went to read messages of the custom type from my rosbag I received the following error:
Reference to non-existent field 'Forces_'.
Error in robotics.ros.custom.msggen.sfm_msgs.Forces/reload (line 165)
Forces_Cell = arrayfun(@(x) feval([obj.SfmMsgsForceClass '.loadobj'], x), strObj.Forces_, 'UniformOutput', false);
Error in robotics.ros.Message/fromStruct (line 172)
obj.reload(sObj);
Error in robotics.ros.BagSelection/readMessages (line 280)
msgs{i}.fromStruct(msgStructs{i});
I did some investigation on how the function works and where the error comes from. In
robotics.ros.Message/fromStruct
the code tries to create a message object from the bag information (which is in struct format). For my custom message of type
sfm_msgs/Forces
the field names for the message and the structs (these are autogenerated by rosgenmsg) differ:
K>> msgs{1}
ans =
ROS Forces message with properties:
MessageType: 'sfm_msgs/Forces'
Header: [1×1 Header]
Forces_: [0×1 Force]
versus
K>> msgStructs{1}
ans =
struct with fields:
MessageType: 'sfm_msgs/Forces'
Header: [1×1 struct]
Forces: [1×6 struct]
This leads to the top-most error of my error message. As mentioned, this naming difference is autogenerated by the rosgenmsg routine.
The original .msg message definitions are:
Forces.msg:
std_msgs/Header header
Force[] forces
Force.msg:
uint8 ATTRACTIVE=0
uint8 INT_ROBOT=1
uint8 INT_OBSTACLE=2
uint8 INT_HUMAN=3
uint8 type
string entity_name
geometry_msgs/Vector3 force
So... yeah. I have no idea how to fix this and as far as I am considered this is a bug in the rosgenmsg routine. Hopefully some of you guru's have an idea!
P.S. I am using MATLAB Version: 9.4.0.813654 (R2018a) with Robotics System Toolbox Version 2.0 (R2018a)
Joep Linssenhttps://in.mathworks.com/matlabcentral/profile/authors/3857061-joep-linssentag:in.mathworks.com,2005:Question/4461952019-02-21T09:40:26Z2019-02-21T09:40:26Zcalibration of stereo camera'sHi All,
I'm working on a 3d reconstruction of a scene, I took 13 pairs of calibration images using a checkerboard pattern, When I calibratie the camera's one by one I get a reproduction errors < 0.4 pixel, how ever wehen usig the steroe calibration app I get a reprojection error of > 200 pixel and some very very weird deformed images. I noiced that the app defined the origin of the x-y system radomly, when I select only image pais having the same corenr chosesn for origin the reproejction error goes down to 20 pixel (still far to high). Has anybodey suggestions whtacould be wrong? If you need more infor, please let me know.
kind regards
Francois ClemnesFrancois Clemenshttps://in.mathworks.com/matlabcentral/profile/authors/4521513-francois-clemenstag:in.mathworks.com,2005:Question/4449232019-02-14T09:14:34Z2019-02-21T09:38:57Zmaximum width of a blobHi
I have two blobs(see the attached image). i can calculate the maximum length "regionprops" but the issue is that i also want to calculate maximum width of each blob instead of average width.how can i do that? any idea?
Thanks!Malik Malikhttps://in.mathworks.com/matlabcentral/profile/authors/14784207-malik-maliktag:in.mathworks.com,2005:Question/4435722019-02-06T19:38:24Z2019-02-21T09:37:17ZAnother Bug in Matlab 2018b: iLaplace cannot compute a valid systemThe following line of codes show that the system ys and the input xs are valid and the lsimplot shows the output response properly. Why the ilaplace in the last plot doesn't work and generates junk results?
syms s t
time=linspace(0,4e-09,201).';
xs=(0.5/s)*(1-exp(-5e-10*s))/(1+exp(-5e-10*s));
xt=double(subs(ilaplace(xs,s,t),t,time));
ys=(1.3e12*s^3+2.5e28*s^2+2.3e41*s+5.3e53)/(s^4+4e16*s^3+4.1e29*s^2+1.3e42*s+1.2e54);
[num,den]=numden(ys);
figure
lsimplot(tf(sym2poly(num),sym2poly(den)),xt,time)
figure
plot(time,double(subs(ilaplace(xs*ys,s,t),t,time)))S Hhttps://in.mathworks.com/matlabcentral/profile/authors/6229522-s-htag:in.mathworks.com,2005:Question/4461322019-02-20T23:10:11Z2019-02-21T09:36:14ZSolve for symbol not finding explicit solutionHi all,
Im trying to isolate/solve an equition for a symbol, but both the solve and isolate function arent providing any solutions.
Heres my code:
clear
syms H SH AO RA;
t = sqrt(H / pi);
r = (0.506 * t + 1.0) / (1.79 * t^2 + 2.045*t + sqrt(2.0));
a = 1.0 / (0.803 * t^3 + 1.886 * t^2 + 2.524*t + 2.0);
c = 0.5 - r * sin(0.5 * pi * (a - t^2));
s = 0.5 - r * cos(0.5 * pi * (a - t^2));
eqn = ((pi * (cos(H / 2.0) * c + sin(H / 2.0) * s)^2) / ( RA^2 * (sin(H / 2.0 + AO))^2)) == SH;
answer = solve(eqn, H);
I've looked on this forum and google and ive tried a bunch of stuff but i cant figure this outJBertelinghttps://in.mathworks.com/matlabcentral/profile/authors/14838035-jbertelingtag:in.mathworks.com,2005:Question/4461892019-02-21T09:08:21Z2019-02-21T09:31:49ZHow to divide the input data for two levels in matlabL= 2; % L is no. of levels
L_total= 400;
[temp, alpha] = sort(rand(1,L_total)); %Howto divide this data into half for giving to two levels
nishika Katiyarhttps://in.mathworks.com/matlabcentral/profile/authors/14841358-nishika-katiyartag:in.mathworks.com,2005:Question/4461932019-02-21T09:25:59Z2019-02-21T09:25:59ZCompute the ctft of e^-2t.u(t) and plot magnitude vs frequency using matlab Can someone help me with the MATLAB CODE FOR THE ABVE QUESTION. I AM UNABLE TO SOLVE IT.Twinkle Vhatkarhttps://in.mathworks.com/matlabcentral/profile/authors/14166417-twinkle-vhatkartag:in.mathworks.com,2005:Question/4460952019-02-20T18:21:12Z2019-02-21T09:25:02ZReturn matrix of maximum valuesI have a matrix of the form:
a =
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
column 1 & 2 represent x,y positions while col 3-5 represent intensity. I obtained the maximum and index of the intensity for each position from [M,I] =max(a(:,3:5),[],1). I am struggling with how to obtain the x,y positions corresponding to each maximum intensity. Any help would be appreciated. Thanks.Folu Yusufhttps://in.mathworks.com/matlabcentral/profile/authors/12810130-folu-yusuftag:in.mathworks.com,2005:Question/4455432019-02-18T10:43:33Z2019-02-21T09:24:02ZHow to interpolate in 3d?I have a matrix in 100 distane and 10 distance which i want to interpolate to 1
but as it is a matrix i want to interpolate in 3D
I have tried it interpolating in 2D and getting some irregularities in the which can be seen in attached picture
The 2D code is as follows
[num] = xlsread('Mappe2.xlsx') ;
n = 860;
num1=num(2:87,2:26)';
B = interp1(1:size(num1, 2), num1.', linspace(1, size(num1, 2), n));
n = 250;
B1 = interp1(1:size(B, 2), B.', linspace(1, size(B, 2), n));
surf(1:860,1:250,B1,'edgecolor','none');
How to code further to avoid these irregularities?
I have also attached the Excel file feom the code
Shubham Mohan Tatpalliwarhttps://in.mathworks.com/matlabcentral/profile/authors/11425755-shubham-mohan-tatpalliwartag:in.mathworks.com,2005:Question/4461922019-02-21T09:23:57Z2019-02-21T09:23:57ZVariable Gain Amplifier (VGA)Where can I find the variable gain amplifier VGA in Matlab? My university has the electronics toolbox and a new version of it. I looked it up in the documentation but I can't find it in our SimulinkEledharadhttps://in.mathworks.com/matlabcentral/profile/authors/14841585-eledharadtag:in.mathworks.com,2005:Question/4459052019-02-19T21:40:10Z2019-02-21T09:23:25Zplot in predesigned figureHello
I have a script, where I tell my programm to create a figure, called h ,looking like the second picture.
then in a function within the scirpt (1. picture) i want matlab to draw my desired plot into the predesigned figure h. (See function in 4. picture)
but instead, matlab doesnt draw my plot into h, matlab draws it as in the 3. picture.
How do i plot into my predesigned figure h?
Thanks for the help!Josefina Ottitschhttps://in.mathworks.com/matlabcentral/profile/authors/13775798-josefina-ottitschtag:in.mathworks.com,2005:Question/2782752016-04-11T00:09:47Z2019-02-21T09:22:33ZHow I can download elec_lib to MATLABDear Matlab support
I'm writing you due to I cannot find the elec_lib in MATLAB 2016a, I'm studying a Master degree in Australia in Deakin Univ, my name is Andres Ojeda and just in case mi user ID ahojeda@deakin.edu.au
Andres Ojedahttps://in.mathworks.com/matlabcentral/profile/authors/7836258-andres-ojedatag:in.mathworks.com,2005:Question/4447492019-02-13T13:01:20Z2019-02-21T09:21:21ZProblem using nlinfit with a multivariable functionI have the following code so far:
clear , clc , clf
% EXPERIMENTAL DATA =======================================================
load('dispvst.mat'); % Reads Data Set 1
X1 = dispvst(:,2); % Time Vector
Y1 = dispvst(:,1); % Displacement Vector
% REGRESSION ==============================================================
beta0 = [1 2];
FIT = nlinfit(X1,Y1,@FUN1,beta0); % Coefficient Fit
% Function ================================================================
function MODELFUN = FUN1(k,c,t)
m = 1; % Mass (kg)
Wn = sqrt(k/m); % Wn
E = c / (2*Wn); % E
Wd = Wn * sqrt(1-E^2); % Wd
A = sqrt((Wn*E*X1(1)) / Wd + X(1)^2); % A
Phi = atan(Wd/(E*Wn)); % Phi
MODELFUN = A*exp(-E*Wn*t)*sin(Wd*t+Phi); % Model Function
end
% END =====================================================================
MatLab gives me the following error code:
%===========================================================================
Error using nlinfit (line 213)
Error evaluating model function 'FUN1'.
Error in HW2P3 (line 16)
FIT = nlinfit(X1,Y1,@FUN1,beta0); % Coefficient Fit
Caused by:
Error using /
Matrix dimensions must agree.
=================================================================================
I can't figure out the correct syntax to use in order to use the function in the nlinfit function
Dalton Kipphttps://in.mathworks.com/matlabcentral/profile/authors/13390122-dalton-kipptag:in.mathworks.com,2005:Question/4461912019-02-21T09:20:58Z2019-02-21T09:20:58ZInverse dynamics of vertical articulated robot with Simscape MultibodyHi.
I'm trying to make the inverse dynamics model of vertical articulated robot with Simscape Multibody.
But I couldn' understand this error message.
All of joint primitives are with automatically computed force and torque already.
And there's no joint primitives with motion from inputs.
Tool path(pose) was made by this robot's Kinetic simulation.
Is there anything wrong about this model?
Prease anyone.Tomoyuki Nishikorihttps://in.mathworks.com/matlabcentral/profile/authors/13868548-tomoyuki-nishikoritag:in.mathworks.com,2005:Question/4461752019-02-21T07:12:11Z2019-02-21T09:20:03ZTo convert a variable (struct with fields of numeric matrix) to a sliced variable (an array of struct)I was doing code refactor to apply parfor to some legacy code. Legacy code creates a big struct variable called 'Boot', with fields of numeric matrix.
I want to convert it to a new sliced variable "BootS" , but if I do the conversion like the attached image, Matlab give me warnings that I should preallocate it.
( iters means number of iterations.)
I tried to preallocate BootS as the code commented out , it fails with runtime errors.
Anyone has good idea to convert it elegantly??Owen Zhanghttps://in.mathworks.com/matlabcentral/profile/authors/12426090-owen-zhang