https://fr.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2018-12-12T09:49:32Ztag:fr.mathworks.com,2005:Question/4350802018-12-11T03:19:26Z2018-12-12T09:49:32ZIs there any solution to generate an orthogonal matrix for several matrices?Hi All,
Is there any solution to generate an orthogonal matrix for several matrices in Matlab?
For example, I have
P'*A1*P = D1
P'*A2*P = D2
P'*A3*P = D3
P'*A4*P = D4
where:
D1 is a diagonal matrices with eigenvalues of A1 on the diagonal
D2 is a diagonal matrices with eigenvalues of A2 on the diagonal
D3 is a diagonal matrices with eigenvalues of A3 on the diagonal
D4 is a diagonal matrices with eigenvalues of A4 on the diagonal
A1 = [1 -1 0 0 0 0;
-1 2 -1 0 0 0;
0 -1 1 0 0 0;
0 0 0 0 0 0;
0 0 0 0 0 0;
0 0 0 0 0 0];
A2 = [0 0 0 0 0 0;
0 0 0 0 0 0;
0 0 1 -1 0 0;
0 0 -1 1 0 0;
0 0 0 0 0 0;
0 0 0 0 0 0];
A3 = [0 0 0 0 0 0;
0 0 0 0 0 0;
0 0 0 0 0 0;
0 0 0 1 -1 0;
0 0 0 -1 1 0;
0 0 0 0 0 0];
A4 = [0 0 0 0 0 0;
0 0 0 0 0 0;
0 0 0 0 0 0;
0 0 0 0 0 0;
0 0 0 0 1 -1;
0 0 0 0 -1 1];
How can I generate an orthogonal matrix P?
Thank YouImil Imranhttps://fr.mathworks.com/matlabcentral/profile/authors/7796464-imil-imrantag:fr.mathworks.com,2005:Question/4353152018-12-12T09:42:58Z2018-12-12T09:48:15ZInterception points (two) for complicate functionHow can I find interception points (two) for two functions, ex: y1=(30).*(((t./7).^(3))./(1+((t./7).^(3)))).*exp(-t./400); , y2 = 20.*t.^10;
I tryed :
Interception=find(abs(y1-y2)<=(eps), but sometimes it taking too much time , because I using this functions in ,,while'' (repeating hundred times).Marko Boskovichttps://fr.mathworks.com/matlabcentral/profile/authors/14054628-marko-boskovictag:fr.mathworks.com,2005:Question/1807382015-02-27T17:01:47Z2018-12-12T09:47:07Zerror LNK2005 on Accelerator Mode SimulationHello,
I created a simulink library containing an S-function named Simulink_2_C_link with 2 modules: Simulink_2_C_link.c and Simulink_2_C_link_wrapper.c
Then I used this S-function in a Simulink model called Avvolgimento02_senza_alim.
This model works fine in Normal Mode Simulation.
When I try to simulate it in Accelerator Mode I obtain a lot of errors like these:
Simulink_2_C_link.obj : error LNK2005: DYNAMIC_DIMENSION_DEF already defined in Avvolgimento02_senza_alim_acc.obj
Simulink_2_C_link.obj : error LNK2005: DYNAMIC_DIMENSION already defined in Avvolgimento02_senza_alim_acc.obj
Simulink_2_C_link.obj : error LNK2005: mexFunction already defined in Avvolgimento02_senza_alim_acc.obj
...
I think this is because "simulink.c" is included in both Simulink_2_C_link.c and Avvolgimento02_senza_alim_acc.c but these .c modules are created automatically from Simulink.
What can I do to resolve the problem?
Thank you in advance,
paolo_tollpaolo_tollhttps://fr.mathworks.com/matlabcentral/profile/authors/1971420-paolo_tolltag:fr.mathworks.com,2005:Question/4353162018-12-12T09:44:50Z2018-12-12T09:44:50ZHow to modifiy output of freeBoundary from input of STL?How to modifiy output of freeBoundary from input of STL? can any one share idea's?Selva Karnahttps://fr.mathworks.com/matlabcentral/profile/authors/4733665-selva-karnatag:fr.mathworks.com,2005:Question/4353132018-12-12T09:31:29Z2018-12-12T09:42:58ZI want to generate a square or rectangular array that should contain desired numbers in a circular fashion with some radius and all other numbers should be zero. Can anyone help me in thisI have an array of values, which is either square or circular in nature, which is as a function of x and y coordinates. I want to create a circular contour that contains a desired/input values, The contour should be like circule or elliptical, in that contour the desired values should be present. In all other places the number should be zero.linga veluchamyhttps://fr.mathworks.com/matlabcentral/profile/authors/3931530-linga-veluchamytag:fr.mathworks.com,2005:Question/4351422018-12-11T12:28:07Z2018-12-12T09:41:50ZHow can i plot files separately?Whenever I want to plot graphics (quiver, bode, rootl...) different files come together as seen in the picture. What can I do against it?Alp Yücesanhttps://fr.mathworks.com/matlabcentral/profile/authors/11038484-alp-yucesantag:fr.mathworks.com,2005:Question/4353142018-12-12T09:40:19Z2018-12-12T09:40:19ZHow to create a login interaface with a mask passwordHi, i'm doing a project for my university and i need to do an interface protected with a login and a recording page.
That interface must be composed by a edit text for the username, and a edit text for the pwd.
The issue is: how can i mask my pwd while i'm writing it, and how can i record new pwd and usernames witout touchin the .m file?Andrea Simonottihttps://fr.mathworks.com/matlabcentral/profile/authors/13733523-andrea-simonottitag:fr.mathworks.com,2005:Question/4348922018-12-10T10:41:58Z2018-12-12T09:40:14ZIssue with Simulink Model Simulation inside Parfor ?Hi,
I am trying to run multiple simulations with different data set on model 'ModelTest.slx' using parfor.
my code goes like this,
parfor
simout=sim(bdroot,<options>)
..
..
..
end
Parfor executes one simulation (sometime it runs two simulations). It geerates 'slprj' folder after first simulation.
Then it gets aborted with following error message.
"C:\Users\...\parllelTest\slprj\_jitprj\jitEngineAccessInfo.mat.
Not a binary MAT-file. Try LOAD -ASCII to read as text."
Below are the details of matlab version and model settings,
Matalb 2015b,
parpool with local profile.
Simulation Mode : Normal;
Solver :Fixed Step, discrete
Does anyone have any idea about this error. ?Shivaputra Narkehttps://fr.mathworks.com/matlabcentral/profile/authors/3327626-shivaputra-narketag:fr.mathworks.com,2005:Question/4338802018-12-05T02:29:42Z2018-12-12T09:32:26Zoutput of the text detection from command window to txt file?I want to know how to change the ouput from command window to show in the txt file? by using the example of Automatically Detect and Recognize Text in Natural Images. Aqip10https://fr.mathworks.com/matlabcentral/profile/authors/13601187-aqip10tag:fr.mathworks.com,2005:Question/4351372018-12-11T11:50:34Z2018-12-12T09:25:10ZWhat is the fastest way to add a row at the bottom of a table?Hi all,
In my program, I create an empty table with, lets say, 70 columns. Lets call it 'Collection_Table'.
During a tipical run the program has to add a one row table, 'Row_Table', to the bottom of 'Collection_Table'.
In a tipical run it happens few tens of thousend times (~20000 and more).
It turns that it takes A LOT OF TIME. I tryied the following methods:
1.
Collection_Table(end+1,:) = Row_Table;
2.
Collection_Table = [Collection_Table; Row_Table];
3.
I created a very large 'Cellection_Table' with zero, or empty, entires to eliminate the problem of enlarging the table during run.
Then, I used a counter 'Counter' to track the right entry to the table:
Counter = Counter + 1;
Collection_Talbe(Counter,:) = Row_Table;
In all three methods the time it takes to add 'Row_Table' data was long! Actually it is the major time consuming action in the program.
Is there a way to be more efficient? Am I missing something? Or I have to accept that working with the tables is time consuming?
Thanks,
Alon
Alon Rozenhttps://fr.mathworks.com/matlabcentral/profile/authors/3038003-alon-rozentag:fr.mathworks.com,2005:Question/4351432018-12-11T12:33:53Z2018-12-12T09:19:58ZHow to sum pixels from each sliding window in a picture?I have a picture and a sliding window on it. Sliding window is moving and ectracts the number of pixels relevant to setpoint rgb intervals. But I need the whole sum from the picture. How to calculate that ?Aneta Chwalahttps://fr.mathworks.com/matlabcentral/profile/authors/9573699-aneta-chwalatag:fr.mathworks.com,2005:Question/328522012-03-20T14:35:11Z2018-12-12T09:19:30ZShrink a 1-D array (vector) by removing all the columns with a value of zero SimpleArray = [1,0,2,0,3,0,4,0,5,0]
Desired result
NewSimpleArray = [1,2,3,4,5]Davidhttps://fr.mathworks.com/matlabcentral/profile/authors/1313512-davidtag:fr.mathworks.com,2005:Question/4353102018-12-12T09:10:33Z2018-12-12T09:18:06Zstoring values from a for loop into a new variable
for i = 1:length(row)
sol{i}
disp i
end
How can I store the values obtained (characters, not numbers) in a new variable?Nativehttps://fr.mathworks.com/matlabcentral/profile/authors/12921279-nativetag:fr.mathworks.com,2005:Question/4353112018-12-12T09:14:16Z2018-12-12T09:16:44ZRead the output line by lineHow to read the text line by line? i dont know where to put it. Now, it show rubbish output. this is the code.
[file,path]=uigetfile({'*.jpg;*.bmp;*.png;*.tif'},'Choose an image');
s=[path,file];
picture=imread(s);
[~,cc]=size(picture);
picture=imresize(picture,[300 500]);
if size(picture,3)==3
picture=rgb2gray(picture);
figure
imshow(picture)
title ('GRAY')
end
% se=strel('rectangle',[5,5]);
% a=imerode(picture,se);
% figure,imshow(a);
% b=imdilate(a,se);
threshold = graythresh(picture);
picture =~im2bw(picture,threshold);
picture = bwareaopen(picture,30);
imshow(picture)
title ('first')
if cc>2000
picture1=bwareaopen(picture,3500);
else
picture1=bwareaopen(picture,3000);
end
figure,imshow(picture1), title ('show')
picture2=picture-picture1;
figure,imshow(picture2), title ('thresh 1')
picture2=bwareaopen(picture2,200);
figure,imshow(picture2), title ('BoundingBOx')
[L,Ne]=bwlabel(picture2);
propied=regionprops(L,'BoundingBox');
hold on
pause(1)
for n=1:size(propied,1)
rectangle('Position',propied(n).BoundingBox,'EdgeColor','g','LineWidth',2)
end
hold off
figure
final_output=[];
t=[];
for n=1:Ne
[r,c] = find(L==n);
n1=picture(min(r):max(r),min(c):max(c));
n1=imresize(n1,[42,24]);
imshow(n1)
title ('alphabet found')
pause(0.2)
x=[ ];
totalLetters=size(imgfile,2);
for k=1:totalLetters
y=corr2(imgfile{1,k},n1);
x=[x y];
end
t=[t max(x)];
if max(x)>.45
z=find(x==max(x));
out=cell2mat(imgfile(2,z));
final_output=[final_output out];
end
end
file = fopen('TextDetect.txt', 'wt');
fprintf(file,'%s\n',final_output);
fclose(file);
winopen('TextDetect.txt')
my output are like this : and the 'DO' part cant be read.
TANHNAiyMsyoHEsuEcLMANPYR7EDEoAqip10https://fr.mathworks.com/matlabcentral/profile/authors/13601187-aqip10tag:fr.mathworks.com,2005:Question/4353122018-12-12T09:15:35Z2018-12-12T09:15:35ZDownload Matlab 2017b for windows 10Hi,
I've tried to download Matlab 2017b but for some reason has been downloaded as dvd (please see the figure). Inside this dvd drive there are two files. I don't know how to install Matlab from this point. Could you please help?
Marhttps://fr.mathworks.com/matlabcentral/profile/authors/4757715-martag:fr.mathworks.com,2005:Question/4352222018-12-11T19:55:42Z2018-12-12T09:13:53Zparallel pool won't initialize, 2017b on MacOS MojaveI am trying to initialize a parallel pool, which worked as of one month ago, but now will not work. The only thing that has changed since then has been an upgrade from High Sierra to Mojave.
>> mypool = parpool()
Starting parallel pool (parpool) using the 'local' profile ...
"/Applications/MATLAB_R2017b.app/toolbox/distcomp/bin/util/psname.sh" MACI64 93322: Aborted
"/Applications/MATLAB_R2017b.app/toolbox/distcomp/bin/util/psname.sh" MACI64 93322: Aborted
"/Applications/MATLAB_R2017b.app/toolbox/distcomp/bin/util/psname.sh" MACI64 93322: Aborted
Error using parpool (line 113)
Invalid default value for property 'ProcessInformation' in class 'parallel.cluster.Local':
The following error occurred while retrieving the name of process 93322: dyld: Library not
loaded: /usr/local/opt/gdbm/lib/libgdbm.4.dylib
Referenced from: /usr/local/bin/zsh
Reason: image not found
I'm not sure if it has something to do with Mojave, or what - but googling this error hasn't helped. Nothing else related to Matlab has been problematic in Mojave.Nicholas Angelideshttps://fr.mathworks.com/matlabcentral/profile/authors/6919031-nicholas-angelidestag:fr.mathworks.com,2005:Question/4348082018-12-09T23:59:20Z2018-12-12T09:13:44ZError using audioread function in MATLAB. It gives error while using .wav or .mp3. >> [y,Fs] = audioread('C:\Users\sat33\Documents\MATLAB\audio1.wav')
*** audioread: problem reading C:\Users\sat33\Documents\MATLAB\audio1.wav - returning empty waveform
y =
[]
Fs =
0Satwik Duttahttps://fr.mathworks.com/matlabcentral/profile/authors/13425375-satwik-duttatag:fr.mathworks.com,2005:Question/4351952018-12-11T16:46:03Z2018-12-12T09:12:31ZHow to concatenate structs with different fieldnames?I'm looking for a way to concatenate structures which have different fieldnames into one struct array of with similar fieldnames.
Below you will find a minimum working example:
% Convert this
Object(1).Stats.Var1 = 1;
Object(1).Stats.Var2 = 2;
Object(2).Stats.Var1 = 1;
% Towards this
Output = [struct('Var1', 1, 'Var2', 2);
struct('Var1', 1, 'Var2', [])];
% But this doesn't work
[Object.Stats]
This returns an error message "Number of fields in structure arrays being concatenated do not match. Concatenation of structure arrays requires that these arrays have the same set of fields."JBl147https://fr.mathworks.com/matlabcentral/profile/authors/13102114-jbl147tag:fr.mathworks.com,2005:Question/4352422018-12-11T22:47:50Z2018-12-12T09:10:50ZHow can I launch a script as an LSF job from the Matlab console?Is there a way to launch a matlab script as an LSF bjob on a specified cluster name with specific memory and CPU request settings from the matlab console? Is "batch" the command to do this? If so it seems I need to set up a cluster profile - I'm not sure how to do this or where to find the documentation for it.
Thank you,
BillBill Huffhttps://fr.mathworks.com/matlabcentral/profile/authors/14348859-bill-hufftag:fr.mathworks.com,2005:Question/3308592017-03-20T15:08:37Z2018-12-12T09:10:15ZHow to remove zeros from an array?I want to remove zeroes from an array. The array has exactly one zero per row. For example:
a = [1 4 0 3; 0 1 5 5; 1 0 8 1; 5 4 4 0; 0 1 5 2]
Should be turned into
a = [1 4 3; 1 5 5; 1 8 1; 5 4 4; 1 5 2]
I have tried using the command
a(a==0) = [];
However, this turns the 2000x50 array into an 1x98000 array instead of an 2000x49 array like I want it. Any ideas?Elvis Somershttps://fr.mathworks.com/matlabcentral/profile/authors/6889325-elvis-somerstag:fr.mathworks.com,2005:Question/4353092018-12-12T09:05:33Z2018-12-12T09:05:33ZCan Matlab web app server access the hardware of a server?Hi,
I would like to know if it is possible to access Hardware, for an example a COM port, from a matlab web app.
My idea would be to have web based data logging app, that can be accessed anywhere from within the local network.
Best regards
FelixFelix Ritzkowskyhttps://fr.mathworks.com/matlabcentral/profile/authors/4253806-felix-ritzkowskytag:fr.mathworks.com,2005:Question/4347592018-12-09T17:50:52Z2018-12-12T09:05:20ZHow to automatically run a matlab script on data in a seperate file on your computer?Hello,
I have data (.txt file) incoming on an sd-card inserted in my computer. At the moment I open the .txt file on excel and save it as a .xlsx file in my Matlab folder and write an xlsread() line at the top of my script. Is there any way to shorten this process or even make it happen fully automatically?
ThanksPeter De Wachterhttps://fr.mathworks.com/matlabcentral/profile/authors/9052952-peter-de-wachtertag:fr.mathworks.com,2005:Question/4298442018-11-14T14:35:08Z2018-12-12T09:03:38Zsort() is not working as mentioned in its doc !!!!!Hi
I want to use 'gpucoder.sort' feature newly included in 2018b. But I am getting below error:
I have GPU Coder, C/C++ compiler - Microsoft Visual C++ 2015 (C/C++), CUDA toolkit v9.1
I just tried the test mySort() function provided in gpucoder.sort webpage.
Can someone please guide me, what can be done to solve this.
Thank for considerationJAI PRAKASHhttps://fr.mathworks.com/matlabcentral/profile/authors/7172030-jai-prakashtag:fr.mathworks.com,2005:Question/4352962018-12-12T07:54:41Z2018-12-12T08:57:43ZWhy the numerical values for function handle from matlabFunction should be written one by one?Hi guys,
I am now using matlabFunction for change a symbolic expression into a funtion handle.
I find a question like this: if I write the numeric values one by one to replace the symbolic variables like this:
then the answer can be obtained as 3.
However, if I write
F2= f( aa )
then, in the command window, it shows like this:
Could anyone help me about this question?
Thanks so much!Tony Chenghttps://fr.mathworks.com/matlabcentral/profile/authors/9474183-tony-chengtag:fr.mathworks.com,2005:Question/4335332018-12-03T14:59:35Z2018-12-12T08:57:27ZParameter Estimation with MATLAB codeHallo,
I have written a function which calculates temperatur depending on input paramter. This Temperatur will be in vector form. Depending on input quantities, I will calcultes the temperatur.
function temp=fun_temp(param)
{
...................
}
end
I also have one another vector varible which is the actual temperatur vector for the same input. Now I want to estimate the parameter by comparing both the vector, one from above function and second from which I already have(actual).
%param = set of varible to be estimated
p = param.Continuous('x',2)
opts = sdo.OptimizeOptions('Method','lsqnonlin');
opts.MethodOptions.OptimalityTolerance = 1.5e-3;
opt_fun = @(p) fun_temp(p)
[param_opt,opt_info] = sdo.optimize(opt_fun,p,opts);
Actually this works with Paramter Estimation Toolbox of Simulink. I have Simulink model which calculates the Temperatur and by using this toolbox, i could find the optimal parameter. But Now I wanted to do same thing by NOT USING SIMULINK and just MATLAB to find the same paramter.
The above code throws a following error.
Error using sdo.optimize (line 115)
There are no design objectives to meet. The objective function argument of the optimize command must return a structure with at
least one objective to minimize or constraint to satisfy. See sdo.optimize for more information.
I dont know how this function works. Does any one know ?
Lukehttps://fr.mathworks.com/matlabcentral/profile/authors/8813759-luketag:fr.mathworks.com,2005:Question/4353022018-12-12T08:28:26Z2018-12-12T08:55:42ZProblem with solve functionHi if I use the solve function it doesnt work, like on my colleagues computer.
Here an example:
>> syms x
>> d=solve(x*5+15,x)
d =
-3
>> d=solve(x*5+15==0,x)
d =
x
somehow I get d=-3 when I let the ==0 out, but this makes no sense to me.
Even when I use the example from the help Page
syms x
eqn = sin(x) == 1;
solx = solve(eqn,x)
my result is solx=x
Has anyone an Idea, what I am doing wrong? Maybe some settings I need to change?
Thank you for your help
Dorian Jaggihttps://fr.mathworks.com/matlabcentral/profile/authors/13542294-dorian-jaggitag:fr.mathworks.com,2005:Question/4351162018-12-11T09:59:08Z2018-12-12T08:51:49ZDelete the string symbols on specific line with special symbol.Hi I have file fomated like that.
# 1996 3 4 9 58 11.0 20.2810 106.3000 20.8 2.7 0.0 0.0 0.5 1
PLV 12.20 1.00 Pg
PLV 21.00 0.75 Sg
HNV 16.20 1.00 Pg
HNV 28.40 0.75 Sg
# 1996 3 29 10 34 43.4 20.8820 107.2830 28.5 2.6 0.0 0.0 0.7 2
PLV 12.20 1.00 Pg
PLV 20.60 0.75 Sg
Now I need to remove the number on line have symbol "#" from
# 1996 3 4 9 58 11.0 20.2810 106.3000 20.8 2.7 0.0 0.0 0.5 1
to
# 1
Mean that all so thing after "#" to last number need to be remove (between # and number have 4 <space>). Final I need the file like that
# 1
PLV 12.20 1.00 Pg
PLV 21.00 0.75 Sg
HNV 16.20 1.00 Pg
HNV 28.40 0.75 Sg
# 2
PLV 12.20 1.00 Pg
PLV 20.60 0.75 Sg
Any one can help me! I try few way but it remove all or change the string only.Long Hà Vinhhttps://fr.mathworks.com/matlabcentral/profile/authors/6357385-long-ha-vinhtag:fr.mathworks.com,2005:Question/4353082018-12-12T08:47:40Z2018-12-12T08:49:12Zbasic 1 side echo cancellationhi, i need to do a mini project in echo cancellation
,well i'v biult one and my teacher said its to difficult, in my understanding he deman with bo doubletalkdetector,with no non linear proccesor..
he said a conversation like in skype, where the voice that comeout from the speaker bounce in to the microphone with the acual voice of the preson .
so ,to take it into equations...
i have the x(n)=the voice that wire to the speaker
y(n)=built from to 2 signals,1 the accual voice,the second is the voice that came out from the speaker (must be twisted voice (no??))
so i need to change x(n) to x(spectral twisted voice(n))
and then y(n)=x(spectral twisted voice(n))+p(n) where p(n) is accual voice of the preson thats sit and talkyuval ohayonhttps://fr.mathworks.com/matlabcentral/profile/authors/10651585-yuval-ohayontag:fr.mathworks.com,2005:Question/4351782018-12-11T14:56:31Z2018-12-12T08:46:17ZHi, Has anyone been able to implement ILC (using basis functions) in Matlab? Can someone please share the code of an example. Thank you very much.Hi, Has anyone been able to implement ILC (using basis functions) in Matlab? Can someone please share the code of an example. Thank you very much.Hekma Sekandarihttps://fr.mathworks.com/matlabcentral/profile/authors/4800210-hekma-sekandaritag:fr.mathworks.com,2005:Question/4353042018-12-12T08:33:47Z2018-12-12T08:37:30Zfft on an unit matrixHello i wanted to try a fft on an unit matrix, but the result of this is very strange.
A has the size 3x3
DFT = fft(eye(size(A)));
The result is:
Whats wrong here ?Alexander Loiblhttps://fr.mathworks.com/matlabcentral/profile/authors/12094523-alexander-loibltag:fr.mathworks.com,2005:Question/4352512018-12-12T00:03:56Z2018-12-12T08:36:00Zhow do i solve least squares problems with newtons method? I was wondering if it is possible to solve least squares problems using matlab for 100% of the way. What i mean:
I wrote this code for finding the variables of the polynomial f(x)=a*x+b that minimize the sum of (yi-f(xi))^2 for the given x,y.
x=linspace(-5, 5,100);
y = [zeros(1,50) + 0.2*rand(1,50), ones(1,50)-0.2*rand(1,50)];
sol=[1;1];
sumx=0;
sumy=0;
sumxsq=0;
sumysq=0;
sumxy=0;
for i=1:100
sumx=sumx+x(i);
sumy=sumy+y(i);
sumxsq=sumxsq+x(i).^2;
sumysq=sumysq+y(i).^2;
sumxy=sumxy+x(i).*y(i);
F=[sol(1)*sumxsq+sol(2)*sumx-sumxy; sol(1)*sumx+101*sol(2)-sumy];
J=[sumxsq,sumx;sumx,101];
sol=sol-J\F;
endfor
sol
As you can see, I calculated F and J for the Newton-Raphson method on paper using the theory of least squares. But there is a problem with that, as it requires you to solve a lot of things on paper and it changes for each starting f(x) that you want to fit. I tried doing the same thing for a starting f that is given by: s(z)=1/(1+exp(-z)), f(x)=s(a*x+b), and i had trouble with the complexity of the equation as i couldnt find F and J easily. So, is there anything i missed in this example and its actually easy to calculate, or can i use newtons method in another way to solve this problem without calculating anything on paper. Thanks in advance and sorry of the long post!apostolos georgantopouloshttps://fr.mathworks.com/matlabcentral/profile/authors/12697084-apostolos-georgantopoulostag:fr.mathworks.com,2005:Question/4353062018-12-12T08:34:15Z2018-12-12T08:34:15Zhow to control which license is usedI have a computer which has a SC license for Matlab and few toolboxed however the computer is connected to the network and the user also has an NNU license.
In this case, when Matlab is started on the computer, I noticed that in most cases the NNU license is taken. I would like to "control" this and "set" in such a way that this computer will always take the SC license installed.
How can I do this without disconnecting the computer from the network.
Thank you,
AlecsAlecsander Eitanhttps://fr.mathworks.com/matlabcentral/profile/authors/654715-alecsander-eitantag:fr.mathworks.com,2005:Question/4353052018-12-12T08:34:10Z2018-12-12T08:34:10Zi want to ask how to adjust image contrast,i want to adjust the image contrast, the problem is the when i used imread to read the image it appears as a black image although when i browse it using image viewer the image was good. i used imadjust command to adjust image contrast , but it become brighter in the middle , but at the edges the brigntness is lower, so i want a command to change the image brighness equally through out the image
in the first column of the attached image i am tracing powder inside pocket , so the problem is that the pixel values at the pocket boundries is lower than in the middle , so it is traced as black (no powder), i think that comes from imadjust commandkhalid Elserfyhttps://fr.mathworks.com/matlabcentral/profile/authors/11846776-khalid-elserfytag:fr.mathworks.com,2005:Question/4352792018-12-12T05:01:00Z2018-12-12T08:30:51Zhow can i convert the following script into function??I am having trouble in converting the following Script into function
fid = fopen('C:\Users\Windows\Downloads\INPUT_1.txt', 'r+');
data1 = zeros(4007,1);
data1 = fscanf(fid, '%f');
fclose(fid);
plot(data1);
b = [0.0305, 0.0305];
a = [1, -0.9391];
zi = 0.9695;
y = filter(b, a, data1, data1(1)*zi);
fid = fopen('C:\Users\Windows\Downloads\RESULT.txt', 'w+');
[m1, n1] = size(data1)
for i = 1:m1
fprintf(fid, '%f\r\n',data1(i,1));
end
fclose(fid);
Sanjeev Ramachandranhttps://fr.mathworks.com/matlabcentral/profile/authors/13244067-sanjeev-ramachandrantag:fr.mathworks.com,2005:Question/4353032018-12-12T08:29:15Z2018-12-12T08:29:15ZHow to Filter Data using three different kind of filters?Well, I want to filter a data base (only numbers in lineal way), using three different kind of filters, for example:
I have these data: 1, 2, 3, 4, 5........100.
My first filter should be filtrating 1-25%.
The second one, 85-100%.
And the last one (direct) should be filtrating any number I want, like 50-70%....
This is my work, but I still don't how to introduce the direct filter... any idea?
disp(' Filter frequencies')
disp('')
disp(' 1. High ')
disp(' 2. Low ')
disp(' 3. Direct')
disp('')
Filter= input('\nWich filter?:');
disp('')
Range1=input(' start number of the range: ');
Range2=input(' end number of the range:');
N=[];
N=(Range1:1:Range2);
Amount=Range2-Range1;
if Filter==1
disp(' 1. High ')
High=((Amount*85)/100)+1;
High=N(High:Amount+2);
disp(High)
elseif Filter==2
disp(' 1. Low')
Low=(Amount*25)/100;
Low=N(1:Baja);
disp(Low)
end
end
end
case 'b'
Filter= input('\nWich filter?:');
disp('')
Range1=input(' start number of the range: ');
Range2=input(' end number of the range:');
N=[];
N=(Range1:1:Range2);
Amount=Range2-Range1;
if Filter==1
disp(' 1. High ')
High=((Amount*85)/100)+1;
High=N(High:Amount+2);
disp(High)
elseif Filter==2
disp(' 1. Low')
Low=(Amount*25)/100;
Low=N(1:Low);
disp(Low)
end
end
Leslie Pedrazahttps://fr.mathworks.com/matlabcentral/profile/authors/14352099-leslie-pedrazatag:fr.mathworks.com,2005:Question/4350832018-12-11T03:29:50Z2018-12-12T08:25:24ZImplementing correct heat flux boundary conditionsHi! I'm having quite a bit of trouble implementing the following boundary condition (BC) into a PDEPE solver for temperature change with respect to time inside a bubble:
The PDE is: dT/dt = alpha*d2T/dr2 - vbubble*dT/dr
BC: q = h*(T - Tinf) - m*Hv
Where:
r = radius
alpha = coefficient (constant)
vbubble = coefficient (constant)
q = heat flux
h = local heat transfer coefficient (constant)
T = temperature in bubble (variable)
Tinf = ambient temperature around bubble (constant)
m = evaporation flux into bubble (we can assume it to be constant for now)
Hv = enthalpy of vaporisation of water (constant)
My problem really arises when I run the code, as T should equal Tinf at the edge of the bubble (where radius = r = 1), but for some reason I'm getting the opposite. The code is as follows:
m = 2; % specifies spherical symmetry for PDE solver
r = linspace(0,r,100);
t = linspace(0,t,100);
sol_temp = pdepe(m,@mainfunction_temp,@initialconds_temp,@boundaries_temp,r,t);
T = sol_temp(:,:,1);
function [a,f,s] = mainfunction_temp(r,t,T,DuDr)
a = 1;
f = 0.001;
s = -vbubble;
end
function T0 = initialconds_temp(t)
T0 = Tgas_in;
end
function [pl,ql,pr,qr,tt] = boundaries_temp(rl,Tl,rr,Tr,t)
pl = 0;
ql = 1;
pr = h.*(Tr(1) - T_column) - m(i).*Hv;
qr = 1;
end
Another problem is that T is present in pr, and I'm just not sure how to incorporate the variable that I'm trying to solve for into the boundary condition, unless it's just for the first step where T = Tgas_in. I've therefore replaced it with Tr(1) for now instead of just T (as inputting T says it's a cleared variable), but I think that might be the source of the problem when it comes to getting the correct BC. Any suggestions?Filip Butulahttps://fr.mathworks.com/matlabcentral/profile/authors/10883013-filip-butulatag:fr.mathworks.com,2005:Question/4262002018-10-26T05:07:37Z2018-12-12T08:20:09ZHow to resolve the error "Expected audioIn to be a column vector."Hi,
I am using the "Speech Command Recognition Using Deep Learning " to detect words from my own database. The length of each clip in my database is 4 seconds. I am using the default parameters for creating histograms only changing the segmentDuration to the duration in my clips. What wrong I might be doing here?
segmentDuration = 3;
frameDuration = 0.025;
hopDuration = 0.010;
numBands = 40;
The problem is whenever I am trying to run the code, its throwing an error
"Computing speech spectrograms...
Error using auditorySpectrogram
Expected audioIn to be a column vector.
Error in auditorySpectrogram>validateRequiredInputs (line 196)
validateattributes(x,{'single','double'},...
Error in auditorySpectrogram (line 66)
validateRequiredInputs(x,fs)
Error in speechSpectrograms (line 24)
spec = auditorySpectrogram(x,fs, ...
Error in Speech (line 30)
XTrain = speechSpectrograms(adsTrain,segmentDuration,frameDuration,hopDuration,numBands);"
What could be the possible reason and a solution for this. ThannksMohammed Faridul Haque Siddiquihttps://fr.mathworks.com/matlabcentral/profile/authors/7702407-mohammed-faridul-haque-siddiquitag:fr.mathworks.com,2005:Question/4353002018-12-12T08:13:30Z2018-12-12T08:19:34Zusing dsolve to equation equation is : d(x1)/dt (t) = -x1(t)*alpha+p
syms x1 t
tank1 = 'diff (x1,t)= - x1* alpha + p'
soln1 = dsolve(tank1,'x1(0) = 0')
it worked at somepoint then i cleared my workspace and then poof stopped. im guessing i had declared something in syms but dont remember ma
error getting
Error using mupadengine/feval (line 163)
Cannot identify differential equations. To solve
algebraic equations, use 'solve' or 'vpasolve'.
Error in dsolve>mupadDsolve (line 336)
T = feval(symengine,'symobj::dsolve',sys,x,options);
Error in dsolve (line 193)
sol = mupadDsolve(args, options);Brenda Galabehttps://fr.mathworks.com/matlabcentral/profile/authors/13307459-brenda-galabetag:fr.mathworks.com,2005:Question/4352992018-12-12T08:11:12Z2018-12-12T08:16:30ZObtaining Mode shape from k and m matrciesEveryone is asking about plotting mode shapes !!
What about obtataining mode shapes by only known k matrix, m matrix and lambda values???
Please ! Help!Yasser Almosabihttps://fr.mathworks.com/matlabcentral/profile/authors/14215901-yasser-almosabitag:fr.mathworks.com,2005:Question/4352982018-12-12T08:05:57Z2018-12-12T08:05:57ZRadar Signal Simulation: range-angle responseI'm going to get range-angle response of example in ACC.
I know that there's only single sensor in RX in this example, what I want to do is replacing single sensor to ULA.
Then the size of response I get should be like:4*512 (for example)
4 is number ULA elements and 512 is fast time samples.
I studied FMCW DSP before but I still don't know how to deal with so many system objects in Matlab.
I really need an example or a tutorial.
Thanks!
%% Radar Signal Simulation
% specanalyzer = dsp.SpectrumAnalyzer('SampleRate',fs,...
% 'PlotAsTwoSidedSpectrum',true,...
% 'Title','Spectrum for received and dechirped signal',...
% 'ShowLegend',true);
rng(2012);
for azimuth = 1:180
xr = complex(zeros(4,waveform.SampleRate*waveform.SweepTime));
% Update radar and target positions
[radar_pos,radar_vel] = radarmotion(waveform.SweepTime);
[tgt_pos,tgt_vel] = carmotion(waveform.SweepTime);
% Transmit FMCW waveform
sig = waveform();
txsig = transmitter(sig);
% Propagate the signal and reflect off the target
txsig = channel(txsig,radar_pos,tgt_pos,radar_vel,tgt_vel);
txsig = cartarget(txsig);
% Dechirp the received radar return
txsig = collectPlaneWave(sULA,sig,[azimuth;0],fc);
% txsig = receiver(txsig);
dechirpsig = dechirp(txsig,sig);
% Visualize the spectrum
% specanalyzer([txsig dechirpsig]);
xr(:,azimuth) = dechirpsig;
azimuth
endWei-Min Chenhttps://fr.mathworks.com/matlabcentral/profile/authors/12179330-wei-min-chentag:fr.mathworks.com,2005:Question/4344182018-12-07T12:51:21Z2018-12-12T08:05:18ZHow to fit data with a solution of a non linear differential equation containing multiple unknown coefficientHi everybody,
So it's been quite some time since I have used Matlab and now I have had a hard time figurint out how to proceed with my problem.
So I have measured some data and I would like to fit it with a certain function.
This latter function is found by solving numerically a non linear differential equation with 6 unknown coefficients.
What I want to do is by using a least-squares method (lsqcurvefit) I would vary the 6 unknown coefficients of the non linear ODE so that after the loop routine the solution to this equation fits my data.
And I'm stuck in thinking how to label all this. I understand the examples of the lsqcurvefit but it applies to a function. And I want to apply it to a equation so that the solution fits the data.
Here is the equation with the unknown coefficients a, b1, b2, c1, c2 and d. I aleady have a guess for all these values and a range in which they should lie within.
When I solve this equation numerically in matlab (with certain values), I can plot the function u(t). But what I want to plot and fit is actually .
So in summary: I want to write a routine loop varying my 6 coefficients in my non linear equation in order for the p(t) function to fit my data.
Any suggestion from you guys ?
Thanks a lot.
Best,
ThibautThibarelyhttps://fr.mathworks.com/matlabcentral/profile/authors/14320133-thibarelytag:fr.mathworks.com,2005:Question/4352972018-12-12T07:55:38Z2018-12-12T07:55:38ZI have some errors when I import the AUTOSAR arxmal file with MATLAB>> ar = arxml.importer('Pre-release_w49_xMA_18041_RMD_181208_AR-4.2.2_Unflattened_Swc.arxml')
createComponentAsModel(ar,'/ pkg / swc','ModelPeriodicRunnablesAs','AtomicSubsystem')
ar =
The file "C:\Program Files\MATLAB\R2018a\bin\Pre-release_w49_xMA_18041_RMD_181208_AR-4.2.2_Unflattened_Swc.arxml" contains:
警告: LowerLimit and UpperLimit need to be the same in literal Reserved for type /ApplicationDataTypes/IntrlMirrDispSysSts_1, which uses definition /CompuMethods/IntrlMirrDispSysSts_1 in file C:/Program
Files/MATLAB/R2018a/bin/Pre-release_w49_xMA_18041_RMD_181208_AR-4.2.2_Unflattened_Swc.arxml:1868.
2 Composition-Software-Component-Type:
'/ECUExtractRMD/ComponentType/TopLevelComposition'
'/SwComponentType/RMD'
0 Atomic-Software-Component-Type
Cannot find a valid AtomicSoftwareComponent "/ pkg / swc"yongzheng lvhttps://fr.mathworks.com/matlabcentral/profile/authors/13689593-yongzheng-lvtag:fr.mathworks.com,2005:Question/4187062018-09-12T16:52:02Z2018-12-12T07:54:03ZMatlab R2017b or R2018 compatible with Mojave (macOS 10.14)? Hi,
Did someone already try to use Matlab R2017 or R2018 on the new macOS Mojave (from beta version)?
Just to know if I can update safely to this OS when available soon.
Thanks in advance,
PierrePierre Chapuishttps://fr.mathworks.com/matlabcentral/profile/authors/6199375-pierre-chapuistag:fr.mathworks.com,2005:Question/4352952018-12-12T07:39:35Z2018-12-12T07:39:35ZInport Outports ranges in the generated codeHallo,
I'm trying to do the code generation for a model. I was wondering if there is a way to include the specified ranges in inports/outports in the code. At the moment, the only related option I've found is "Optimize using the specified minimum and maximum values", though what I need is a way to have some hard limits on the variables generated in the code.
Thanks for the help.
DavideDavide Freyhttps://fr.mathworks.com/matlabcentral/profile/authors/5098938-davide-freytag:fr.mathworks.com,2005:Question/4350762018-12-11T02:59:28Z2018-12-12T07:39:31ZReading multiple nc files in different subfolders within a directory Hi,
My data is stored in a folder withch contains subfolders cyc001, cyc002, cyc003...cyc258 each with 15 .nc files. I have written this code to explore the main data data directory and each cyc* subdirectories (total 258),read data from 15 nc files, retrieve certain fields in each .nc filesand store/save as output (passes). My code works well for one cyc001 folder but it failes to read the 2nd and subsequen folders.
currentdir= '/Users/Documents/test1';
cd(currentdir);
% For each cyc subdirectory
list_cycle= textscan(ls(),'%s');
cyclelist=list_cycle{1,1}(:,:)
j=1;
for c=1:length(cyclelist)
cd(cyclelist{c,1});%change into current cyc
list_dir= textscan(ls('-d','*.nc'),'%s');
dirlist=list_dir{1,1}(:,:)
%read nc files
myFolder=pwd;% folder of each cy
filePattern = fullfile(myFolder, '*.nc');
theFiles = dir(filePattern);
findFileInFolder(pwd,{'.nc'})
% Loop for each nc-file
for k = 1:length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
ncid=netcdf.open(fullFileName, 'NC_NOWRITE');
varname= netcdf.inqVar(ncid,4);
varid = netcdf.inqVarID(ncid,varname);
netcdf.close(ncid);
end
ncfiles = dir('*.nc'); % get all nc files in the folder
nfiles = length(ncfiles) ; % total number of files
end
% For each pass (.nc file)
for d=1:length(dirlist)
cd(dirlist{d,1});
data=read_nc(fullFileName); % Read the selected nc files using read_nc func
fprintf('Reading track: %d/%d of pass %d/%d. To read tracks: %d\n',d, length(dirlist),c,length(cyclelist),i);
ind=find((data.glat.Value<lat1)&(data.glat.Value>lat2)&(data.glon.Value<lon1|data.glon.Value>lon2));%find the indices
passe(j).lat= data.glat.Value(ind); % copy the fields in the data structure
passe(j).lon= data.glon.Value(ind); % copy the fields in the data structure
j=j+1;
clear data;
cd('..')
end
cd('..')
cd(currentdir)
It gives me eorror that
Error using cd
Cannot CD to cycle002 (Name is nonexistent or not a directory).
Ithink porblem is where I am trying to read nc files in each cyc... subfolder. Anyone, please help to fix this loop? I am not an expert matlab user so maybe I cam forgetting something and doing something wrong here.
skanwalhttps://fr.mathworks.com/matlabcentral/profile/authors/8706550-skanwaltag:fr.mathworks.com,2005:Question/4352942018-12-12T07:33:40Z2018-12-12T07:37:05ZHow can get the value for each time step for a variable inside of a function?I need to get the value of some variables (Defined as golobal variables in the attached file) for each time steps. These variables are calculated inside of the fucntion for each time steps. Based on my code I am geeting the value only for the last time step. How can i get the value for each time steps
I have attached the files (main file. function file)
Md Shamim Ahamedhttps://fr.mathworks.com/matlabcentral/profile/authors/6077641-md-shamim-ahamedtag:fr.mathworks.com,2005:Question/4352932018-12-12T07:31:37Z2018-12-12T07:31:37ZHow to remove TEXT from an ECG image?I have an ECG image as attached. Kindly help me to remove the TEXT regions{I, II, III, avR,aVL...V1 to V5 etc}. Only after removing these regions I an go further in my research study. Please help me to solve this. I use matlab 2012.Sam Roshhttps://fr.mathworks.com/matlabcentral/profile/authors/13309556-sam-roshtag:fr.mathworks.com,2005:Question/4322992018-11-27T15:10:49Z2018-12-12T07:27:25ZWhy importing ascii file and doing differentiation on it by GUI MATLAB shows this error 'Undefined operator '<=' for input arguments of type 'cell'.' ?Dears,
I come to my first Matlab code and I have no previous experience with Matlab so I need your help. I wrote the following code in order to load an ascii file of different rows and columns by push_callback in GUI Matlab. Before loading the file I entered value to define the column of interest and I loaded the desired 'tauD'. Afterwards, I need this code to do some differentiations, save the results, and finally to draw the ouput. But, I got the following message
'
' Undefined operator '<=' for input arguments of type 'cell'.
Error in PSD>pushbutton1_Callback (line 128)
I=imp(tauD(1,1)<=imp(:,1)&imp(:,1)<=tauD(end,1),col+1);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in PSD (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)PSD('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback''
So, could you please help me to fix this errors?
Your efforts and time are deeply appreciated in advance!
tauD_file='myOptions';
col=getappdata(0,'edit1');
load(tauD_file);
tauD=myOptions;
[fnames,fpath]=uigetfile({'*.dat;*.txt','ASCII Files';'*.*','All Files' },'Select data file','MultiSelect','on');
if ~iscell(fnames)
fnames={fnames};
end
for k=fnames
X1 = cell2mat(k)
imp=importdata([fpath,char(X1)]);
I=imp(tauD(1,1)<=imp(:,1)&imp(:,1)<=tauD(end,1),col+1);
[~,fname]=fileparts(char(X1));
dtau=gradient(tauD(:,1));
dtaudD=gradient(tauD(:,1),tauD(:,2));
dtaudlogD=gradient(tauD(:,1),log(tauD(:,2)));
dVdD=I.*dtaudD./dtau;
dVdlogD=I.*dtaudlogD./dtau;
result=[tauD(:,2),dVdD,dVdlogD];
save([fpath,'dVdD(C8)_cyl_0.193_6_',fname,'.dat'],'result','-ascii')
end
set(handles.pushbutton1,'String',filename);
a = get (handles.pushbutton1,'String',dVdlogD(:,1));
b= get (handles.pushbutton1,'String',dVdlogD(:,3));
axes(handles.axes1);
plot(eval(a), eval(b))
Ahmed Elsherifhttps://fr.mathworks.com/matlabcentral/profile/authors/13979717-ahmed-elsheriftag:fr.mathworks.com,2005:Question/4352922018-12-12T07:27:15Z2018-12-12T07:27:15Zmac Matlab 2018b with xcode10 installed still No supported compiler was foundWarning: Xcode is installed, but its license has not been accepted.
Run Xcode and accept its license agreement.
> In make (line 13)
Error: path_to_libsvm/libsvm-3.23/matlab/make.m failed (line 13)
No supported compiler was found. For options, visit https://www.mathworks.com/support/compilers.
I would like to compile some C codes with mex. However, even with matlab 2018b and xcode10 installed on my mac could not compile these files.
Yeah, I know the warning about Xcode license issue and that's strange since I DID aceept these license by typing
sudo xcodebuild -license
in command line and accepting it.
So anyone with same experience or some suggestions ? I would be very appreciated if you do ! 0.0xie linghttps://fr.mathworks.com/matlabcentral/profile/authors/9031393-xie-lingtag:fr.mathworks.com,2005:Question/4352622018-12-12T01:30:30Z2018-12-12T07:25:13ZQuestion for weboptions fieldHello, everyone.
I'm looking for the way to upload a file on my drobox using its API.
I found the function uploaded in file exchange as below:
https://kr.mathworks.com/matlabcentral/fileexchange/59673-upload-files-to-your-dropbox-folder-from-matlab
In his code, he use weboptions to use webwrite function.
But, the problem is... "HeaderFields" in weboption is available for matlab version post R2016b.
Prior to R2016b such as R2016a cannot control "HeaderFields" in weboption.
Is there any alternative way to upload a file on dropbox, here?
** Reference: https://kr.mathworks.com/matlabcentral/fileexchange/59673-upload-files-to-your-dropbox-folder-from-matlab
JongChunhttps://fr.mathworks.com/matlabcentral/profile/authors/4413194-jongchun