https://nl.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2018-12-10T12:59:08Ztag:nl.mathworks.com,2005:Question/4319502018-11-26T07:55:22Z2018-12-10T12:59:08ZHow to locate some specific files?Hello Everyone,
Can someone please help me,
I have 100 excel files, and each file is located on diffrent folder in the drive.
For eg.
file 1 = C:\DATA_DIR\TEST_1\2018_11_26.0001\Excel.xlsx
file 2 = C:\DATA_DIR\TEST_1\2018_11_26.0002\Excel.xlsx
file 3 = C:\DATA_DIR\TEST_1\2018_11_26.0003\Excel.xlsx
.
.
.
file 100 = C:\DATA_DIR\TEST_1\2018_11_26.0100\Excel.xlsx
In each excel file, the data is located at cell (1,1).
What I want to do, take the data from every excel file and save it in one single Excel file and the data should be saved in one single column.
The code I have, was good enough for small amout of data, but In this case and in future, I'll have bigger amount of data, and I'm looking for something, where I don't have to specify the each folder location to save my data in one single excel file.
I really appreciate you help.
Thank you.Ketan Sahuhttps://nl.mathworks.com/matlabcentral/profile/authors/14193184-ketan-sahutag:nl.mathworks.com,2005:Question/4349182018-12-10T12:20:12Z2018-12-10T12:57:48ZWeighted Classification Layer for Time Series/LSTMHi,
Recently came across WeightedClassificationLayer example for the custom Deep Learning layer templates. Pleased as this is exactly what I'm after for my current problem. custom layer
Unfortunately, the layer throws an error during backpropagation when I try to utilise with an LSTM. Is this because the layer works only with imageInputLayer problems? In my mind it ought to work the same except that dimensions 1-4 are used for images (width, height, channels, observations) and 2 additional dimensions are used for time series as I understand (featureDimension and SequenceLength).
Could anyone guide me on altering the tutorial such that it works for time series? Or does it work for anyone else? The error message isn't too descriptive, simply:
'Error using trainNetwork (line 150)
Error using 'backwardLoss' in layer weightedClassificationLayer. The function threw an error and could not be executedStuart Whipphttps://nl.mathworks.com/matlabcentral/profile/authors/11349362-stuart-whipptag:nl.mathworks.com,2005:Question/4343422018-12-07T01:46:05Z2018-12-10T12:57:24Zhow-do-i-estimate-or-optimize-the-parameters-of-my-ode-45 system of equations?I have three constitutive equations containing variables which need to be optimised..
How to give the equality constraints in optimisation solver ... (LSQNONLIN, FMINCON} for the following system of equations...
since I am having only three equations with initial conditions..
Finally I want to optimise the variables with experimental data with minimum least squares..
I have attached the function file and executable file using ODE45, equations and experimental data...
Please help me to sort out this problem... Help will be appreciated...ruban ramalingamhttps://nl.mathworks.com/matlabcentral/profile/authors/7917654-ruban-ramalingamtag:nl.mathworks.com,2005:Question/4349312018-12-10T12:57:06Z2018-12-10T12:57:06ZCan I use a IFFT HDL Optimized block with an input length greater than 2^16?I have an input data greater than 2^16 and i wanted to know if there's a way to use the block IFFT HDL Opltimized for it. Maybe putting more blocks in parallel, but will the result be the same?Daniele Massarihttps://nl.mathworks.com/matlabcentral/profile/authors/7859031-daniele-massaritag:nl.mathworks.com,2005:Question/4349142018-12-10T12:09:31Z2018-12-10T12:56:39ZI have to solve un overdetermined system with least squares method. I wrote in matlab 'A\b' and it gives me only one solution correct. Why? Or how can I solve the problem efficently? up-Xup*up-Xuu*u^2-Xvv*r^2-Xvr*v*r-v*r-Xrr*r^2 = 2*Xr+2*Xp
This is my equation. I have to find Xup, Xuu, Xvv, Xvr, Xrr. For solving this I have a folder .xlsx from where I import some values for coeff. of my unkowns.
In fact, this means I define my matrix (A and b).
To solve this I wrote A\b in matlab but the answer is not as I expected.
I must use least squares method.
Thaanks! Paul-Catalin Puscasuhttps://nl.mathworks.com/matlabcentral/profile/authors/14338260-paul-catalin-puscasutag:nl.mathworks.com,2005:Question/4348942018-12-10T10:51:22Z2018-12-10T12:55:59Zhow can i find the numbers and their indices which are same this is my data
1 3 4 36
3 2 2 5
5 5 6 8
3 4 1 23
3 12 6 34
1 5 3 1
11 17 12 9
17 19 26 26
16 1 1 27
18 10 18 15
i want to return those indices and their numbers which are repeating. for example row one has no repeating value so skip it.row 2, row 3 ,row 6, row 8 row 9 and 10 has the repeating numbers. so i want to obtain these numbers and their indices.
thanks in advanceFarman Shahhttps://nl.mathworks.com/matlabcentral/profile/authors/13190684-farman-shahtag:nl.mathworks.com,2005:Question/4348372018-12-10T05:15:41Z2018-12-10T12:55:09Zhow to read images in MATLAB when images are saved in one folder in the form of image(1),image(2)........image(2000).how to read images in MATLAB when images are saved in one folder in the form of image(1),image(2)........image(2000).Anuja Bhargavahttps://nl.mathworks.com/matlabcentral/profile/authors/3578000-anuja-bhargavatag:nl.mathworks.com,2005:Question/4348042018-12-09T23:04:39Z2018-12-10T12:54:56ZHow can I segment blobs in a image using the threshold filter I want to remove the spatter which I marked red in the following image using the threshold filter. Right now as you can see I used the default options of the binarize method
bw_left = imbinarize(v1_left);
To remove the spatter in the image I also tried to use the adaptive threshold filter which is included in the binarize method with a sensitivity from 0.7 till 1 with no luck. As you can see the image gets worse and looks very unstable (right image)
Iblur_left = imgaussfilt(left1, 2 ); % gaussian filter to remove noise in the image
%parameters vessel filtering
options.sigmas = '0.5:0.5:3'; % vector of scales on which the vesselness is computed
options.spacing ='[1;1.5]'; % input image spacing resolution - during hessian matrix
% computation, the gaussian filter kernel size in each dimension can
% be adjusted to account for different image spacing for different
% dimensions
options.tau = 0.5; % tau:(between 0.5 and 1)parameter that controls response uniformity
% -lower tau -> more intense output response
v1_left = vesselness2D(Iblur_left, options.sigmas,options.spacing, options.tau, true);
bw_left = imbinarize(v1_left, 'adaptive','sensitivity', 0.7);
figure;
imshowpair(v1_left, bw_left, 'montage');
Is there any way to remove those spatters in the image ?
Thank you for your helpLightisthenighthttps://nl.mathworks.com/matlabcentral/profile/authors/11559075-lightisthenighttag:nl.mathworks.com,2005:Question/2826882016-05-05T10:44:48Z2018-12-10T12:54:27Zwhy my excel file can not be read by matlab?I have simple excel file including date and rainfall in two columns.
the matlab can not read the file, either import data by xlsread command.
I made two format .xls and .xlsx. but matlab has an error.
just it can read .csv file.
matlab version is 2016a.
error message after command
Error using xlsread (line 251)
Error: The server threw an exception.
Miladhttps://nl.mathworks.com/matlabcentral/profile/authors/8000073-miladtag:nl.mathworks.com,2005:Question/4349282018-12-10T12:46:54Z2018-12-10T12:53:40ZError installing Support Package for ArduinoGood morning,
I'm trying to install the support package to Arduino , but in the end after click install it's appearing this message: "Download failed: received fatal alert: protocol_version".
The simmulink packages were correctly instaled, but Matlab support to Arduino Hardware not.
Can you help me?Pedro Skhttps://nl.mathworks.com/matlabcentral/profile/authors/14291229-pedro-sktag:nl.mathworks.com,2005:Question/4349272018-12-10T12:42:34Z2018-12-10T12:53:30ZAdd a number every n valuesHi all,
I have a question:
If I have an array
A=[ 1 2 3 4 5 3 0 2 8 3 2 1 0 3 2 0 0 1 1 0 3 1 5 3 2 8 1 0 3 2];
Is it possible to put the a value "a=800" after every 6 elements of A; (or after every 3 elements etc.)
So I get
b=[ 1 2 3 4 5 a 3 0 2 8 3 a 2 1 0 3 2 a 0 0 1 1 0 a 3 1 5 3 2 a 8 1 0 3 2 a];
thanks a lot!!
NikolasNikolas Spiliopouloshttps://nl.mathworks.com/matlabcentral/profile/authors/9122757-nikolas-spiliopoulostag:nl.mathworks.com,2005:Question/4349302018-12-10T12:53:19Z2018-12-10T12:53:19ZWarning: Solutions might be lost.why matlab is unable to solve two set of equations?clear all;clc;
d = 0.4;
omega_a = d^-4;
omega_b = (1-d)^-4;
omega_r = 12;
target_rate = 0.5;%bps/Hz
pI = (10)^0.5;%5dB
omega_e_a = 0;
omega_e_b =omega_e_a;
omega_hat_a = omega_a-omega_e_a;
omega_hat_b = omega_b-omega_e_b;
gama_th_HD = 2^(2*target_rate)-1;
%% number1
ma = 1;
mb = 1;
mr = 1;
Na = 1;
Nr = 2;
M = 1;
z=1;
p = db2pow(5)
[pa_HD pb_HD pr_HD] = opa1_HD(p,ma,Na,mb,M,omega_r,pI,mr,Nr,omega_e_a,omega_e_b,gama_th_HD,omega_hat_a,omega_hat_b);
%% function
function [sol_pa sol_pb pr] = opa1_HD(p,ma,Na,mb,M,omega_r,pI,mr,Nr,omega_e_a,omega_e_b,gama_th_HD,omega_hat_a,omega_hat_b)
syms pa pb
delta2 =( pb/((p-pa-pb)^2))+ omega_e_a;
delta1 = (p-2*pb)/((p-pa-pb)^2);
bt1 = 2*pb*omega_e_b + pa*omega_e_a + pb/(p-pa-pb);
sig1=0;
for f=0:(ma*Na)
sig = (1/(pa^(ma*Na)))*(((ma*gama_th_HD)^(ma*Na))/((gamma(mr*Nr+1))*((gamma(ma+1))^Na)))...
*(nchoosek(ma*Na,f))*(gamma(f+mr*Nr))*mr*Nr*(((pI*omega_r)/mr)^f)*(bt1^(ma*Na-f))...
*((ma*Na-f)*delta2/bt1-ma*Na/pa)-(1/((f+mr*Nr)*(pa^(ma*Na))))*...
(((ma*gama_th_HD)^(ma*Na))/((gamma(mr*Nr+1))*((gamma(ma+1))^Na)))...
*(nchoosek(ma*Na,f))*mr*Nr*((mr/(pI*omega_r))^(mr*Nr))*(bt1^(ma*Na-f))*...
(((pa-pb)/(p-pa-pb)-2*pb*omega_e_b)^(f+mr*Nr))*...
((f+mr*Nr)*delta1/((pa-pb)/(p-pa-pb)-2*pb*omega_e_b)+(ma*Na-f)*delta2/bt1-ma*Na/pa);
sig1= sig1+sig;
end
L1_HD_1 = ((1/omega_hat_a)^(ma*Na))*...
((((ma*gama_th_HD)^(ma*Na))/((gamma(mr*Nr+1))*((gamma(ma+1))^Na)))...
*((mr/(pI*omega_r))^(mr*Nr))*((omega_e_a+1/(p-pa-pb))^(ma*Na))*...
((((pa-pb)/(p-pa-pb))-(2*pb*omega_e_b))^(mr*Nr))*...
(mr*Nr*delta1/(((pa-pb)/(p-pa-pb))-(2*pb*omega_e_b)) + (ma*Na/((p-pa-pb)^2))/(omega_e_a+1/(p-pa-pb)))+sig1);
%%
delta4 =((p-pa)/((p-pa-pb)^2))+2*omega_e_b;
delta3 = ((2* pa-p)/((p-pa-pb)^2))-2*omega_e_b;
sigg1=0;
for f=0:(ma*Na)
sigg = (1/(pa^(ma*Na)))*(((ma*gama_th_HD)^(ma*Na))/((gamma(mr*Nr+1))*((gamma(ma+1))^Na)))...
*(nchoosek(ma*Na,f))*gamma(f+mr*Nr)*mr*Nr*(((pI*omega_r)/mr)^f)*(bt1^(ma*Na-f))*...
((ma*Na-f)*delta4/bt1-ma*Na/pa)-(1/((f+mr*Nr)*(pa^(ma*Na))))*...
(((ma*gama_th_HD)^(ma*Na))/((gamma(mr*Nr+1))*((gamma(ma+1))^Na)))...
*(nchoosek(ma*Na,f))*mr*Nr*((mr/(pI*omega_r))^(mr*Nr))*(bt1^(ma*Na-f))*...
(((pa-pb)/(p-pa-pb)-2*pb*omega_e_b)^(f+mr*Nr))*((f+mr*Nr)*delta3/((pa-pb)/(p-pa-pb)-2*pb*omega_e_b)+(ma*Na-f)*delta4/bt1-ma*Na/pa);
sigg1= sigg1+sigg;
end
L1_HD_2 = ((1/omega_hat_a)^(ma*Na))*((((ma*gama_th_HD)^(ma*Na))/((gamma(mr*Nr+1))*((gamma(ma+1))^Na)))*((mr./(pI*omega_r))^(mr*Nr))*((omega_e_a+1/(p-pa-pb))^(ma*Na))*((((pa-pb)/(p-pa-pb))-(2*pb*omega_e_b))^(mr*Nr))*(mr*Nr*delta3/(((pa-pb)/(p-pa-pb))-(2*pb*omega_e_b)) + (ma*Na/((p-pa-pb)^2))/(omega_e_a+1/(p-pa-pb)))+sigg1);
%%
delta6 =((p-pb)/((p-pa-pb)^2))+2*omega_e_a;
delta5 = ((2*pb-p)/((p-pa-pb)^2))-2*omega_e_a;
at1 = 2*pa*omega_e_a + pb*omega_e_b + pa/(p-pa-pb);
sig2=0;
for f=0:(mb*M)
sig_g = (1/(pb^(mb*M)))*(((mb*gama_th_HD)^(mb*M))/((gamma(mr*Nr+1))*((gamma(mb+1))^M)))...
*(nchoosek(mb*M,f))*gamma(f+mr*Nr)*mr*Nr*(((pI*omega_r)/mr)^f)*(at1^(mb*M-f))...
*((mb*M-f)*delta6/at1)-(1/((f+mr*Nr)*(pb^(mb*M))))*...
(((mb*gama_th_HD)^(mb*M))/((gamma(mr*Nr+1))*((gamma(mb+1))^M)))...
*(nchoosek(mb*M,f))*mr*Nr*(((pI*omega_r)/mr)^(mb*M))*(at1^(mb*M-f))...
*(((pb-pa)/(p-pa-pb)-2*pa*omega_e_a)^(f+mr*Nr))*((f+mr*Nr)*delta5/((pb-pa)/(p-pa-pb)-2*pa*omega_e_a)+(mb*M-f)*delta6/at1);
sig2= sig2+sig_g;
end
L2_HD_1 = ((1/omega_hat_b)^(mb*M))*((((mb*gama_th_HD)^(mb*M))/((gamma(mr*Nr+1))*((gamma(mb+1))^M)))*((mr./(pI*omega_r))^(mr*Nr))*((omega_e_a+1/(p-pa-pb))^(mb*M))*((((pb-pa)/(p-pa-pb))-(2*pa*omega_e_a))^(mr*Nr))*(mr*Nr*delta5/(((pb-pa)/(p-pa-pb))-(2*pa*omega_e_a)) + (mb*M/((p-pa-pb)^2))/(omega_e_b+1/(p-pa-pb)))+sig2);
%%
delta8 =(pa/((p-pa-pb)^2))+omega_e_b;
delta7 = ((p-2*pa)/((p-pa-pb)^2));
sig22=0;
for f=0:(mb*M)
sig_g2 = (1/(pb^(mb*M)))*(((mb*gama_th_HD)^(mb*M))/((gamma(mr*Nr+1))*((gamma(mb+1))^M)))*(nchoosek(mb*M,f))*gamma(f+mr*Nr)*mr*Nr*(((pI*omega_r)/mr)^f)*(at1^(mb*M-f))*((mb*M-f)*delta8/at1)-(1/((f+mr*Nr)*(pb^(mb*M))))*(((mb*gama_th_HD)^(mb*M))/((gamma(mr*Nr+1))*((gamma(mb+1))^M)))*(nchoosek(mb*M,f))*mr*Nr*(((pI*omega_r)/mr)^(mb*M))*(at1^(mb*M-f))*(((pb-pa)/(p-pa-pb)-2*pa*omega_e_a)^(f+mr*Nr))*((f+mr*Nr)*delta7/((pb-pa)/(p-pa-pb)-2*pa*omega_e_a)+(mb*M-f)*delta8/at1);
sig22= sig22+sig_g2;
end
L2_HD_2 = ((1/omega_hat_b)^(mb*M))*((((mb*gama_th_HD)^(mb*M))/((gamma(mr*Nr+1))*((gamma(mb+1))^M)))...
*((mr./(pI*omega_r))^(mr*Nr))*((omega_e_a+1/(p-pa-pb))^(mb*M))...
*((((pb-pa)/(p-pa-pb))-(2*pa*omega_e_a))^(mr*Nr))*...
(mr*Nr*delta7/(((pb-pa)/(p-pa-pb))-(2*pa*omega_e_a)) + (mb*M/((p-pa-pb)^2))/(omega_e_b+1/(p-pa-pb)))+sig22);
x = L1_HD_1 + L2_HD_1;
y = L1_HD_2 + L2_HD_2;
[sol_pa, sol_pb] = vpasolve([x ==0 , y == 0], [pa, pb],[p p]);% [y1,...,yN] = vpasolve(eqns,vars,init_guess)
pr = p - sol_pa - sol_pb;
end
what is wrong?beh mousavihttps://nl.mathworks.com/matlabcentral/profile/authors/10292604-beh-mousavitag:nl.mathworks.com,2005:Question/4349292018-12-10T12:50:22Z2018-12-10T12:52:29Zhow do i assign posterior probability to a class which is having same number of votes?i found the same number and thier indices as according to the following
https://www.mathworks.com/matlabcentral/answers/434894-how-can-i-find-the-numbers-and-their-indices-which-are-same?s_tid=prof_contriblnk
now my question is : If i get the cell value as {2,2,8,8} it means i have same number of votes for both classes. in this case i want to sum the posterior probabilty of both the classes (which i have calculated and saved) . For example the posterior probability of first element of the cell is 0.30 and the second is 0.45 (sum is equal to 0.75). now i check the posterior probabiltiy of second class i.e. class 8. for example i found that the posterior probabilty of class 8 fisrt element is 0.60 and the second is 0.30 (sum is equal to 0.90). as the posterior probability of 8,8 is greather then the 2,2 now i want {2,2,8,8} returns me only 8,8 . how to do this?
any help will be really appriciated
thanksFarman Shahhttps://nl.mathworks.com/matlabcentral/profile/authors/13190684-farman-shahtag:nl.mathworks.com,2005:Question/4107772018-07-17T17:00:15Z2018-12-10T12:50:13ZCan A Multicast Sender send to a tag which is dynamically determined from an attribute in the entity which it is sending?Can A Multicast Sender send to a tag which is dynamically determined from an attribute in the entity which it is sending?Elliott Rachlinhttps://nl.mathworks.com/matlabcentral/profile/authors/55024-elliott-rachlintag:nl.mathworks.com,2005:Question/3295942017-03-13T13:59:23Z2018-12-10T12:48:32ZPlease Help Basics Made HardHey guys, i am trying to solve this assignemnt. :
Write a function called day_diff that takes four scalar positive integer inputs, month1, day1, month2,
day2. These represents the birthdays of two children who were born in 2015. The function returns a
positive integer scalar that is equal to the difference between the ages of the two children in days. Make
sure to check that the input values are of the correct types and they represent valid dates. If they are
erroneous, return -1. An example call to the function would be
>> dd = day_diff(1,30,2,1);
which would make dd equal 2. You are not allowed to use the built-in function datenum or datetime.
Hint: store the number of days in the months of 2015 in a 12-element vector (e.g., 31, 28, 31, 30 …) and use
it in a simple formula.
I have figured the Hard part but i have problems how to make it accpent only whole possitve numbers and no matrixes as an input. Here is my code :
function [d] = day_diff( month1,day1,month2,day2 )
M=[31,28,31,30,31,30,31,31,30,31,30,31];
if month1==fix(month1)&&month1==fix(month1) && day1==fix(day1) && day2==fix(day2) && isscalar(month1)&&isscalar(day1)&&isscalar(month2)&&isscalar(day2) && day1>0 && day2 > 0 && month1 <=12 && month1 >= 1 && month2 <=12 && month2 >= 1 && M(month1) >= day1 && M(month2) >= day2
d1 = day1 + sum(M(1:1:month1-1));
d2 = day2 + sum(M(1:1:month2-1));
dd = d2-d1;
if dd <0
d = dd*(-1);
else
d = dd;
end
else d = -1;
end
end
Radoslav Gagovhttps://nl.mathworks.com/matlabcentral/profile/authors/9887255-radoslav-gagovtag:nl.mathworks.com,2005:Question/4323112018-11-27T16:09:08Z2018-12-10T12:45:31ZRemove image region inside another regionHello!
Does anyone have an idea of how can I remove some regions surrounded by another region? I would like to set the value of these pixels to 0. Both are already segmented and labelled.
This is an example imagesc:
Thank you very much in advanced!
Maria
MARIA RODRIGUEZ SANZhttps://nl.mathworks.com/matlabcentral/profile/authors/12988979-maria-rodriguez-sanztag:nl.mathworks.com,2005:Question/4347222018-12-09T12:25:13Z2018-12-10T12:44:39ZHow can I save permanently a change made in a GUI? Hi guys, I made an interface, and one of its functions is a register.
The GUI has a pop up menu where appears all the registered users, if the user isn't in the list, you can add another user by typing his name. Now in the pop up menu I am able to see the new user and save his data.
But, of course, when I close the figure and I reopen the interface, I loose the new user I have introduced in the list (his data is saved in a txt, so the only thing I loose is his name in the menu).
Is it possible saving permanently that change in the pop up menu?
How can I do it?
I've read something about to save the state in a mat file, but I don't really understand how it works. Could someone explain me it?
Many thanks! Pol Auladellhttps://nl.mathworks.com/matlabcentral/profile/authors/9757280-pol-auladelltag:nl.mathworks.com,2005:Question/4349262018-12-10T12:41:59Z2018-12-10T12:43:14ZHow to convert a cell array to string/char array???Hello guys!
I'm trying to read some data from excel with xlsread fun and to create an array which contains names of some variables. The type of the data is cell and I want to convert them to str array and after that to concatenate the names with another array.
What I use : Name = char(the array with names from excel) .'
What I get : I get some rows with latters..
The fun num2str may help here?????
Help!
Thank you!
John Rebbnerhttps://nl.mathworks.com/matlabcentral/profile/authors/13894292-john-rebbnertag:nl.mathworks.com,2005:Question/4347392018-12-09T14:37:26Z2018-12-10T12:40:58ZFinding the pseudo inverse of a matrixI'm trying to find the inverse of the following matrix
A =
-185.0685 185.0685 0
185.0685 -274.3238 89.2553
0 89.2553 -89.2553
Since A is a low-rank matrix , inv(A) doesn't work. So I tried the pseudo inverse, pinv(A) which takes the inverse of SVD of A.
However, A*pinv(A) isn't equal to identity. Are there alternative ways to find an inverse of A that will satisfy A*inverse(A) = Identity ?Deepa Maheshvarehttps://nl.mathworks.com/matlabcentral/profile/authors/8575091-deepa-maheshvaretag:nl.mathworks.com,2005:Question/4345932018-12-08T14:47:36Z2018-12-10T12:37:25ZImproving speed of for-loopHello,
I am trying to improve the speed of the following for loop in Matlab. As it is now is incredibly slow. Maybe vectorizing or execute in parallel?
The problem is that the solution of the componentwise matrixproduct A*B has to be saved in the matrix component k,l based on its rank in matrix RX & RY.
Thanks!
for j=1:n
for i=1:n
a=A(i,j);b=B(i,j);
k=RX(i,j);l=RY(i,j);
covXY(k,l)=covXY(k,l)+a*b;
EX(k)=EX(k)+a;
EY(l)=EY(l)+b;
end
endmeko94https://nl.mathworks.com/matlabcentral/profile/authors/11395888-meko94tag:nl.mathworks.com,2005:Question/4349252018-12-10T12:37:18Z2018-12-10T12:37:18ZHow to run SIL of a model including s-functions based on c++ codeI have a model using S-functions. The s-function is based on existing C++ code and the integration of this code into s-functions was done using legacy code. Until here everything works well. The problem is when i try to run the model as reference model in software in the Loop mode. In this case the compiler is not capable of finding the source code of the s-functions. It works when i copy the source code to the directory where i'm working at, but i don't want that. I need the compiler to find the source code in a specific directory struture, where the code is placed.
Regards,
RodrigoRodrigo Estrellahttps://nl.mathworks.com/matlabcentral/profile/authors/5957304-rodrigo-estrellatag:nl.mathworks.com,2005:Question/4348802018-12-10T09:52:16Z2018-12-10T12:36:53Znon linear equation "problem with not enough arguments"Im wriitng this to verify my non-linear equations..but having problem with this problem :
"nlinearval
Error using nlinearval (line 14)
Not enough input arguments.
function F=nlinearval(z)
Can anyone help me how i can solve this problem? Below are my coding:
function F=nlinearval(z)
%define constants
Isc=8.53;
Voc=44.9;
Vmp=36.1;
Imp=8.04;
Ns=72;
dv_di_oc=-0.48766;
di_dv_sc=-2.48797e-3;
q=1.6e-19;
k=1.381e-23;
T=298;
x = z(1);
y = z(2);
w= z(3);
Rsh = -1/(di_dv_sc);
b=exp(q*((Vmp+Imp*w)/(Ns*y*k*T)));
c=exp((Voc*q)/(Ns*y*k*T));
F(1)=[x-((Isc-(Voc/Rsh))/(c-1))-0];
F(2)=Imp-Isc+x*b+((Vm+Imp*w)/(Rsh));
F(3)=w+dv_di_oc+(1/((x*q)/((Ns*y*k*T)*c)));
end
nourihttps://nl.mathworks.com/matlabcentral/profile/authors/14337317-nouritag:nl.mathworks.com,2005:Question/4348502018-12-10T07:32:03Z2018-12-10T12:36:03ZHow to write a general equation and solving that using matrix method??T(m-1) - 2T(m) + T(m+1) + (delx*delx)*g/k =0 for m= 1 to 4
solving this i got the equations as
-2T(1) + T(2) = -16-50;
T(1)-2T(2) + T(3) = -16;
T(2)-2T(3) + T(4) = -16;
T(3)-2T(4) + T(5) = -16-4.44;
wanna solve this using matrix method.......
GURU PRASAATH Phttps://nl.mathworks.com/matlabcentral/profile/authors/14335987-guru-prasaath-ptag:nl.mathworks.com,2005:Question/4349242018-12-10T12:35:40Z2018-12-10T12:35:40ZHow to create all the possible Sub-Matrices from a large Matrix by shifting exactly one row and one column?
My input Matrix is that Scene Image Pixel Value.
I want to create that Sliding window 1 to Sliding Window n. All the Sliding Window Matrix Should be in the size of 5*5.Arijit Panigrahihttps://nl.mathworks.com/matlabcentral/profile/authors/12616626-arijit-panigrahitag:nl.mathworks.com,2005:Question/4349232018-12-10T12:35:19Z2018-12-10T12:35:19ZHow can I access AWS DynomoDB from MatlabIs there a way to access DynamoDB database immediately from Matlab? Georgios Pipelidishttps://nl.mathworks.com/matlabcentral/profile/authors/7905789-georgios-pipelidistag:nl.mathworks.com,2005:Question/4348662018-12-10T08:54:45Z2018-12-10T12:33:36ZCreate a Multiple graph with tha same pop up manuHi All
I need to create a GUi with a multiple graph controlled by the same pop up menu, for exsample if I select the option 1 from the pop up menu I will get in graph 1 a plot that coming as plot (A(:,5),A(:,6) and in the second graph plot(A(:,8),A(:,9));
where A is a matrix that I already have;
It shoul be easy but I can't still find a solution....ADChttps://nl.mathworks.com/matlabcentral/profile/authors/3876401-adctag:nl.mathworks.com,2005:Question/4349222018-12-10T12:31:58Z2018-12-10T12:31:58ZI worte a very small project on Mathcad, and I want to write it on MatlabHello,
I worte a very small project on Mathcad, and I want to write it on Matlab. you can see the pdf file that I made using Mathcad attached here. I appreciate your help. It does not have any complicated or any codes. It is just identifying parameters and write the given equation as a function of a parameter.
Thanks in advance.Mahmoud Elsayedhttps://nl.mathworks.com/matlabcentral/profile/authors/14338422-mahmoud-elsayedtag:nl.mathworks.com,2005:Question/4348702018-12-10T09:15:19Z2018-12-10T12:31:02ZCreate a for loop and save the values in different columnsI have problems creating a for loop in my matlab script. Have tried for a while but don't really get the solution I want.
I have three different locations and the coordinates for these can be found in coordlat and coordlon. I want to run my program for all the locations after eachother and then finally save the answers in a matrix, a new column for each location.
Here follows the code I have right now.
format long
ncfil00 = 'met_forecast_1_0km_nordic_20180601T00Z.nc';
ncfil01 = 'met_forecast_1_0km_nordic_20180601T01Z.nc';
lat=ncread(ncfil00,'latitude');
lon=ncread(ncfil00,'longitude');
temp00 = ncread(ncfil00,'air_temperature_2m');
temp01 = ncread(ncfil01,'air_temperature_2m');
coordlat=[63.2831 65.0942 68.4217];
coordlon=[12.1246 14.5085 18.1719];
for i=1:length(coordlat)
for j=1:length(coordlon)
distance = ( coordlat(i) - lat(:) ).^2 + ( coordlon(j) - lon(:) ).^2;
[~, index] = min(distance);
Temperaturejune2018(1,i) = temp00(index)-273.15;
Temperaturejune2018(2,i) = temp01(index)-273.15;
end
end
Sofie Peterssonhttps://nl.mathworks.com/matlabcentral/profile/authors/5773779-sofie-peterssontag:nl.mathworks.com,2005:Question/4349172018-12-10T12:17:14Z2018-12-10T12:30:48ZPlotting Data of a Matrix with multiple values on the X-Axis.Hello everyone.I have a matrix with 731 row & 31 column as you can see in attachment, and i wanna plot all the data in every column with one specific value on the x-axis.
in other word,all the data in first column with the value -30 on the x-axis, all the data in second column with the value -28 on the x-axis, all the data in third column with the value -26 on the x-axis, and so on till the last column, which is the column 31 with the value 30 on the x-axis.
thanks a lot.Reza Aminihttps://nl.mathworks.com/matlabcentral/profile/authors/13764037-reza-aminitag:nl.mathworks.com,2005:Question/4335132018-12-03T13:42:09Z2018-12-10T12:29:52ZVisualization of activation for LSTMLike deepDreamImage for CNN layers visualization, is there any approach to check/analyze activations of a LSTM layer into MATLAB ?
My workaround for now is to change my TS to image and then check activations, but it is not perfect.
Pierre Harouimihttps://nl.mathworks.com/matlabcentral/profile/authors/11149993-pierre-harouimitag:nl.mathworks.com,2005:Question/4344892018-12-07T18:07:32Z2018-12-10T12:29:18Zcalculating the average of every pixel in a 3D matrix in a 3x3x3 neighborhoodHi,
I have a 320x260x96 3D matrix and I need to create a new, same size 3Dmatrix, who's every pixel in it will be the average/mean value of its 3x3x3
surrounding cube neighborhood. Something like:
stdfilt(my_3D_image, ones(3,3,3))
only for caculating the average/mean -> instead of the std (above) will be great.
Anyone have an idea...?roy royhttps://nl.mathworks.com/matlabcentral/profile/authors/10106156-roy-roytag:nl.mathworks.com,2005:Question/3851452018-02-27T12:30:14Z2018-12-10T12:28:53ZEntity generation in SimEventsI want to generate 5 entities at the start of simulation and then single entity with fixed interval (idea of having initial inventory and then production at continuous rate) . I know how to generate multiple entities at the start of simulation but don't know how to continue generation of single entity with regular interval in rest of simulation time. can anyone guide me please as I'm a learner of SimEvents.summyia qamarhttps://nl.mathworks.com/matlabcentral/profile/authors/8556300-summyia-qamartag:nl.mathworks.com,2005:Question/4349212018-12-10T12:26:58Z2018-12-10T12:26:58Zhey i wanted to do a hough transform to detect circles in a picturei need help with coding hough transform and to detect a semi circles from a picture and marking it.
i have a code doing it on lines and i want to chage it into circles.
function [H, thetas, rhos, expected_average_H_for_uniform_edge_distribution] = Hough_lines(gradientImY, gradientImX, rhoSpacing, thetaSpacing)
assert(rhoSpacing>0);
assert(thetaSpacing>0);
assert(thetaSpacing<pi/2);
Y= size(gradientImY,1);
assert(Y==size(gradientImX,1));
X= size(gradientImY,2);
assert(X==size(gradientImX,2));
maxRho= norm([Y X],2);
assert(rhoSpacing<maxRho/2);
% The minimum is min_theta(-sin(theta) Y) which is -Y
minRho= -Y;
thetas= unique( [(-pi/2) :thetaSpacing:(pi/2) (pi/2)] );
thetas= thetas(1:end-1); % remove pi/2 to be in cyclic mode
rhos= unique( [(minRho):rhoSpacing :(maxRho) (maxRho)] );
H= zeros(length(thetas), length(rhos));
expected_average_H_for_uniform_edge_distribution= zeros(length(thetas), length(rhos));
for y=1:Y
for x=1:X
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% compute expected_average_H_for_uniform_edge_distribution over the
% current
% pixel
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for theta_i= 1:length(thetas)
theta= thetas(theta_i);
rho= x*cos(theta)+y*sin(theta);
[rho_lb_i, rho_ub_i] = find_lb_ub_in_sorted_arr(rho, rhos);
expected_average_H_for_uniform_edge_distribution(theta_i, rho_lb_i)= expected_average_H_for_uniform_edge_distribution(theta_i, rho_lb_i)+1;
expected_average_H_for_uniform_edge_distribution(theta_i, rho_ub_i)= expected_average_H_for_uniform_edge_distribution(theta_i, rho_ub_i)+1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (gradientImY(y,x)==0&&gradientImX(y,x)==0)
continue;
end
theta= atan(gradientImY(y,x)/gradientImX(y,x));
[theta_lb_i, theta_ub_i] = find_lb_ub_in_sorted_cyclic_arr(theta, thetas, pi/2);
rho= x*cos(theta)+y*sin(theta);
[rho_lb_i, rho_ub_i] = find_lb_ub_in_sorted_arr(rho, rhos);
grad_magnitude= norm([gradientImY(y,x) gradientImX(y,x)],2);
H(theta_lb_i, rho_lb_i)= H(theta_lb_i, rho_lb_i) + 0.25*grad_magnitude;
H(theta_lb_i, rho_ub_i)= H(theta_lb_i, rho_ub_i) + 0.25*grad_magnitude;
H(theta_ub_i, rho_lb_i)= H(theta_ub_i, rho_lb_i) + 0.25*grad_magnitude;
H(theta_ub_i, rho_ub_i)= H(theta_ub_i, rho_ub_i) + 0.25*grad_magnitude;
end
end
liad donaldhttps://nl.mathworks.com/matlabcentral/profile/authors/14338288-liad-donaldtag:nl.mathworks.com,2005:Question/1005642009-07-02T14:46:00Z2018-12-10T12:26:27ZCan I run my .NET executable on the deployment machine without using the package utility in MATLAB Builder for .NET 2.0 (R2006a)?I would like to have the ability to deploy my .NET application without using the package utility in the dotnettool or deploytool.
MathWorks Support Teamhttps://nl.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:nl.mathworks.com,2005:Question/4349202018-12-10T12:26:11Z2018-12-10T12:26:11ZSave file into columnsI have a program that calls a subroutine (function) inside this function has a loop, I need to save the data in .txt to open in excel, I can save the data, so that each loop is saved one below the other, but I can not save it in columns.
The first two columns are the same, what is different are the last two columns
function
for i = 1:9 vi = vi+(i+10-i); misv = (C1.*(1-exp(-C2.*si))-C3.*si).*exp(-C4.vi); misvc = (C1.(1-exp(-C2.*si))-C3.*si).*mi0.*exp(-C4.*vi);
TempA = [si; Fsi; misv; misvc];
FilenameA = strcat(Filename,' - Slip Function','.txt');
fid = fopen(FilenameA{1},'at+');
fprintf(fid, 'Slip Slip_Function Slip Slip_Function_Dry Slip_Function_Cont \n');
fprintf(fid,'------------------\n');
fprintf(fid,'%.3f %.3f %.3f %.3f\n',TempA);
fprintf(fid,'------------------\n');
fclose(fid);
File .txt
Slip Slip_Function Slip Slip_Function_Dry Slip_Function_Cont
------------------
0.000 0.000 0.000 0.000
0.010 0.224 0.208 0.187
0.020 0.399 0.370 0.333
0.030 0.536 0.497 0.448
0.040 0.643 0.597 0.537
...
Slip Slip_Function Slip Slip_Function_Dry Slip_Function_Cont
------------------
0.000 0.000 0.000 0.000
0.010 0.224 0.193 0.173
0.020 0.399 0.344 0.309
0.030 0.536 0.461 0.415
0.040 0.643 0.554 0.498
...
I need every file in a column, for example:
Slip Slip_Function Slip Slip_Function_Dry Slip_Function_Cont
------------------
0.000 0.000 0.000 0.000 0.000 0.000
0.010 0.224 0.208 0.187 0.193 0.173
0.020 0.399 0.370 0.333 0.344 0.309
0.030 0.536 0.497 0.448 0.461 0.415
0.040 0.643 0.597 0.537 0.554 0.498
ThanksJuliano Cardosohttps://nl.mathworks.com/matlabcentral/profile/authors/1876921-juliano-cardosotag:nl.mathworks.com,2005:Question/4345152018-12-07T23:07:15Z2018-12-10T12:24:25ZBest/fastest way to call MATLAB routine from C repeatedlyWe have a MATLAB routine/script that we wish to call from a C program.
What we have tried to do so far is to use the MATLAB compiler to create a DLL, and then in the C program, using the Windows SDK, we load the DLL (LoadLibrary), and then we run Init, run the DLL, and run Close (all through calls using GetProcAddress).
We have successfully done this with a simple "hello_world.m" function that doesn't do anything interesting. What we have found is that the process above is really slow -- ~15 seconds to load the DLL and ~10 seconds to run it.
Our desired "use case" is to use MATLAB to implement a routine that would get called numerous times by the C program, and so this slowness is a real concern.
My questions are:
Is this slowness similar to what others have experienced?
Is there a smarter way to go about this whole goal, maybe in how we compile the MATLAB code, or how we interact with it from C, that gives better performance?
We've looked for examples of what we're trying to do, and there aren't a lot of them and none go into this sort of level of detail. It is much more common to run compiled C code from MATLAB, and maybe there are good reasons why people don't usually do it the other way around?
David Aronsteinhttps://nl.mathworks.com/matlabcentral/profile/authors/12854886-david-aronsteintag:nl.mathworks.com,2005:Question/4349192018-12-10T12:22:55Z2018-12-10T12:22:55Zhow to implement tf idf vector and calculate the cosine distance between I have 6 documentum need to implement a tf idf from scrach and calculate distance in each pair
I done 6 vector which show the word fequence with histcount function but not sure how to compear to each other and calculate the distance in each pair of tf idf
Dezdihttps://nl.mathworks.com/matlabcentral/profile/authors/13777003-dezditag:nl.mathworks.com,2005:Question/4344282018-12-07T13:21:29Z2018-12-10T12:22:40ZHow to plot a 3D surface from a non square matrix?Hi, I am a newbee in matlab and have some difficulty to plot a surface from matrix. Here is the problem, I have a matrix () and a vector and a vector. I want to plot a surface from the matrix with the two vectors as X and Y axis, respectively. Bu it is impossible to directly use the function 'surf' since . Does anyone know what should I do to generate the plot? Thanks a lot in advance.Lin Yanghttps://nl.mathworks.com/matlabcentral/profile/authors/9170203-lin-yangtag:nl.mathworks.com,2005:Question/990672013-03-05T15:36:00Z2018-12-10T12:16:32ZWhy do I receive License Manager Error -9?When I try to launch MATLAB, I get the following error:
ERROR: License checkout failed. Invalid host. License Manager Error -9
MathWorks Support Teamhttps://nl.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:nl.mathworks.com,2005:Question/4349152018-12-10T12:12:32Z2018-12-10T12:14:34ZWhy i receive this warning : Warning: Variable 'needed' exists in base workspace or data dictionary but not in the model's source workspace. I want to run an optimization problem using GA, the optimization will be runned for multiple cases of study using For statement.
An objective function (myfitness) is written for the fitness functions and this function will run a Simulink model using a command line as follow
options=simset('SrcWorkspace','current''DstWorkspace','current');
sim('untitled2.slx',[],options)
The whole program is runned by a Main script in which another function 'function 2' is called to define some data and variables to be used in the fitness function (myfitness).
When the main script is runned, i got this warning and the simulation stops
' Warning: Variable 'needed' exists in base workspace or data dictionary but not in the model's source workspace. '
The variable 'needed' is obtained by calling the 'function 2' , i understand that Simulink don’t have the access to this variable , but i can see that this variable is on the workspace.
What is the solution please and what is the cause of the problem.
Bestdjedoui Nassimhttps://nl.mathworks.com/matlabcentral/profile/authors/3893584-djedoui-nassimtag:nl.mathworks.com,2005:Question/4349162018-12-10T12:13:51Z2018-12-10T12:13:51ZHow to sort files by nametitles containing mulitple numbersHello,
I want to sort files by names containing mutiple numbers e.g 03-01-01-01-01-01-01.wav
For quick testing, I am trying to sort 2 files c#6_6_1_2_100_483853850.txt and 'c#6_6_1_3_9_472319296.txt' with code
d=dir('PATH\c#*.txt');
d.name
f=@(x) cell2mat(textscan(char(x),['c#' repmat('%d_',1,5) '%9d'],'collectoutput',1));
dtvals=reshape(cell2mat(arrayfun(f,[d(:).name],'uniformoutput',false)),6,[]).'
My matlab output:
>> d.name
ans =
'c#6_6_1_2_100_483853850.txt'
ans =
'c#6_6_1_3_9_472319296.txt'
dtvals =
0×6 empty int32 matrix
I donot understand why dtvals is empty?
Would be great help to fix this quickly. Thanks in advanceSudha UNDEhttps://nl.mathworks.com/matlabcentral/profile/authors/14321041-sudha-undetag:nl.mathworks.com,2005:Question/4348892018-12-10T10:24:54Z2018-12-10T12:12:31Zcould we convert or detect matrix value to logical scalar value in matlab ? if it could, please tell me how. because, when i try to do that, i got "Operands to the || and && operators must be convertible to logical scalar values." ber=[];
for EbN0=0:1:50
if EbN0<=26 && ber<=0.001
smod_total=bpsk_mod(s);
else EbN0<=32 && ber<=0.001
smod_total=qpsk_mod(s);
end
end
[noe, berr]=biterr(s,det);
ber=[ber berr];
Naufal Alihttps://nl.mathworks.com/matlabcentral/profile/authors/14337482-naufal-alitag:nl.mathworks.com,2005:Question/4340862018-12-05T20:15:47Z2018-12-10T12:10:48ZHow can I print only the axes in gui to pdf?Hi, I made a GUI using GUIDE.
The figure has an axes and I want to print it only to pdf. How can I do it?
When I print it, whole figure is printed which means the pdf includes other buttons and edit texts and so on. Yumu Nomahttps://nl.mathworks.com/matlabcentral/profile/authors/13818240-yumu-nomatag:nl.mathworks.com,2005:Question/4349052018-12-10T11:29:47Z2018-12-10T12:09:30ZSum two values coming from eval Hi,
I would like to ask how to sum two numerical values, which coming from the eval fucntion
set(handles.A_edit,'string',eval(char(strcat('handles.forces.',gridnames(gridnum,1),'.total.B_IBE'))));
+
set(handles.A_edit,'string',eval(char(strcat('handles.forces.',gridnames(gridnum,1),'.total.C_IBE'))));Davide Di Pasqualehttps://nl.mathworks.com/matlabcentral/profile/authors/11592092-davide-di-pasqualetag:nl.mathworks.com,2005:Question/4345052018-12-07T21:24:26Z2018-12-10T12:07:17ZScript doesn't seem to be execute properlyI was hoping to acquire some help on how to make my program work efficiently and not take a substantial amount of time to finish:
clear variables
a=...;
p=nextprime(a);
count=0;
limit=200000;
tic
while isprime((p-1)/2)~=1
a=a+1;
p=nextprime(a);
count=count + 1;
if count>limit
break
end
end
toc
This program outputs a number p greater than a such that p is prime and (p-1)/2 is prime. However I've noticed that for any number a greater than approximately 15 digits, the program will take an absurd amount of time to finish, which isn't ideal since I need to test numbers of the order 10^50.Manuel Barroshttps://nl.mathworks.com/matlabcentral/profile/authors/13743191-manuel-barrostag:nl.mathworks.com,2005:Question/4058922018-06-15T20:16:58Z2018-12-10T12:07:07ZStochastic SimEvents simulation for serversHi All. I am interested in running a SimEvents simulation with some stochastic inputs, for instance, having different server times in the server block. How can this be implemented? Are there some examples somewhere that I can look at?Etiennehttps://nl.mathworks.com/matlabcentral/profile/authors/1404326-etiennetag:nl.mathworks.com,2005:Question/4349132018-12-10T12:06:09Z2018-12-10T12:06:09Zhow to plot real time Data from iOS sensors in MATLAB?how to plot real time Data from iOS sensors in MATLAB?
Jae Hyung Parkhttps://nl.mathworks.com/matlabcentral/profile/authors/9918961-jae-hyung-parktag:nl.mathworks.com,2005:Question/4349122018-12-10T12:04:42Z2018-12-10T12:04:42ZColormap of histogram affected by contour plot on same axesI am making a histogram2 (tile view) of one dataset, which is time samples of two variables. On the same axes I plot a contour of a map which comes from different data (essentially a target map for the time based data which is in the histogram).
The unusual behaviour is that the colour scale of the hist2 appears to be affected by having the contour on the same axes.
If it is noteworthy, I am plotting the contour first, with a solid colour for all contour lines (not using colormap). Then I plot the histogram second.
If anyone knows how to resolve this, I would be most grateful.
Many thanksAndrea Ackroydhttps://nl.mathworks.com/matlabcentral/profile/authors/13764287-andrea-ackroydtag:nl.mathworks.com,2005:Question/4349112018-12-10T12:02:41Z2018-12-10T12:02:41Zhow to find similarity of two patches?In Non Local Total Variation, a fixed patch is exploited to search the non-local similar patches for each pixel. Suppose the patch size is p*p, P(x) represents the vector form of the target patch centered at the location x, we find for the similar patch P(y) in a w*w search window around x.Kavitha Khttps://nl.mathworks.com/matlabcentral/profile/authors/13445950-kavitha-ktag:nl.mathworks.com,2005:Question/4349092018-12-10T12:01:48Z2018-12-10T12:02:34ZDistance between the BS and the UT in example "3GPP 5G NR PDSCH Throughput Simulation"Where is the distance between the Base Station (BS) and the User Terminal (UT) in the example "3GPP 5G NR PDSCH Throughput Simulation" of the library "5G Library for LTE System Toolbox EXAMPLES"?
I can't find in any part of the code of the example.Henrique Buenohttps://nl.mathworks.com/matlabcentral/profile/authors/14203557-henrique-bueno