https://uk.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2020-01-23T08:24:23Ztag:uk.mathworks.com,2005:Question/5014392020-01-22T11:45:57Z2020-01-23T08:24:23ZSimulink Coverage setting 'CovModelRefExcluded'Hello!
I'm struggling around with the coverage setting 'CovModelRefExcluded'.
My model settings at the moment are
Hoever, when I try to exclude some models via
set_param(gcm,'CovModelRefExcluded','EGTR_FCTDGTDLOCP0, EGTR_FCTDGTDLOCLA0, EGTR_FCTDGTDLOCL0, EGTR_FCTDGTDLOCHA0')
measurement of coverage still runs over all models, and the GUI is not affected by the command line setting. However,
get_param(gcm,'CovModelRefExcluded')
returns me the list given above.
So, what did I forget here?
I'm a kind of stuck here :-).
Thanks a lot!
Greetings
MatthiasMatthiashttps://uk.mathworks.com/matlabcentral/profile/authors/5497657-matthiastag:uk.mathworks.com,2005:Question/5012572020-01-21T11:01:10Z2020-01-23T08:23:35Zerror due to function handle in for loopHi! I have a problem with my optimization problem. I try to minimize the difference between real option price and model option price (Its an option pricing model calibration). I use the for loop to catch every option in my dataset in the fmincon optimization to optimize the summed error of 'real' and 'model' price.
The code looks like this:
The "cl_heston()" is the pricing formla for the model price and works when inserting random numbers instead of x.
'Testset4' is the set with the information for the option price calculation
real is the actual historical price.
%Optimierung Heston Loop
clc
clear
global data;
x0 = [0.5 0.5 1 -0.5 1]; % starting values
lb = [0 0 0 -1 0]; % lower bound
ub = [1 1 6 1 20]; % upper bound
data = xlsread('Testset4');
for n = 1:length(data)
model(n) = @(x) cl_heston(data(n, 1), x(1), x(2), x(5), x(3), data(n, 4), 0, x(4), data(n, 2), data(n, 3)); % model price
real(n) = data(n, 5); % historical price
end
objective = @(x) sum(abs(real-model(x))); % objective function
%fmincon Funktion
x = fmincon(objective, x0, [], [], [], [], lb, ub, []);
objective(x)
When I run it I receive the error: Nonscalar arrays of function handles are not allowed; use cell arrays instead.
If I remove the '(n)' from 'model (n)' it works but just takes the last number in the dataset for the model price for every iteration.
Any help is highly appreciated! Jonas Huwylerhttps://uk.mathworks.com/matlabcentral/profile/authors/16656517-jonas-huwylertag:uk.mathworks.com,2005:Question/5010502020-01-20T09:26:06Z2020-01-23T08:20:59ZMatlab Amd GPU sopprt setupHello there,
I am runnign a script that i can't simplify any further, the problem is that i have to run big data sets.
The Pc i am running it on has an Amd Ryzen9 3900x (12 core 24 threads 4.1 ghz boost, running on all cores) , 16 gb 3200Mhz cl16 Ram, and a AMD Radeon Rx5700XT 8Gb GPU. I have read multiple threads that it is possible for Matlab to use the GPU (and yes Amd GPU's not Nivida GPU's). My question is how do i setup Matlab or the AMD driver?
Kind Regards
JJ Jonas Jeskulkehttps://uk.mathworks.com/matlabcentral/profile/authors/15214515-jonas-jeskulketag:uk.mathworks.com,2005:Question/5015702020-01-23T06:46:51Z2020-01-23T08:20:44ZHOW TO DELETE A LINE FROM A CREATING FILEHello, I have a question. I am creating a .csv file in MATLAB using the commands:
T = cell2table
writetable(T,'file.csv')
. I would like to delete from this file the 2nd row only, and keeping all the other rows. How could I make it?
ThanksRavn Michaelhttps://uk.mathworks.com/matlabcentral/profile/authors/15708342-ravn-michaeltag:uk.mathworks.com,2005:Question/4712652019-07-11T12:23:50Z2020-01-23T08:16:27Zdouble-click on "uilistbox" App designerHallop everyone,
How can I execute a double-click on ListBox in App Designer?
Thank you in Advance
joehttps://uk.mathworks.com/matlabcentral/profile/authors/4780336-joetag:uk.mathworks.com,2005:Question/5014312020-01-22T11:01:29Z2020-01-23T08:14:41ZFPRINTF making mistakes when inside a PARFOR loopHi there,
I am running a model that writes MATLAB code to a file every time it is run, and then runs that code. This model is run 5 times, separately, so I decided to replace the for-loop for this with a parfor-loop. To avoid mistakes/overlaps with writing to the file, I have made the model write to 5 different files. In summary, the pseudocode is this:
parfor i = 1:5
fprintf("model"+i+".m", "lots_of_code_gets_written_in_here"); % write the code for the model
if i == 1
model1(arg1,arg2); % run the model
elseif i == 2
model2(arg1,arg2); % run the model
elseif i == 3
model3(arg1,arg2); % run the model
elseif i == 4
model4(arg1,arg2); % run the model
elseif i == 5
model5(arg1,arg2); % run the model
end
end
This solution used to work perfectly. The parfor-loop would write code to 5 different files and run these 5 files separately and in parallel. Unfortunately, somehow it no longer works. What happens now is that when writing the code to the file, there are mistakes in the code - basic syntax mistakes like leaving out brackets, incomplete lines, etc. As a result, this written code no longer runs and I get an error.
I replaced the parfor-loop with a for-loop again, and everything works fine. There are no errors in the code written by MATLAB. But I would still like to use the parfor-loop because of the increased speed.
Any idea why having a parfor-loop might cause these errors and what I can do about this?
Would greatly appreciate any tips!
Best,
Alex
EDIT: this problem seems to be to do with the fact that these files are being written to a shared hard drive. At least, when I move my files back there, the problem comes back. Does this seem plausible and is there nonetheless a solution?Alex van Tuyllhttps://uk.mathworks.com/matlabcentral/profile/authors/9156947-alex-van-tuylltag:uk.mathworks.com,2005:Question/5015742020-01-23T08:13:05Z2020-01-23T08:13:05ZUnique dates and data, supplying values to all repeated dates in a matrix after indexing.Hi. I have a matrix (A = 70 x 2) with unique date and temperature. Then I have an array of dates (B = 500 x 1) with several repetition that exactly match with the unique dates in the matrix (A). How do I index the repeated dates in B with A? From this, I'd like to make a new column in B containing the temperature from A (even if they're repeated)? I tried intersect, find, fun, etc even using for loops, but I can't seem to find the right function or workaround to do this. Any help would be appreciated.Yaj16https://uk.mathworks.com/matlabcentral/profile/authors/10871111-yaj16tag:uk.mathworks.com,2005:Question/5015732020-01-23T08:12:23Z2020-01-23T08:13:00Zis there something similar to imregistrer but for video?I have a bunch of stereo videos, camera has shifted and the objects are small animals which look similar but are not identical. I am tracking certain facial features in the bats but I realized that the points in the videos don't have same coordinates. I was thinking of using imregister but that seems to only work for images, not videos.
So I have a three part question:
Are there functions similar to Imregster but for videos?
Or do I have to save the files as individual frames and go through the files frame by frame?
Or do I use FacialTracking code to find the relative movement and normalize it?
Thanks!Sam Litvinhttps://uk.mathworks.com/matlabcentral/profile/authors/1413666-sam-litvintag:uk.mathworks.com,2005:Question/5015722020-01-23T07:48:19Z2020-01-23T08:06:07Zhow can i rectify index position error?Hi guys,
Thanks for your support so far, please this part of matlab script (hydrogen storage model) is given me this error:
Index in position 1 exceeds array bounds (must not exceed 1).
Error in mescode2019 (line 264)
mesprob.Constraints.hydeogenstored=selfdchh*Eh2(idxHr2Toend-1,:)+(echh2*(h2ch(idxHr2Toend,:)*dt))-((edchh2(idxHr2Toend,:)*dt)/edh2)==Eh2(idxHr2Toend,:);
%initial time variables for 24hrs
dt=1; % Time step
nHours=numel(LD);
Time=(1:nHours)';
idxHr2Toend=2:nHours;
%battery model
mesprob.Constraints.Batstoredele=selfdchb*Et(idxHr2Toend-1,:)+(echb.*Pbch(idxHr2Toend,:)*dt)-...
((Pbdch(idxHr2Toend,:)*dt)./edchb)==Et(idxHr2Toend,:);
mesprob.Constraints.SOCb=Et(idxHr2Toend(1),:)<=Et(idxHr2Toend(end),:);
mesprob.Constraints.Etout=Et<= NOMb;
%thermal storage model
mesprob.Constraints.thermalstored=(1-qselfdch)*Eq(idxHr2Toend-1,:)+(echq.*(qch(idxHr2Toend,:)*dt))-...
((qdch(idxHr2Toend,:)*dt)./edchq)==Eq(idxHr2Toend,:);
mesprob.Constraints.SOCq=Eq(idxHr2Toend(1),:)<=Eq(idxHr2Toend(end),:);
mesprob.Constraints.Eqout=Eq<= NOMq;
%cold storage model
mesprob.Constraints.coldstored=(1-cselfdch)*Ec(idxHr2Toend-1,:)+(echc.*(cch(idxHr2Toend,:)*dt))...
-((cdch(idxHr2Toend,:)*dt)./edchc)==Ec(idxHr2Toend,:);
mesprob.Constraints.SOCc=Ec(idxHr2Toend(1),:)<=Ec(idxHr2Toend(end),:);
mesprob.Constraints.Ecout=Ec<= NOMc;
%hydrogen storage model
mesprob.Constraints.hydeogenstored=selfdchh*Eh2(idxHr2Toend-1,:)+(echh2*(h2ch(idxHr2Toend,:)*dt))...
-((edchh2(idxHr2Toend,:)*dt)/edh2)==Eh2(idxHr2Toend,:);
mesprob.Constraints.SOCh=Eh2(idxHr2Toend(1),:)<=Eh2(idxHr2Toend(end),:);
mesprob.Constraints.Ehout=Eh2 <= NOMh;
This most confusing part is that, the same procedure is applicable to battery storage, cold storage and heat storage, but those ones are not showing that kind of error, please how can i rectify it?
Thanks
tobi alabihttps://uk.mathworks.com/matlabcentral/profile/authors/16243865-tobi-alabitag:uk.mathworks.com,2005:Question/5010602020-01-20T10:43:07Z2020-01-23T08:04:37ZHow can i convert set of images from RGB to Lab using matlab?I have a set of images and I want to convert them from RGB to Lab , then i want to access and save L ,a,b values for each images .ahmad Al sarairahhttps://uk.mathworks.com/matlabcentral/profile/authors/15606036-ahmad-al-sarairahtag:uk.mathworks.com,2005:Question/4042902018-06-06T10:16:29Z2020-01-23T07:59:49Z3D plot over triangular grid
I want to make a 3D plot over a non-rectangular grid. I have vectors X=linspace(0,1,100) and Y=linspace(0,1,100) and I create the typical rectangular grid [x,y]=meshgrid(X,Y).
Now I have matrix Z, and I can represent without problems mesh(x,y,Z). The thing is that I only know Z for points (x,y) with y less or equal than x, but never for (x,y) with y greater than x. Therefore, I would like to plot (x,y,Z) but showing only the triangular region of points (x,y) with x and y between 0 and 1 and y less or equal than x. How can I achieve this?
Thanks!Diego Soler Polohttps://uk.mathworks.com/matlabcentral/profile/authors/7908173-diego-soler-polotag:uk.mathworks.com,2005:Question/5010132020-01-19T23:14:41Z2020-01-23T07:55:16ZRecolouring Sentinel2 multispectral imageHello,
I am trying to recolour an image composed of the red, green and blue channels of Sentinel 2 imagery (Bands 4, 3 and 2, respectively). I have processed this imagery in the SNAP toolbox and exported in netCDF4-BEAM format.
Firstly, I read in the required image bands and create the RGB image:
address = %file location on computer;
ncid = netcdf.open(address);
bands{1} = transpose(im2double(netcdf.getVar(ncid,4))); %Red channel
bands{2} = transpose(im2double(netcdf.getVar(ncid,3))); %Green channel
bands{3} = transpose(im2double(netcdf.getVar(ncid,2))); %Blue channel
Image = cat(3,bands{1},bands{2},bands{3}); %RGB image, datatype of double
When I try to visualise the image with imshow(Image), the result is near monochromatic. I understand this is due to correlation between channels and so I wish to recolour the image.
What is the best way to do this?
I have tried to use the code below, however this makes no difference:
stretchedImage = imadjust(Image,stretchlim(Image));
I have also investigated the image histograms however I don't understand why there is a difference between histogram(Image) and imhist(Image). I think the differences in the outputs of these may be related to my issues with strethlim, hopefully you can help shine a light on this for me!
Many thanks.Aidan Woodhttps://uk.mathworks.com/matlabcentral/profile/authors/9032996-aidan-woodtag:uk.mathworks.com,2005:Question/5006102020-01-16T14:49:21Z2020-01-23T07:37:02ZSimulation Data Inspector - Activate another run to display its dataI have multiple runs in the Simulation Data Inspector. The latest run is marked with "[Current]" and is displayed.
How can I activate another run to display its data?
Thanks in advance!
Alexander Lampehttps://uk.mathworks.com/matlabcentral/profile/authors/4358045-alexander-lampetag:uk.mathworks.com,2005:Question/5008512020-01-18T11:09:29Z2020-01-23T07:33:48ZLimiting mouseclick event to current Axes in App DesignerHi, I am trying to get the mouselocation on an axes - 'app.UIAxes' (using app designer).
delete(findobj(app.UIAxes, 'Marker', '*')); %DElete previous marker
z=app.UIAxes.CurrentPoint;
x=z(1,1); y=z(1,2);
hold(app.UIAxes,'on');
plot(app.UIAxes,x,y,'b*');
hold(app.UIAxes,'off');
app.xy=[x,y]; %Save value so can access later
However, as I also have 2 other UIAxes (app.UIAxes2 & app.UIAxes3), whenever I click on any of them, it invokes the fucntion above and plots a point on the UIAxes.
How can I limit this to just the UIAxesJasonhttps://uk.mathworks.com/matlabcentral/profile/authors/1217570-jasontag:uk.mathworks.com,2005:Question/5014592020-01-22T13:17:37Z2020-01-23T07:31:30ZHow can I use my CNN after training (Image Recognition)Hello everyone,
I'm new to MATLAB but am working on a project so I've problem using and understanding new function and I'm not too good at deep learning with respect to hands on approach.
I've written code for CNN and trained the network somehow but I'm not able to use that trained network, will be greatful for any help.
Here's part of my code: -
%% Creating the CNN
% I've defined inputlayer, middlelayer and finallayer and it's training successfully
layers = [
inputlayer
middlelayer
finalayer
];
options = trainingOptions('sgdm','MaxEpochs',50, ...
'InitialLearnRate',0.000001);
convnet = trainNetwork(trainData,layers,options);
thisNetwork = convnet;
save('TheTrainedCNN','thisNetwork');
If I load my network with command using : -
load('TheTrainedCNN');
OR
load('TheTrainedCNN.mat')
I don'd get any error.
Then when I try to use it using: -
result = TheTrainedCNN('test.jpg');
I get error as:-
Unrecognized function or variable 'TheTrainedCNN'.zayeema masoomhttps://uk.mathworks.com/matlabcentral/profile/authors/16962827-zayeema-masoomtag:uk.mathworks.com,2005:Question/4403192019-01-18T02:28:02Z2020-01-23T07:28:25ZMATLAB 2018b does not start, MATLAB 2018a starts, but takes forever to compute as simple as 2+2I had an original academic installation of MATLAB 2018a on my laptop which worked fine. Later I added a 2018b version as well. Both worked fine. But, recenltly on a random day, the laptop crashed while MATLAB 2018b was open. Ever since then, MATLAB 2018b executable does not open MATLAB, as if it does not exist at all. I reinstalled it fresh, but that did not help. The 2018a version opens and works randomly, but again also randomly freezes forever to do such simple tasks as 2+2. Any help is greatly appreciated.A Kinghttps://uk.mathworks.com/matlabcentral/profile/authors/7306850-a-kingtag:uk.mathworks.com,2005:Question/5013972020-01-22T08:04:59Z2020-01-23T07:23:11Zfscanf question when ignoring headerHello,
I have a text file that im having issues with. Ive been able to read my others files but this one for some reason isnt working properly when trying to us fscanf.
The file has 5 headers then data of 2k samples:
SAMPLES: 2000
BITSPERSAMPLE: 32
CHANNELS: 1
SAMPLERATE: 96000
NORMALIZED: FALSE
50
45
30
etc...till 2k values
My code: for convience lets say this file is file # 4.
formatSpec = '%*s %f'; %ignore strings and keep integers
myCell = {}; %create cell to put data into after uigetfile
[file,path] = uigetfile('*.rnd','MultiSelect', 'on');
%creates file{1,X}
%open file # 4
pathname = file{1,4};
%use current pathname to open file
fileID = fopen(pathname,'r');
%read file with formatSpec set to ignore strings and read only numbers
myCell{1,1} = fscanf(fileID,formatSpec);
Pretty straightforward. And my code for opening all of my other files that have different headers/footers works fine,and they all use this same setup for formatSpec and fscanf. But when opening this file it just returns [2000,32,1,96000] in myCell.m jhttps://uk.mathworks.com/matlabcentral/profile/authors/8259812-m-jtag:uk.mathworks.com,2005:Question/4951962019-12-06T09:21:32Z2020-01-23T07:22:55ZStoring decomposition object for future useI used the function decomposition to create a MATLAB decomposition object dA.
dA = decomposition(A)
Since my primary matrix A is same for all simulations even with other parameters, I wish to create dA once (and by once I do not mean not once at the start of every simulation but say once in a lifetime since my matrix A remains exactly same for the present physics) and store it as a .mat file (or any other file system) so that I can re-use it without re-running it for every new simulation. However, MATLAB gives a warning
Warning: Saving a decomposition is not supported.
> In decomposition/saveobj (line 667)
Is there any other round about to save dA and re-load and use it for future use.
Thanks in advance. Jayabrata Dharhttps://uk.mathworks.com/matlabcentral/profile/authors/16786834-jayabrata-dhartag:uk.mathworks.com,2005:Question/4309402018-11-20T10:34:36Z2020-01-23T07:19:43Zcombine two matrices to get another matrix of same sizeI have two matrices of same order say 'a' and 'b':
a=[1,2;3,4];
b=[5,6;7,8];
How to combine these matrices in order to get a 3rd matrix of the form:
c=[15,26;37,48]
i.e. each cell of first matrix combine with corresponding cell of another matrix.tanveer haqhttps://uk.mathworks.com/matlabcentral/profile/authors/13868209-tanveer-haqtag:uk.mathworks.com,2005:Question/5015442020-01-22T22:07:03Z2020-01-23T07:14:21Z3D plot for PDP Hi all,
I have 29 PDP plots, each plot corresponds to different receiving angle but one tx angle. I want a 3D plot for this case, Is it possible ? please help me with generic code.
Thanks in advanceMeghashree Srikantaiah Manjeshhttps://uk.mathworks.com/matlabcentral/profile/authors/13017303-meghashree-srikantaiah-manjeshtag:uk.mathworks.com,2005:Question/3789412018-01-25T13:18:11Z2020-01-23T07:13:15ZMatlab code for Optimization of Distributed GenerationMatlab code for Optimization of Distributed GenerationRespect Every Onehttps://uk.mathworks.com/matlabcentral/profile/authors/11983263-respect-every-onetag:uk.mathworks.com,2005:Question/4412882019-01-24T14:23:37Z2020-01-23T07:12:49ZFunction block is working in Matlab but not in simulink Hi,
I am currently trying myself on some human activity recognition on android. I used the "Human Activity Recognition Simulink Model for Smartphone Deployment" example as a starting point but as I wanted to do other activities and some more amndroid stuff I decided to only reuse some part of the 'slexHARAndroidExample' simulink i.e. the extractFeature block.
My problem is that I cannot simulate my model and if I use the embedded coder to deploy it, it classifys everything the same. Interesting is that it works correctly if I do it in Matlab step by step.
So if I run the following lines in Matlab directly it works fine:
feats = extractFeatures(X_Buff,Y_Buff,Z_Buff);
Act = predict(mdl,feats);
But if I want to simulate it by
Act = sim('ClassME')
with the same X_Buff,Y_Buff,Z_Buff in the workspace I get the following Error:
Index exceeds array dimensions. Index value 0 exceeds valid range [1-2049] of array f. Error in 'ClassME/extractFeatures' (line 133) ofpk = f(olocs); Error in 'ClassME/extractFeatures' (line 62) Error in 'ClassME/extractFeatures' (line 16)
although the code is the same.
Below is my simulink model where extractFeatures and predictActivity are taken from the example, although I trained the model for the predict block with diefferent data.
I am currently using Matlab version R2018b. Do you have any idea or starting point why it behaves like this?Michael Erdlhttps://uk.mathworks.com/matlabcentral/profile/authors/7237151-michael-erdltag:uk.mathworks.com,2005:Question/5015622020-01-23T05:28:50Z2020-01-23T07:12:06ZContrast stretching diagram formula with imadjust function in matlabHelp me....
I have an image output contrast stretching use function "imadjust"
How i can see a diagram like bellow with my image contrast stretching...?
<</matlabcentral/answers/uploaded_files/267359/images%20(1).png>>
Nayuta Altriahttps://uk.mathworks.com/matlabcentral/profile/authors/17089355-nayuta-altriatag:uk.mathworks.com,2005:Question/5015682020-01-23T06:30:40Z2020-01-23T07:11:18Zhow to combine matricesI have two matrices: A & B ... I want to combine them so that every element will be near the other one's corresponding element. For example something like C matrix.
A=[1,2;3,4]
B=[5,6;7,8]
C=[15,26; 37, 48]Ani Asoyanhttps://uk.mathworks.com/matlabcentral/profile/authors/17285928-ani-asoyantag:uk.mathworks.com,2005:Question/5011092020-01-20T15:40:37Z2020-01-23T07:10:37ZHow to programmatically "click" the block mask Apply or OK button.I have created a Block Mask with a Text area. A callback is writing a text to this Text area using set_param(gcb,'VariableText_', 'A little house');
The text is written into the Text Area and clicking the Apply button will save the text. That works Ok, off cause.
What I want to do, and is not able to figure out, is how I programmatically can "click" the Apply or the OK button from the callback?
The purpose is to save the contents of the Text area programmatically.
People have been asking this question before, but I have not found any useful answer.Petter Gran-Jansenhttps://uk.mathworks.com/matlabcentral/profile/authors/7173589-petter-gran-jansentag:uk.mathworks.com,2005:Question/5009952020-01-19T18:44:59Z2020-01-23T07:08:24ZUndefined variable or function 'f'Hi, I'm trying to resolve an error in my matlab code, which is trying to find the inductance and resistance through voltage and current. Here are my codes:
function [b,m,db,dm] = wRegression(x, y, dy)
% WREGRESSION [b,m,db,dm] = wRegression(x, y, dy)
% Written by: Allen Zhong
% takes x and y values, and uncertainies on y (dy), and outputs the slope
% (m), intercept (b), slope error (dm), and intercept error (db) for the
% linear regression (y = mx + b)
%define the variable w to simplify expressions
w = 1./(dy.^2);
D = addUp(w).*addUp(w.*x.^2)-(addUp(w.*x)).^2;
b = (addUp(w.*x.^2).*addUp(w.*y)-addUp(w.*x).*addUp(w.*x.*y))/D; %Computes y intercept
m = (addUp(w).*addUp(w.*x.*y)-addUp(w.*x).*addUp(w.*y))/D; %Computes slope
db = sqrt(addUp(w.*x.^2)/D); %Computes uncertainties in intercept
dm = sqrt(addUp(w)/D); %Computes uncertainties in slope
end
function [L, R, dL, dR] = findInductanceAndResistance(f, V, I, dV, dI)
wsq = (2.*pi.*f).^2;
Z2 = (V./I).^2;
dzSqrd = ((Z2(V+dV,I)-Z2(V,I)).^2+(Z2(V,I+dI)-Z2(V,I)).^2).^0.5;
[Rsq,Lsq,dLsq,dRsq] = wRegression(wsq,Z2,dzSqrd);
L= (Lsq).^0.5;
R = (Rsq).^0.5;
dR = (Rsq+dRsq).^0.5-(Rsq).^0.5;
dL = (Lsq+dLsq).^0.5-(Lsq).^0.5;
end
For 'findInductanceAndResistance', I can't seem to get it working as there is always an unresolved 'undefined function 'f''. Any help and assistance would be appreciated.
Allen Zhonghttps://uk.mathworks.com/matlabcentral/profile/authors/13541351-allen-zhongtag:uk.mathworks.com,2005:Question/5014042020-01-22T08:52:59Z2020-01-23T07:07:28ZNeed a filter which crop the detected mouth.% % Reading an Image %%
a=imread('C:\Users\SanaUllah\Documents\MATLAB\face.jpg');
subplot(1,3,1);
imshow(a);title('Original Image');
% % Detection %%
detector=vision.CascadeObjectDetector('mouth');
detector.MergeThreshold=150;
boundingbox=step(detector,a);
out=insertObjectAnnotation(a,'rectangle',boundingbox,'mouth Detected','LineWidth',3,'TextColor','black');%Annotation(Extra Info.)
subplot(1,3,2);
imshow(out);title('Detected Image');
% % Cropping Detected Part %%
Sana Ullahhttps://uk.mathworks.com/matlabcentral/profile/authors/16684857-sana-ullahtag:uk.mathworks.com,2005:Question/5015422020-01-22T21:34:42Z2020-01-23T07:05:03ZHow to find a custom object in images with convolutional neural network?How to create a convolutional neural network to find a particular object in images?Daniel Merlohttps://uk.mathworks.com/matlabcentral/profile/authors/12481331-daniel-merlotag:uk.mathworks.com,2005:Question/5014832020-01-22T15:31:20Z2020-01-23T07:04:40ZGeneral images.roi.Line questions - movingROI and roiMoved callbacks, etc. Hello all,
I was hoping for some help as I navigate the new(ish) images.roi objects in Matlab 2019b.
Is there a way to add a listener for the ROIMoved or movingROI events when they are not performed interactively, but instead programmatically (e.g. another code performs a set(roiObj,’Position’,pos) command? I have tested this, but it doesn’t ever trigger my callback, while interacting in the UI does.
Is there a way in ROIMoved or movingROI callbacks to differentiate whether an endpoint or the ROI itself has been moved? As per the documentation “Move the ROI - Position the pointer over the ROI. The pointer changes to the fleur shape. Then click and drag the ROI.”. What if I want a different callback when dragging with the “fleur” vs. the endpoints?
Is there a way to add other hot-keys to the “wait” function for ROIs – instead of double clicking, what if I also want a hotkey like spacebar or enter to complete the wait function?
Thanks, hopefully the answers will generalize to the other images.roi classes.
-DanDaniel Plotnickhttps://uk.mathworks.com/matlabcentral/profile/authors/16580652-daniel-plotnicktag:uk.mathworks.com,2005:Question/4383932019-01-05T15:22:54Z2020-01-23T07:04:36Zunable to run "slexHARAndroidExample" file on simulinkHello All
i'm trying to run file "slexHARAndroidExampleslexHARAndroidExample " on simulink but with no joy, the details are in the below link
https://www.mathworks.com/help/stats/human-activity-recognition-simulink-model-for-deployment.html
when i run it i got the below errors
Index exceeds array dimensions. Index value 0 exceeds valid range [1-2049] of array f.
Error in 'slexHARAndroidExample/extractFeatures' (line 133)
ofpk = f(olocs);
Error in 'slexHARAndroidExample/extractFeatures' (line 62)
Error in 'slexHARAndroidExample/extractFeatures' (line 16)omar sheishaahttps://uk.mathworks.com/matlabcentral/profile/authors/14137200-omar-sheishaatag:uk.mathworks.com,2005:Question/5010952020-01-20T14:30:56Z2020-01-23T07:03:35ZBlob analysis to a difference image gave me an over segmented moving object picture. Is there any way to correctly estimate the moving object shape ? I already tried morphological closing but it didn't work.Sai Sreekar Doranalahttps://uk.mathworks.com/matlabcentral/profile/authors/14787098-sai-sreekar-doranalatag:uk.mathworks.com,2005:Question/5015712020-01-23T07:00:14Z2020-01-23T07:00:14ZI have acquired some y axis values in display in the simulink. I want to automatedly find the coresponding x value in the graph. is the any such block available for the same or any method to do so?SHANTANU KSHIRSAGARhttps://uk.mathworks.com/matlabcentral/profile/authors/14328513-shantanu-kshirsagartag:uk.mathworks.com,2005:Question/5015662020-01-23T06:07:49Z2020-01-23T06:55:59ZHow do you pass MATLAB date (or user input) to SQL query for execution>> myDate= datetime('2020-01-01');
>> selectquery = 'SELECT * FROM myTABLE WHERE reportDate >= '''myDate''' AND portfolio =''ABC'' ';
>> Data = select(conn,selectquery);
I have tried a few quotation mark sequences around 'myDate' but doesn’t seem to be working. My database is MS SQL Server 2013. The Query works if I specify a string date i.e. '2020-01-01' .
Your help is appreciated.ARShttps://uk.mathworks.com/matlabcentral/profile/authors/3410489-arstag:uk.mathworks.com,2005:Question/4995532020-01-09T05:56:25Z2020-01-23T06:54:20ZHost computer Bluetooth connection to Mindstorm EV3 Error using legoev3 (line 196)
Failed to connect to EV3 through Bluetooth. Please check your Bluetooth connection.XIANGYU MENGhttps://uk.mathworks.com/matlabcentral/profile/authors/13170792-xiangyu-mengtag:uk.mathworks.com,2005:Question/451432012-08-02T14:32:39Z2020-01-23T06:51:14Zhow to connect universal bridge block to rotational electromechanical converter block?I try to model DC motor in simulink. But I cannot connect universal bridge block(Average-model based VSC) to DC motor I bulit which include resistor, inductor and Electromechanial converter blocks, however, that can be done in video showed at website (http://www.mathworks.co.uk/videos/speed-control-of-a-dc-motor-using-pwm-68962.html), how to deal with that?
Futhermore, what's the difference between physical variable and physical signal in simulink, why they cannot connect to each other and how to deal with that?
Thanks very much.Zhenghttps://uk.mathworks.com/matlabcentral/profile/authors/3087447-zhengtag:uk.mathworks.com,2005:Question/5013902020-01-22T06:55:06Z2020-01-23T06:50:38ZRed dotted line problem in simulink?HI everyone!
I'm using Matlab 2019a and I tried to link two blocks, but I couldn't and I get a red dotted line. I want to make connections between SPDT and current measurement block.
Does anyone have any idea why it is not possible to do that connection?
Thank youAbdul wahid khanhttps://uk.mathworks.com/matlabcentral/profile/authors/10224994-abdul-wahid-khantag:uk.mathworks.com,2005:Question/3192612017-01-06T07:14:41Z2020-01-23T06:49:54ZHow to connect Universal Bridge of simscape to system generator blockset ?|monospaced|SNEHA NIRMALEhttps://uk.mathworks.com/matlabcentral/profile/authors/9459635-sneha-nirmaletag:uk.mathworks.com,2005:Question/5010512020-01-20T09:29:10Z2020-01-23T06:46:31Zmove plot lines above annotationsHello,
I am using annotations to indicate the axes of my figure. However, they cover my plot lines. Is it possible to move the annotations to the bottom / the plot lines to the top?
Best regards,
PhilippPhilipp Rehlaenderhttps://uk.mathworks.com/matlabcentral/profile/authors/6717210-philipp-rehlaendertag:uk.mathworks.com,2005:Question/5004882020-01-15T19:41:39Z2020-01-23T06:45:42Zerror in returning widths over iterated findpeaksHi,
I am trying to use findpeaks over a matrix, x, column by column. I am using a for loop as below:
for k=1:size(x,2)
[P{k},locs{k},widths,proms{k}]=findpeaks(x(:,k))
end
Everything is working fine except for returning widths. P, locs and proms all return as cell arrays with all the data for the peaks in each column. However, widths only returns the widths of the peaks for the last column. When I try to edit it by making widths return as a cell array:
for k=1:size(x,2)
[P{k},locs{k},widths{k},proms{k}]=findpeaks(x(:,k))
end
I get the error message "Cell contents assignment to a non-cell array object"
Is there a way to get this function to return all the widths of all the peaks for each column?Teddy Fisherhttps://uk.mathworks.com/matlabcentral/profile/authors/17005716-teddy-fishertag:uk.mathworks.com,2005:Question/5015652020-01-23T06:03:33Z2020-01-23T06:43:38Zi want to sum each row of a matrix to the next row of the same matrix and save it in a new variable. its a part of big algorithm.let the matrix is this
A= [1 2 3 4; 5 6 7 8; 4 3 2 1];
and i want to get this
X=[1 2 3 4; 6 8 10 12; 10 11 12 13];
thanks in advance...Sheharyar Mrhttps://uk.mathworks.com/matlabcentral/profile/authors/15788175-sheharyar-mrtag:uk.mathworks.com,2005:Question/5015692020-01-23T06:37:50Z2020-01-23T06:37:50ZHow can I add acceleration variable to my driving scenario matlab code?I am writing matlab code of automatic braking system with the help of available driving scenario object functions, to the 'actors' in the driving scenario can we add acceleration along with velocity and position in the code? as I want the ego vehicle to decelerate when it meets the braking distance. please help.Bhavana Aletihttps://uk.mathworks.com/matlabcentral/profile/authors/13201677-bhavana-aletitag:uk.mathworks.com,2005:Question/5011762020-01-20T22:23:36Z2020-01-23T06:36:52Zintegration equvilants for diff() and dsolve()?
hold all;
clear all;
clc;
close all;
hold on
syms A(z) N beta B0 gamma
cond = A(0) == B0;
eqns = diff(A,z) == beta*(A/N)*(N-A)-gamma*A;
S(z) = dsolve(eqns,cond);
pretty(S);
i used this to diffrentiate and get and equation, is there away to do the same thing with integration?
ie the integral of beta*(A/N)*(N-A)-gamma*A
that could return somthing in teh same way that the pretty() function does?
N (beta - gamma)
----------------------------------------------------------------------
/ / / N beta - N gamma \ \ \
| | log| beta - ---------------- | | |
| | z \ B0 / | |
beta - exp| -N (beta - gamma) | - - ------------------------------ | |
\ \ N N beta - N gamma / /
jghttps://uk.mathworks.com/matlabcentral/profile/authors/12044418-jgtag:uk.mathworks.com,2005:Question/2756072016-03-27T00:11:04Z2020-01-23T06:32:33ZHow 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://uk.mathworks.com/matlabcentral/profile/authors/5494713-helen-kirbytag:uk.mathworks.com,2005:Question/5010772020-01-20T12:12:10Z2020-01-23T06:28:43ZEvaluating svd() on slice of matrix array.I have an array of matrices such that
size(A) == [3, 3, 1e3]
for example. These 1000 [3x3] matrices must be orthonormal so I am attempting to project each one to the nearest orthonormal basis, using svd() and the approximation
This function is made to work on a single [3x3] matrix at a time however. A workaround could be using for loops like
[~,~,np] = size(A);
for i=1:np
[U,~,V] = svd(A(:,:,i));
A(:,:,i) = U*V';
end
but this function will be called very often with high numbers of matrices so I am attempting to make efficient. Is there a better way to do this?Morten Nissovhttps://uk.mathworks.com/matlabcentral/profile/authors/8733171-morten-nissovtag:uk.mathworks.com,2005:Question/2683942016-02-16T12:57:58Z2020-01-23T06:28:22ZHow do you compare the two images using MATLAB programHow do you compare the two images using MATLAB program
I am on my project retrieve images and you write code comparison between images using correlation, but there is a problem in the code does not give me incorrect results for comparison
please help
count=0;
t=0;
x=imread('D:\Image Retrieval\2.bmp');
a=rgb2gray(x);
srcFiles = dir('D:\Image Retrieval\*.bmp'); % the folder in which ur images exists
for i = 1 : length(srcFiles)
filename = strcat('D:\Image Retrieval\',srcFiles(i).name);
k = imread(filename);
count=count+1;
b=rgb2gray(k);
c=corr2(a,b);
if c==1
imwrite(k,'C:\Users\saba\Desktop\images\image1.jpg');
t=t+1;
else
disp('tow image are not simalr');
end
endJasmine collarhttps://uk.mathworks.com/matlabcentral/profile/authors/7464091-jasmine-collartag:uk.mathworks.com,2005:Question/5015642020-01-23T05:57:53Z2020-01-23T06:25:51ZError "The data argument must contain one column for each output channel in the session " using MCC DAQ clear all
s = daq.createSession('mcc')
addAnalogOutputChannel(s,'Board0',0,'Voltage');
z2=[1,2,3,4];
for j=1:4
outputSingleScan(s,z2(j))
end
addAnalogOutputChannel(s,'Board0',1,'Voltage');
z1= [0.141687249833272,0.112007212486591,0.0689071567852794,0.416773440495905,0.0109475552680461,0.466457002843564,0.444121761055060,0.723244656108952,0.171769040517010,0.164394591328530,0.424612979523074,0.769109403398144,0.381813574443237,0.202014542626723,0.327277935663995,0.188914263851877,0.532415534740315,0.449082891619750,0.275924642830849,0.175224346760554,0.270964186619008,0.221080084377209,0.353425692035074,0.116251332792159,0.160479039015892,0.135096542653077,0.238824753756280,0.290191744253818,0.269644882382549,0.497863139879260,0.385337330317502,0.139775389758165,0.632266711819717,0.521620081343885,0.196525216757566,0.254789794829799,0.166977854895624,0.416406134037396,0.209698881660039,0.0366865178011585,0.202390070665126,0.519914923057829,0.426069368607590,0.418509068013190,0.171850913431126,0.212740767289584,0.0878979416788571,0.0578579992470066,0.385429791065513,0.0621551414125397,0.279525459621221,0.641419819855082,0.419649644659232,0.126585398970080,0.304130981893360,0.00848274039987393,0.121747922014143,0.317745942893927,0.103521603980625,0.395982715812410,0.399998094240577,0.0367275233090029,0.210032541273731,0.384875510422949,0.254273693378242,0.416529136270099,0.456120085929646,0.0995015277128458,0.537852499057717,0.182448574170951,0.216270525405994,0.0484753864429646,0.326365308863090,0.369894300120564,0.123539906677832,0.402093851048185,0.116341167403568,0.547697703520118,0.126951055229801,0.199254801696457,0.343137630234827,0.504825493894506,0.126819010245383,0.0991148211121164,0.0838894810170326,0.361212906712746,0.525555641605475,0.640047158779226,0.0404922053767597,0.321231827349959,0.498007665922180,0.0810188318570777,0.147893146042624,0.193479932056936,0.109577706578725,0.0946636462642120,0.300760830445821,0.365278742681428,0.0322404415463660,0.162976565415379,0.0392155113632359,0.0727230139137775,0.134751366753441,0.249182003774137,0.0916518138724496,0.0679287598766877,0.420518816818047,0.316544019388309,0.0983679249017900,0.332268611595562,0.471581105895014,0.942886982166009,0.0121947396951510,0.0521541249506307,0.684453823614449,0.635050793625075,0.306065980203823,0.137694905559089,0.112928395719835,0.0151617401918050,0.802824052616665,0.595622543739041,0.0892454342857938,0.191261461789688,0.0344637490679862,0.443589782446030];
for i=1:126
outputSingleScan(s,z1(j))
end
I get the followinf error "The data argument must contain one column for each output channel in the session ". Please help!A Rhttps://uk.mathworks.com/matlabcentral/profile/authors/12431130-a-rtag:uk.mathworks.com,2005:Question/4988602020-01-04T01:04:06Z2020-01-23T06:23:40ZPrespectrive transform for Lane detection projecthello , any ideas on how to get the transformation matrix for this projection :
my goal is to obtain this :
from this :
i have tried this :
im = imread('test1.jpg');
initial_points=[580,475; 740,475; 300,650; 1050,650]
final_points= [250,0 ; 1100,0; 0,720; 1200,720]
tform = fitgeotrans(final_points,initial_points,'projective');
out = imwarp(im,tform);
and allways get something like this :
with open.cv in python i can do it with :
#4-points on the initial iamge
initial_points=np.float32([(580,475),(740,475),(300,650),(1050,650)])
#same 4 points in the porjected image
final_points=np.float32([(250,0),(1100,0),(250,720),(1100,720)])
Transformation_Matrix = cv2.getPerspectiveTransform(initial_points, final_points)
warped = cv2.warpPerspective(image, Transformation_Matrix,(1280,720)) #equivalent to imwarp
and i get this :
Eduardo Lacerdahttps://uk.mathworks.com/matlabcentral/profile/authors/16679036-eduardo-lacerdatag:uk.mathworks.com,2005:Question/5009562020-01-19T11:55:08Z2020-01-23T06:23:00ZApp Designer: XY Zoom and XY Pan settingsHi everyone,
Is there a way to lock/choose the XY settings for the zoom and pan features when viewing a 3D surf plot in App Designer?
Using the zoom in the App Designer is giving me big holes in the middle of my surf plots that I don't know how to stop? Any help would be greatly appreciated!
Thanks in advance!
Cheersmackhinahttps://uk.mathworks.com/matlabcentral/profile/authors/10435791-mackhinatag:uk.mathworks.com,2005:Question/4826672019-09-29T02:49:21Z2020-01-23T06:13:13ZRead and Parse NMEA Data Directly From GPS Receiver-No exampleI am trying to utilize the NMEA converter in the above example however even after downloading the associated toolbox I am unable to access the example above and can not find the example within its desinated toolbox. Additionally when trying to run the code of my own accord the functions that are utilized within the code most importantly HelperParseGPSData() is not included within the toolboxes files. Can these be added to the toolbox, or can an example of the function be posted? Douglas Curciohttps://uk.mathworks.com/matlabcentral/profile/authors/12124130-douglas-curciotag:uk.mathworks.com,2005:Question/4987602020-01-03T04:05:03Z2020-01-23T06:11:01ZButterworth notch filter numerical errorsI recorded my ECG with ADS1298 and loaded it using matlab to do post-processing.
However, I found a strange pheonomenon.
I used 60 Hz notch filter to reduce 60 Hz noise, but the filtered signal was distorted as shown below figure.
I think the 60 Hz componet did not reduce in that point, what is the reason? and how can I solve it?
My matlab code and raw data was attached.
Thanks.
Wonok Kanghttps://uk.mathworks.com/matlabcentral/profile/authors/9736191-wonok-kang