https://www.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2019-07-22T10:51:07Ztag:www.mathworks.com,2005:Question/4728092019-07-22T10:51:07Z2019-07-22T10:51:07Zbounding box contained object as new imageI have written a code that will detect the RBC's (red blood cells), in a blood smear image. i have successfully put bounding boxes aroun them as well as names. i want each of these bounding boxes along with the object inside to get saved as a different images. for example, if there are about 200 Rbc's, the code i have written is detecting and putting a bounding box around all the 200, but now i want all those 200 bounding boxes and its objects in separate images, that is 1 rbc along with its bounding box in one image, another rbc along with its bounding box in a different image, likewise if there are 200 rbcs in an image, i want 200 images each containing one RBC and its bounding box
the code as well as the image is guve below. please do help me
clc;
close all;
clear all;
sum=0;
% for l = 10:145
l=58;
jpgFilename = strcat('t_images_', num2str(l), '.jpg');
rbc=imread(jpgFilename);
% hdinterlacer = vision.Deinterlacer;
% clearimage = hdinterlacer(rbc);
b = imsharpen(rbc,'Radius',30,'Amount',5);
figure(1);
imshow(b);
%%
%%rgb to grayscale conversion
BW1=rgb2gray(b);
%%
%%erosion and dilation
BW=imbinarize(BW1);
figure(2);
imshow(BW);
A1=strel('diamond',2);
A2=imerode(BW,A1);
figure(3);
imshow(A2);
A3=imdilate(A2,A1);
A4=imdilate(A3,A1);
figure(4);
imshow(A4);
A7=strel('diamond',1);
A5=imerode(A3,A7);
Z1=edge(A4,'sobel');
figure(4);
imshow(Z1);
%%
Imask = immultiply(b,repmat(BW,[1 1 3]));
Imask = reshape(Imask,[],3);
idx = any(Imask == 0,2);
bgColor = mean(Imask(~idx,:));
s = regionprops('table',BW,{'Area','PixelIdxList'});
I2 = reshape(b,[],3);
s.AvgRGB = zeros(height(s),1);
for kk = 1:height(s)
regColor = mean(I2(s.PixelIdxList{kk},:));
s.AvgRGB(kk,:) = norm(regColor - bgColor);
end
for kk = 1:height(s)
if s.AvgRGB(kk) <= 10 || s.Area(kk) < 200
BW(s.PixelIdxList{kk}) = false;
end
end
%counting the number of RBC's
D = bwdist(~A4);
D = -D;
D = imgaussfilt(D, 10);
L = watershed(D);
L(~Z1) = 0;
BW2 = L > 10;
% Visualize the result
CC = bwconncomp(rbc);
L = labelmatrix(CC);
% RGB = label2rgb(L);
figure
imshow(A3)
s = regionprops('table',A3);
hold on
for kk = 1:height(s)
rectangle(...
'Position', s.BoundingBox(kk,:),...
'EdgeColor', 'b')
text(s.BoundingBox(kk,1),s.BoundingBox(kk,2)-25,...
num2str(kk),...
'FontSize', 6)
end
Ragini Narasimhahttps://www.mathworks.com/matlabcentral/profile/authors/13959813-ragini-narasimhatag:www.mathworks.com,2005:Question/4728062019-07-22T10:40:48Z2019-07-22T10:50:56ZHow to create a .mat fileHello,
I've been searching for clues in order to solve my problem but couldn't find anything and since I just start with Matlab, I'm a bit lost.
Here's the thing :
I need to create a .mat file which would contain the following arrays :
lattitude (1-10980)
longitude (ID)
time (43 dates)
the data (10980,10980,43)
The data are Sentinel 2 images (.tif) that I would like to stack in order to conduct Time Series analyses.
The script I've been provided with is EOF, and the data they use in their example are organised as previously (only, with less data).
Since I'm not familiar with .mat files, I think I only understood that they are organised like .nc or .hdf files (might not be though).
Anyway, even if they are, I clearly can't tell how to end up with my arrays organised like that.
Could somebody help ?
Thank you.Thomashttps://www.mathworks.com/matlabcentral/profile/authors/15842641-thomastag:www.mathworks.com,2005:Question/4728002019-07-22T10:15:24Z2019-07-22T10:50:29Zhow to solve this error? in matlabnet.layers{1} = struct(...
'name', 'conv1', ...
'type', 'conv', ...
'weights', {{randn(10,10,3,2,'single'), randn(2,1,'single')}}, ...
'pad', 0, ...
'stride', 1) ;
net.layers{2} = struct(...
'name', 'relu1', ...
'type', 'relu') ;Fawad Ahmadhttps://www.mathworks.com/matlabcentral/profile/authors/14603339-fawad-ahmadtag:www.mathworks.com,2005:Question/652922013-02-28T05:12:38Z2019-07-22T10:46:54ZHow to calculate Inverted T wave for ECGI detected P,Q,R,S,T peaks for ECG wave from MIT-BIH Arrhythmia Database
and intervals such as
s_t_interval
r_r_interval
t_t_interval
p_r_interval
q_t_interval
now i want to calculate inverted T and inverted P. please assist
nkumarhttps://www.mathworks.com/matlabcentral/profile/authors/3941207-nkumartag:www.mathworks.com,2005:Question/4727862019-07-22T09:12:57Z2019-07-22T10:45:40Zhow to use a file from a different directory?Hello,
i have developed a program and it works correctly ,and now i want to make it as a function so i need as input a directory(directoryname) and inside the function i want to get the file c.ini wich is in the directoryname
function B(directoryname) % the function B is why i am trying to program now
N = inifile(directoryname\c.ini,90) %infile is a one of my function wich needs as input the file c.ini
Thank you
rachida elamranihttps://www.mathworks.com/matlabcentral/profile/authors/15363306-rachida-elamranitag:www.mathworks.com,2005:Question/4728082019-07-22T10:45:29Z2019-07-22T10:45:29ZTransforming HH:mm:SS to 'dd.MM.yy HH:mm:SS' and loosing seconds>> time = datestr(seconds(duration),'HH:MM:SS')
time =
'02:59:57'
>> date_and_time = datetime(time, 'ConvertFrom', 'datenum', 'Format', 'dd.MM.yy HH:mm:SS')
date_and_time =
datetime
22.07.19 02:59:00
I would like to add current date to the 'time'. Why do I loose the 57 seconds when I do this transformation, and how to do it correctly?
Many thanks!Butterflyfishhttps://www.mathworks.com/matlabcentral/profile/authors/2964718-butterflyfishtag:www.mathworks.com,2005:Question/4728052019-07-22T10:30:23Z2019-07-22T10:45:00ZHow do I make a new folder using the name of a specific variable. I have named a vairable s2 which stores the string '3 min RT' and I want to create a folder names "3 min RT" to save the figures the script has created. Anyhelp please? Thanks! The import code is below.
% which files to be imported
s1 = '\';
s2 = '3min RT'; % edit this line to name of file
s3 = '.cpr';
s = strcat(s1,s2,s3);
s5 = 'Schems\';
fname = [pname s];Nicholas Byreshttps://www.mathworks.com/matlabcentral/profile/authors/15803220-nicholas-byrestag:www.mathworks.com,2005:Question/4724132019-07-18T20:14:19Z2019-07-22T10:44:32ZFminsearchbnd vs. Pattern Search vs. Surrogate Optimzation to attempt to find the global optimal solution.Hello,
I'm trying to decide on what type of solver I should use for my problem and I'm at a bit of an impasse.
To give an overview of my problem, I'm attempting to optimze for the best choice of parameters (between 3-4) of an ODE having a nonsmooth cost function (calculated by first solving the ODE). Moreover, the objective function has many local minima (some close to each other) and my goal is to try and find the parameters which minimze the objective function best. The only constraints on the problem are lower and upper bounds on the parameters.
Now, the 3 solvers I'm considering are fminsearchbnd, patternsearch, and surrogateopt. For fminsearchbnd, I know it can find local minimums, but can also get stuck, depending on where the initial guess is. From my understanding, a similar situation can arise from using patternsearch, and so if I where to sample the parameter space by randomly choosing 20 starting points, this may lead to the "best" solution using either fminsearchbnd or patternsearch. As for surrogateopt, it seems like this may be the best choice since it is made to handle costly nonsmooth objective functions and find a global minimum, if given enough time. I also think that based on the setup of my problem surrogate optimzation will probably take the least amount of time, but I'm unsure of if this is the case.
My question is, will fminsearchbnd (with 20 random initial points) give similar results (that is similarly sized cost function) as compared to using patternsearch or surrogate optimization? Or will I have to choose many more initial guesses (which can get computationally costly) to acheive similar results?
Thanks for any help!Shant Danielianhttps://www.mathworks.com/matlabcentral/profile/authors/7422401-shant-danieliantag:www.mathworks.com,2005:Question/4728072019-07-22T10:41:22Z2019-07-22T10:41:22ZHow to detect human in an image using Matlab?Hi,
I would like to detect whether there is any human in an image using Matlab.
For instance, this image has a human.
Could I have any advice or suggestions?
Salad Boxhttps://www.mathworks.com/matlabcentral/profile/authors/11434690-salad-boxtag:www.mathworks.com,2005:Question/4718202019-07-15T19:12:39Z2019-07-22T10:35:11ZI have discovered that in solving ordinary differential equations things can get very easy if we use micro-intervals (intervals divided by 10 000 or more) and very rough methods like Euler's , to get the same accuracy as when using complex methods. ODEs of any order with initial conditions can be solved easely "using micro-intervals (intervals divide by more than a 1000) associated with Euler's method - definition of derivative -, can lead to great accuracy. I have a batch of scripts that can prove that. (study1, study2 ......). The simplicity is the great asset. Is this known ?Carlos Steinstrasserhttps://www.mathworks.com/matlabcentral/profile/authors/1967874-carlos-steinstrassertag:www.mathworks.com,2005:Question/4727652019-07-22T07:38:43Z2019-07-22T10:34:10ZSampling with detector and rise time effect. also freq changeHello,
I'm trying to understand how to simulate sampling with detector which has rise time 25psec.
(up to 15GHz sampling rate)
My signal is a pulse which has periodic change in center freq - let's say dni.
The detector is connected to the scope. My final goal is to simulate what the scope will measure with diffrent bandwidth. (to understand what scope we should get)
Would appriciate your help.
Thanks.
Eli_Coghttps://www.mathworks.com/matlabcentral/profile/authors/15006865-eli_cogtag:www.mathworks.com,2005:Question/4728012019-07-22T10:17:27Z2019-07-22T10:33:59ZHow can I load (many!) points from file, and display them in 3D including color?Hi,
I'm new to MATLAB
I need to upload many points from a file (up to 25 milion points, but about 15 milion points will also be enough) and display them in 3d space including the option to move them in all dicertions. I also want (if it's possible) to determine the Color of each point.
I create the input file by myself, so it's easy for me to change the format of this file to any format that Matlab can read.
For example it can be a simple text file in the format:
7850, 5394, 6240, 0x22578C
5172, 2958, 1852, 0x72B5A4
397, 1450, 42, 0xB4FC7A
.....
.....
where each line is a pixel: x, y, z, Color in RGB.
I can also create a binary file (for example: "InputPoints.bin") with the points data if it's easier for the Matlab to read.
So, I need to load all the points from my input file, and to show them as color points in a 3d space.
If adding color for each point is a problem, then for now points without a color will also be "OK", but points with color will be much better for what I need.
Please advice,
Thanks!
MathLab Userhttps://www.mathworks.com/matlabcentral/profile/authors/15842834-mathlab-usertag:www.mathworks.com,2005:Question/2836752016-05-11T09:14:16Z2019-07-22T10:26:47ZHow to set a parameter as a variable in a simulink block from Matlab?Hello everyone,
I am using a function in matlab that has as input a frequency. The idea is that the function modifies the cutoff frequency of a low pass filter (from a Simulink model) with the frequency provided as input. The Simulink model splits a time function in two new functions (one with frequencies below the cutoff frequency and the other with the frequencies higher than the cutoff frequency). The code from the second line to the fifth one, is meant to update the function that is going to be split (in case it has been modified)
So far I have come up with the following code:
function Create_Signal_PuissancekW(x)
load puissance_kW
puissance_kWx=transpose(puissance_kW);
time=1:length(puissance_kW);
signalbuilder('Division_Profil_Charge/ProfilCharge', 'set', 'Puissance', 'Group_1', time, puissance_kWx)
set_param('Division_Profil_Charge/Pass Bass','Wlo','x')
sim('Division_Profil_Charge','SimulationMode','normal');
The problem I have is that the function set_param() doesn't allow me to put a variable instead of a real value. I have tried with _set_param(gcb, 'UserData', x)_ and even puting _sim('Division_Profil_Charge','SimulationMode','normal','Pass Bass/Wlo',x)_ but none of them seems to work. Does anyone have an idea of what the problem might be?
Here is the Simulink model, in case it is necessary:
<</matlabcentral/answers/uploaded_files/51980/2016-05-11.png>>
And this is the error displayed by Matlab when I try to run the function: _Create_Signal_PuissancekW(0.00175)_
<</matlabcentral/answers/uploaded_files/51981/2016-05-11%20(2).png>>
Thanks a lot in advance!Juan Rodríguezhttps://www.mathworks.com/matlabcentral/profile/authors/7157727-juan-rodrigueztag:www.mathworks.com,2005:Question/4727962019-07-22T09:56:14Z2019-07-22T10:25:57Z3d surface helpso i have a xyz coordinates like this
x = [701850.324 701850.394 701850.512 701850.592 701850.66 701850.657 701850.592 701850.508 701850.388 701850.319 701850.324 701850.384 701850.504 701850.579 701850.649]
y = [9309973.758 9309973.034 9309971.834 9309971.021 9309970.33 9309970.327 9309971.02 9309971.832 9309973.033 9309973.758 9309973.758 9309973.032 9309971.83 9309971.011 9309970.319]
z = [19.725 19.84 19.796 19.82 19.79 20.89 20.909 20.903 20.881 20.935 22.622 22.495 22.573 22.508 22.57]
and i want to make a 3d models form those coordinates
i try to use mesh, giddata, surf function but still cant build the 3d models.
i hope you guys can help me to solve my problem. thanks :)Naftalie Riantyhttps://www.mathworks.com/matlabcentral/profile/authors/9939882-naftalie-riantytag:www.mathworks.com,2005:Question/4727972019-07-22T09:58:53Z2019-07-22T10:20:24Zuifigure behaving strangely under windowsI run a program having two regular figures and one uifigure open. The program is constantly busy (running a big while-loop). Both figure and the uifigure shall update at irregular intervalls (always when data has changed which is not very often).
All this works fine when I run the program on my mac but when I try to run the program on my windows PC the uifigure is corrupted. Sometimes it is not updating at all showing only a white, empty window, sometimes the uifigure is just updated partly (for example the upper halv is showing the lower part is only white).
I have both a drawnow and a little pause in my while-loop to give the time for redrawing. It feels like the PC doesn't make it to draw the uifigure but this is hard to believe (it's an i7 CPU and should well handle the workload).
Can anybody explain this?
I experience this with Matlab 2019a update 4 (somehow I can't select the release version down below).Ali Komaihttps://www.mathworks.com/matlabcentral/profile/authors/11593209-ali-komaitag:www.mathworks.com,2005:Question/4138872018-08-07T11:33:08Z2019-07-22T10:20:08ZError using figure: First argument must be a figure object or a positive Integer temp = uint32(1);
figure(temp);
Gives:
Error using figure
First argument must be a figure object or a positive Integer
If anything, 'temp' is definitly a positive integer. What is wrong? (Fix it Mathworks...)Jochem Bonariushttps://www.mathworks.com/matlabcentral/profile/authors/7965091-jochem-bonariustag:www.mathworks.com,2005:Question/4727942019-07-22T09:39:52Z2019-07-22T10:20:04ZHow to plot only variables selected by a user in GUI?I am creating a GUI which after pushbutton1 will load the data which is stored in handles as a structure. There are 10 variables available (stored as a field) and data and time is stored as different fields in this structure. I would like to create a list which will allow user to choose up to 5 variables from the list and then plot then variables (from data) against time. I have created a list with strings, but I am not sure how to connect that string to the variables names and the actual columns in the dataset:
list = {'varname1','varname2',..., 'varname10' };
[indx,tf] = listdlg('ListString',list);
Also how to update that list with those that has been chosen? (I was thinking of a list that is ''dynaically'' changed once the user has selected the variables.)Wiktoria Glogowskahttps://www.mathworks.com/matlabcentral/profile/authors/15842600-wiktoria-glogowskatag:www.mathworks.com,2005:Question/4728042019-07-22T10:19:54Z2019-07-22T10:19:54ZNon-planar robot Dynamics error using Roy Featherstone's Spatial toolbox I am using this code to test robot dynamics of above robot using Spatial Toolbox:
FDab(rob, [0;0;0], [0;0;0], [0;0;0])
But it gives error:
Error using *
Inner matrix dimensions must agree.
Error in FDab (line 49)
a{i} = Xup{i} * -a_grav + c{i};
This is because Xup is 6x6 double whereas a_grav is 1x3.
The 3 link non-planar robot is given as:
rob.NB = 3;
rob.parent = [0:2];
rob.jtype = { 'R', 'R', 'R' }
model.gravity = [0 0 0];
rob.Xtree{1} = rotx(1.57) * xlt([0 0 0]);
rob.Xtree{2} = roty(1.57) * xlt([0.15,0,0]);
rob.Xtree{3} = xlt([0.34 0 0]);
ax1=0.03; ay1=0.03; az1=0.03;
ax2=0.28; ay2=0.05; az2=0.05;
ax3=0.2; ay3=0.05; az3=0.05;
rob.I{1} = mcI( 1, [0 0 -0.02], 1/12*[ay1^2+az1^2 0 0; 0 ax1^2+az1^2 0; 0 0 ax1^2+ay1^2] )
rob.I{2} = mcI( 4, [0.14 0 0], 4/12*[ay2^2+az2^2 0 0; 0 ax2^2+az2^2 0; 0 0 ax2^2+ay2^2] )
rob.I{3} = mcI( 3, [0.1 0 0], 3/12*[ay3^2+az3^2 0 0; 0 ax3^2+az3^2 0; 0 0 ax3^2+ay3^2] )
rob.appearance.base = ...
{ 'box', [-0.2 -0.3 -0.2; 0.2 0.3 -0.07] };
rob.appearance.body{1} = ...
{ 'cyl', [0 0 0; 0.11 0 0], 0.05, ...
'cyl', [0 0 -0.06; 0 0 0.06], 0.06 };
rob.appearance.body{2} = ...
{ 'cyl', [0 0 0; 0.34 0 0], 0.05, ...
'cyl', [0 0 -0.06; 0 0 0.06], 0.06 };
rob.appearance.body{3} = ...
{ 'cyl', [0 0 0; 0.26 0 0], 0.05, ...
'cyl', [0 0 -0.06; 0 0 0.06], 0.06 };
showmotion(rob)
How can I overcome the error?Mohsina Zafarhttps://www.mathworks.com/matlabcentral/profile/authors/10259611-mohsina-zafartag:www.mathworks.com,2005:Question/4728032019-07-22T10:19:29Z2019-07-22T10:19:29ZColormap 'gray' does not work as it should in Matlab r2018Hi, I am currently running matlab r2018a in windows and I am facing A BIG problem with the function colormap 'gray'. It does not plot in gray the bar that I produce with the code below when 'nPC0==2'. Note that the code works perfectly in previous versions of matlab. Could you please help in fixing the code or prodiving me with some ideas about why this does not work anymore? I have already tried with colormap(gca,gray) but it does not work either
Thank you. F.
figure('Name', 'Prt R2')
for j = 1:size(LabPrtTmp,1);
iprt = icnt+1;
icnt = icnt + NumPrtTmp(j);
iprt = iprt:icnt;
subplot(nR, nC, j)
if nPC0 == 1
ytmp = dataplot(iprt, nPC0:nPC); % select matrix for bar plot
ytmp(:, 2:end) = ytmp(:, 2:end)-ytmp(:, 1:end-1); % from cum R2 to R2s (as stacked cumulates)
elseif nPC0==2
ytmp = dataplot(iprt, nPC0:nPC)- repmat(dataplot(iprt, 1), 1, nPC-1); % select matrix for bar plot (PC1 excluded)
ytmp(:, 2:end) = ytmp(:, 2:end)-ytmp(:, 1:end-1); % from cum R2 to R2s (as stacked cumulates)
colormap('gray')
end
nprt = length(ytmp);
bar(ytmp,'stacked')
xlim([xtmp(1)-.5 xtmp(end)+.5])
if (nC*nR-j)<nC;
xlab = xlabel('Portfolios');set(xlab,'FontSize',wlab)
end
strprt=strcat('P',num2str([1:size(dataplot, 1)]'));
set(gca,'XTick',1:nprt,'XTickLabel',strprt);
if mod(j-1,nC)==0
ylab = ylabel('R2 (in %)');set(ylab,'FontSize',wlab)
end
tit = title(LabPrtTmp(j, :));
set(tit,'FontSize',wtit,'FontWeight','normal')
grid on
axis tight
end % for j = 1:size(LabPrtTmp,1);
strleg=strcat('PC',num2str([nPC0:nPC]'));
legend(strleg,'Orientation','horizontal');F. Nucerahttps://www.mathworks.com/matlabcentral/profile/authors/5627552-f-nuceratag:www.mathworks.com,2005:Question/4724492019-07-19T06:10:52Z2019-07-22T10:18:50Zwhy is 'gather' performance dramatically poor when I evaluate a tall array (105151 Bytes) by an indexing operationHi experts,
I have a tall array from type double (Mx386) containing voltage values in each .
For visualization purposes I want to evaluate the first values of one electrode, but this single process took 5 h.
test1 = gather(test(1:500,3));
Also evaluating the tall array to get size is a time consumpting events
gather(size(test,1))
How can I accelerate the process? What could likely be the issue?
I'm happy about any hint to solve this.
Thank you in advance!
EvaEva-Maria Weisshttps://www.mathworks.com/matlabcentral/profile/authors/6680200-eva-maria-weisstag:www.mathworks.com,2005:Question/4728022019-07-22T10:17:57Z2019-07-22T10:17:57Z How to link two matrix, node's coordinate and lines between nodes?I have imported two matrix from Gmsh into matlab.
One matrix (3x45) provides to me the coordinates of nodes, the second (2x136) provides to me the connections between nodes.
The problem is that I know that each number of the second matrix is a nodes but for matlab are just two matrix with randon number.
How can i say to matlab that each nodes are the coordinates storage in the first matrix?
Example:
the first row of Line matrix is 1 17 and I would like to code in matlab 1 and 17 correspond with first and 17th row of Nodes matrix
Nodes =
1 0 0 0
2 5 0 0
3 5 5 0
4 0 5 0
5 0.999999999998413 5 0
6 1.99999999999551 5 0
7 2.99999999999697 5 0
8 3.99999999999849 5 0
9 5 4.00000000000000 0
10 5 3.00000000000000 0
11 5 1.99999999999999 0
12 5 0.999999999999991 0
13 4.00000000000000 0 0
14 3.00000000000000 0 0
15 1.99999999999999 0 0
16 0.999999999999991 0 0
17 0 0.999999999998413 0
18 0 1.99999999999551 0
19 0 2.99999999999697 0
20 0 3.99999999999849 0
21 2.50000000000036 2.50000000000001 0
22 1.43749999999957 1.43750000000026 0
23 1.43750000000081 3.56250000000055 0
24 3.56250000000014 1.43749999999987 0
25 3.56250000000025 3.56249999999959 0
26 2.55163043478259 1.01967773437503 0
27 3.98032226562521 2.55163043478244 0
28 1.01967773437521 2.44836956521634 0
29 2.44836956521649 3.98032226562503 0
30 0.835416666666811 0.835416666666551 0
31 0.835416666666499 4.16458333333299 0
32 4.17768912837252 0.822310871627482 0
33 4.16458333333322 4.16458333333347 0
34 2.15172155753807 1.84171674372294 0
35 1.91602312080068 2.87764584152284 0
36 3.15726153869470 2.15517014158528 0
37 2.87711830552300 3.08476478749167 0
38 0.658518880208503 3.43509057970907 0
39 1.56490942028979 0.658518880208368 0
40 3.43509057970908 4.34148111979162 0
41 0.662502325148937 1.56031395574398 0
42 3.45836391263105 0.655897721200476 0
43 4.34410227879957 1.56228826128196 0
44 1.56031395574401 4.33749767485115 0
45 4.33749767485133 3.43968604425469 0
Lines=
1 17
1 30
2 13
2 32
3 9
3 33
4 5
4 31
5 6
5 31
5 44
6 7
6 29
6 44
7 8
7 29
7 40
8 3
8 33
8 40
9 10
9 33
9 45
10 11
10 27
10 45
11 12
11 27
11 43
12 2
12 32
12 43
13 14
13 32
13 42
14 15
14 26
14 42
15 16
15 26
15 39
16 1
16 30
16 39
17 18
17 30
17 41
18 19
18 28
18 41
19 20
19 28
19 38
20 4
20 31
20 38
21 34
21 35
21 36
21 37
22 26
22 28
22 30
22 34
22 39
22 41
23 28
23 29
23 31
23 35
23 38
23 44
24 26
24 27
24 32
24 36
24 42
24 43
25 27
25 29
25 33
25 37
25 40
25 45
26 15
26 22
26 24
26 34
26 36
26 39
26 42
27 11
27 24
27 25
27 36
27 37
27 43
27 45
28 19
28 22
28 23
28 34
28 35
28 38
28 41
29 7
29 23
29 25
29 35
29 37
29 40
29 44
30 17
30 22
30 39
30 41
31 5
31 23
31 38
31 44
32 13
32 24
32 42
32 43
33 9
33 25
33 40
33 45
34 21
34 28
34 35
34 36
35 29
35 37
36 21
36 37
Danilo Sanfilippohttps://www.mathworks.com/matlabcentral/profile/authors/14852822-danilo-sanfilippotag:www.mathworks.com,2005:Question/4714302019-07-12T10:03:20Z2019-07-22T10:06:13ZChange type of datastoreHi Everbody,
does anyone know, if there is a possibility to get a tall array from a .csv file not as tabular type, but as array?
So my problem is, I can create a database from that csv file, convert it to a tall array, everything is fine and quick. But when I whant to load data to memory by using gather it takes an incredible huge amount of time.
I've read, that the performance on tables is poor compared to arrays, so I thought it would be good to have the data as tall array instead of having it as tall tabular data.
Can anyone help? I appreciate any hint!
Best regards
EvaEva-Maria Weisshttps://www.mathworks.com/matlabcentral/profile/authors/6680200-eva-maria-weisstag:www.mathworks.com,2005:Question/1254652014-02-13T05:00:00Z2019-07-22T10:04:46ZWhat is MATLAB Online?I recently heard about MATLAB Online. What is it, and where can I learn more about it?
MathWorks Support Teamhttps://www.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:www.mathworks.com,2005:Question/4727992019-07-22T10:03:21Z2019-07-22T10:03:21Zvectorization in context of if-condition and comparison for image arrayI want to implement some image compositing methods in Matlab like for example ModulusAdd defined as
if (Sca + Dca) <= 1
Dca = Sca + Dca;
else
Dca = (Sca + Dca) - 1;
end
Here Sca, Dca, Sa, Da are (h,w,1) arrays (gray scale images respective alpha channels) all as double (see also http://www.w3.org/TR/2014/CR-compositing-1-20140220/ for image compositing details).
Comparisons with the if-condition are defined for scalar values so using the above code in Matlab is not working directly (there are also other compositing methods that relay on other if-conditions like "if Sca == 0 && Dca == Da ..." that can not directly be ported so answering this question might also be helpful for those cases). Naively one has to deal with the pixel level and its two nested for-loops:
for i=1:h
for j=1:w
if (Sca(i,j) + Dca(i,j)) <= 1
Dca(i,j) = Sca(i,j) + Dca(i,j);
else
Dca(i,j) = (Sca(i,j) + Dca(i,j)) - 1;
end
end
end
How can I redesign this to make it work faster with an (h,w,1) (or (h,w,3)) array? Perhaps a redesign beyond arrayfun is possible (being not an expert in this):
Dca = arrayfun(@ModulusAdd_scalar, Sca, Dca);
function d = ModulusAdd_scalar(s, d)
if (s + d) <= 1
d = s + d;
else
d = (s + d) - 1;
end
endGünter Bachelierhttps://www.mathworks.com/matlabcentral/profile/authors/9187338-gunter-bacheliertag:www.mathworks.com,2005:Question/4727982019-07-22T10:01:09Z2019-07-22T10:01:09Zcode for odd symmetry 2D Log-Gabor filteri am in need of matlab code for odd symmetry 2D Log-Gabor filter.. please help meAnnie michealhttps://www.mathworks.com/matlabcentral/profile/authors/8372988-annie-michealtag:www.mathworks.com,2005:Question/4722922019-07-18T08:17:07Z2019-07-22T09:59:59Z Interpolation of zero values in matlabHello! The readings from the gas sensor look like this: 70 71 0 69 0, at a temperature of 12 12.2 12.1 11.9 11.2. I try to interpolate all zero values, but for some reason I don’t consider it at all
[cat,nocat]=min(Animals); %readings from a 1x1200 thermometer
[dog,nodog]=max(Animals); % gas sensor reading 1x1200
for i=1:length(cat)
if dog(i)<0 % if some indication is less than 0 (they are all positive)
interpol(i)=dog(i); % the location of these zeros and this is what we interpolate (1 and the last value are not zero)
c(i)=interp1(interpol(i),cat(i),nearest); % interpolate;
else(i) dog(i)>0 % if the values are greater than 0
c(i)= dog(i); % That testimony and remain
end
endLev Mihailovhttps://www.mathworks.com/matlabcentral/profile/authors/15690204-lev-mihailovtag:www.mathworks.com,2005:Question/4725142019-07-19T13:49:29Z2019-07-22T09:51:05ZDifferent results in training a CNN with Matlab 2018a and Matlab 2019aHi, I am training a CNN of classification.
I have trained it with the same seed in Matlab 2018a and Matlab 2019a, after adapting the initialization algorithm in the convolutional layers and the fully connected layer to 'narrow-nomal' in Matlab 2019a, in order to make it comparable. As well, I have set the validation patience in 12 for both releases.
However, I am still getting far different results. Is there anything else that I should take into account to have the same training results? Are there others updates in Matlab 2019a that I should consider?
Thank you in advanceMaría Begoña Rojashttps://www.mathworks.com/matlabcentral/profile/authors/11388178-maria-begona-rojastag:www.mathworks.com,2005:Question/4727952019-07-22T09:49:08Z2019-07-22T09:49:08ZAntenna Toolbox: Issue in simulating the radiation pattern of a 4 elements Yagi antennaI am trying to simulate the radiation pattern of an antenna (4 elements yagi: https://www.iz2uuf.net/wp/index.php/2013/04/06/100g-yagi/) by using the antenna toolbox.
Unfortunately, my simulation (script attached) shows some difference especially in the Horizontal Plane and I am trying to understand where my mistake is.Alberto Luccihttps://www.mathworks.com/matlabcentral/profile/authors/15810019-alberto-luccitag:www.mathworks.com,2005:Question/3101132016-11-01T11:49:50Z2019-07-22T09:46:33Zhow to find out full width at half maximum from this graph<</matlabcentral/answers/uploaded_files/62396/fwhm.png>>
parry sharmahttps://www.mathworks.com/matlabcentral/profile/authors/9004626-parry-sharmatag:www.mathworks.com,2005:Question/4727782019-07-22T08:51:56Z2019-07-22T09:46:32ZCreating new matrix from the second column of other matricesHi,
I have 10918 matrices with dimensions of [1000*4].
I want to create a new matrix which its columns are the second column of 10918 matrices which I have.
These 10918 matrices are .plt file and their name are as : PIV_1, PIV_2, PIV_3,....,PIV_10918.
For example:
PIV_1=[x_1,y_1,u_1,v_1]
PIV_2=[x_2,y_2,u_2,v_2]
...
PIV_10918=[x_10918,y_10918,u_10918,v_10918]
new matrix=[y_1,y_2,...,y_10918]
I am sorry if i cant explain well . Thanks in advance for your help.
Shabnam Mhttps://www.mathworks.com/matlabcentral/profile/authors/15842580-shabnam-mtag:www.mathworks.com,2005:Question/4727702019-07-22T08:02:50Z2019-07-22T09:43:55ZSplitting based on delimiter but only onceHello!
I know how to split a string entirely based on a delimiter. But I would like to know how to do the following split
Input: Country ˈk ʌ n t r i
Output: Country
and ˈk ʌ n t r i
That is, I would like to use the first 'space' as a delimiter. But not the other spaces between the letters.
Please let me know how to make this possible.
Thanks in advance!
Sanjana Sankarhttps://www.mathworks.com/matlabcentral/profile/authors/15815881-sanjana-sankartag:www.mathworks.com,2005:Question/4727932019-07-22T09:34:57Z2019-07-22T09:40:55ZSlow checkLayer-function for simple custom reshape layerI'm trying to create a simple layer to use directly after my imageInputLayer in a neural network. The purpose of the layer is to channel-split the image-input. The input is a three-channel image, where the first channel contains grayscale image data, the middle channel is a zeros-matrix and the third channel contains a few parameters that are later extracted into a 1x11x1 vector by using a max-pooling layer. The purpose of doing this is to be able to use both image and parameter inputs in my neural network. The code for creating the custom layer is as follows:
classdef splitLayer < nnet.layer.Layer
properties
inputSize;
outputSize;
end
methods
function layer = splitLayer(Name)
%Initialize output and input sizes
layer.Name = Name;
layer.inputSize = [256 256 3];
layer.outputSize = [256 256 1];
layer.NumOutputs = 2;
end
function [Z1, Z2] = predict(layer, X)
numObservations = size(X,4);
%Split channels and return as separate outputs
Z1 = zeros([layer.outputSize numObservations], 'like', X);
Z2 = zeros([layer.outputSize numObservations], 'like', X);
for i = 1:numel(numObservations)
Z1(:, :, :, i) = X(:, :, 1, i);
Z2(:, :, :, i) = X(:, :, 3, i);
end
end
function [Z1, Z2, memory] = forward(layer, X)
numObservations = size(X,4);
%Split channels and return as separate outputs
Z1 = zeros([layer.outputSize numObservations], 'like', X);
Z2 = zeros([layer.outputSize numObservations], 'like', X);
for i = 1:numel(numObservations)
Z1(:, :, :, i) = X(:, :, 1, i);
Z2(:, :, :, i) = X(:, :, 3, i);
end
memory = numObservations;
end
function [dLdX] = backward(layer, ~, ~, ~, dLdZ1, dLdZ2, memory)
numObservations = size(dLdZ1, 4);
is = layer.inputSize;
dLdX = zeros(is(1), is(2), 3, numObservations, 'like', dLdZ1);
zeromat = zeros(is(1), is(2), 'like', dLdZ1);
%For each observation dimension, concatenate separated dimensions and pass backwards
for i = 1:numel(numObservations)
dLdX(:,:,:,i) = cat(3, dLdZ1(:, :, :, i), zeromat, dLdZ2(:, :, :, i));
end
end
end
end
However, when using checkLayer to validate my custom layer, the checkLayer-function is very slow, and by some debugging I have realized that it is slow at computing the derivatives in the backward function.
Since this is only my second custom layer, I'm not sure where the problem lies. Could it be the use of the cat-function? In that case, how do I implement the same functionality differently in a way that functions faster on a GPU?Julius Åkessonhttps://www.mathworks.com/matlabcentral/profile/authors/7652274-julius-akessontag:www.mathworks.com,2005:Question/2786742016-04-12T19:18:11Z2019-07-22T09:35:59ZHow do I sum all the y values of a scatter plot to turn it into a histogram?I have a scatter plot of between 600000 and 700000 data points (which are randomly in an array) and I now need to sum all the points in a certain x range (i.e. 0-0.1, 0.1-0.2, etc) to essentially form a histogram to try and highlight any small, repetitive trends in the data. I'm just wondering if there is a function (or combination of functions) that will allow me to do this. I believe I am using MATLAB 7.8.0 (R2009a).
Thanks.Kevin Joneshttps://www.mathworks.com/matlabcentral/profile/authors/8020243-kevin-jonestag:www.mathworks.com,2005:Question/4727042019-07-21T17:34:52Z2019-07-22T09:30:00Zwhat is the best method to fit a curve to strain-stress data?Dear Matlab experits,
Is there any preference towards any method (Matlab function) to fit a curve into strain-stress data? Is polyfit is reliable enough?
Thank you..
Aziz
Abdulaziz Abutunishttps://www.mathworks.com/matlabcentral/profile/authors/5634873-abdulaziz-abutunistag:www.mathworks.com,2005:Question/4727922019-07-22T09:28:36Z2019-07-22T09:28:36ZHow to convert a input and output arrays of complex numbers to iddata, idfrd or any other models in System Identification Toolbox?Dear colleagues,
Please tel me, how to convert a input and output arrays of complex numbers to iddata, idfrd or any other models in System Identification Toolbox?Gleb Derzkijhttps://www.mathworks.com/matlabcentral/profile/authors/10156104-gleb-derzkijtag:www.mathworks.com,2005:Question/4727902019-07-22T09:25:44Z2019-07-22T09:25:44ZError running Matlab code in java intellijHi
Please cann someone help me with this problem
I am trying to run my matlab code in java intellij after packaging it.
I am getting the error below when I try to search for file and load it.
Error using load
Unable to read file 'second1.csv'. No such file or directory.
Error in ido (line 10)
Exception caught: com.mathworks.toolbox.javabuilder.MWException: Unable to read file 'second1.csv'. No such file or directory.
it runs well in the matlab code though.
What do I need to do to rectify this issue
Thanks in advance
Tino
Tinohttps://www.mathworks.com/matlabcentral/profile/authors/14719592-tinotag:www.mathworks.com,2005:Question/4725192019-07-19T14:17:15Z2019-07-22T09:25:42ZHow do I get the real-time plot form Analog input app (matlab 2019) to start from 0?Hi!
I'm using the Analog input app from 2019 version Matlab. I do not include here the code because it's the one given directly by the Analog input app. I'm using this app because I have two different channels (option not included in the Live Acquisition app) and because I want to get the whole plot once the meassurements are done.
The app does so fine but the problem is that the real-time plot only shows 1 second of data (it shows date from 0 to 1 s and then from 1 to 2 s, and so on), how can I modify the code so that the real-time plot starts from 0?
I can use a "hold on" at the end of the code and the real-time plot starts from 0 as I want it to but the codes gives an error ("data inputs must match the axis configuration...")
Thanks,
M.M Andhttps://www.mathworks.com/matlabcentral/profile/authors/15828615-m-andtag:www.mathworks.com,2005:Question/4727892019-07-22T09:24:37Z2019-07-22T09:24:37ZDesign K using bode plotdesign gain for a given transfer function with given gain and phase margins in a bode plotNikhilesh T Shttps://www.mathworks.com/matlabcentral/profile/authors/15647228-nikhilesh-t-stag:www.mathworks.com,2005:Question/4727882019-07-22T09:22:04Z2019-07-22T09:22:04ZWhat are the best IP cameras to perform real-time video based OCR?I am working on a problem where I need to read label number of a box when it is moving across to the camera. Currently, I am using an HIK VISION 4MP 12mm IP camera at 1/100s exposure. But the results are not accurate, I wanted to know that, the current camera is really sufficient for reading letters on label. Any camera recommendations are really helpful for my work.Shaik Ahmadhttps://www.mathworks.com/matlabcentral/profile/authors/6789025-shaik-ahmadtag:www.mathworks.com,2005:Question/4726312019-07-20T16:11:47Z2019-07-22T09:22:01ZSolving a system of mass balance equations with implicit variablesHi,
I want to solve a system of mass balance equations which have concentrations implicit in them. I have attached a photo of the mass balance equations above. 'n' = 1:15 and 'm' = 1:20. so it is a 15 by 20 column of cells. I want to apply the mass balance so that it can update the concentrations of the cell (m,n) but there is no equation for the concentration separately and concentrations cannot be written explicitly (they are also part of the 'tNa' and 'tA' terms, and they cant be explicitly written in those terms)Zain Shabeebhttps://www.mathworks.com/matlabcentral/profile/authors/9294371-zain-shabeebtag:www.mathworks.com,2005:Question/4727122019-07-21T18:37:23Z2019-07-22T09:20:08ZCreateInputOuput data.m in 2012a do not work in 2018a, error Undefined function or variable 'inputs'. Error in CreateInputOutputData (line 9) totallength = length(inputs);%load the data from text file.
disp('Reading in input data from file.....');
disp('....done!!');
%randomize the data.
%get length of total dataset.
totallength = length(inputs);
%inputData = Conf|NoMatch1|NoMatch2|NoMatch3|NoInput1NoInput2|NoInput3|MaxSpeech1MaxSpeech2|MaxSpeech3|Bargein|Hangup|Transfer To Agent|DTMF Transfer.....
%outputData = Field Performance|Field Transfer Reason|Field Global Exit Reason|Field Hangup Reason|Field NNM|Field Duration|Field Recogntion Level|Field System Error
inputData = zeros(totallength, 25);
outputData = zeros(totallength, 4);
disp('Randomizing the data sets.....');
Mapping = randperm(totallength)';
i = 1;Vikash Ramesharhttps://www.mathworks.com/matlabcentral/profile/authors/3298286-vikash-rameshartag:www.mathworks.com,2005:Question/4727872019-07-22T09:15:18Z2019-07-22T09:15:18ZslLinearizer & parameter variation in SimscapeHello,
I want to do a batch linearisation using slLinearizer on a Simulink model that contain Simscape components.
The linearisation is actualy working, but with for loops and iterations over vectors. That's slow.
The changing parameters coupling & primary_ind are inside of a simscape block :
I can create the batch linearisation interface :
io = getlinio(projectName);
sllin = slLinearizer(projectName,io);
I can create and specify the parameters :
coupling_mat = linspace(a,b,c);
primary_ind_mat = logspace(a,b,c);
[I,C] = ndgrid(primary_ind_mat,coupling_mat);
params(1).Name = 'primary_ind'; % i want here to link the simscape block upside
params(1).Value = I;
params(2).Name = 'coupling'; % same here
params(2).Value = C;
But when i try to update the parameters :
sllin.Parameters = params;
I get this error :
Error using slLinearizer/set.Parameters (line 324)
The expression "input(1).Name", "primary_ind" does
not successfully evaluate in model or base
workspace.
Caused by:
Error using sdo.getValueFromModel (line 94)
The variable 'primary_ind' cannot be resolved by
the model 'teslar2019a'. Make sure that the
variable is defined in the model, base
workspace, or data dictionary.
But as you can see on the first pic, there is a parameter called "primary_ind" in the model, inside a simscape block.
I've read :
https://fr.mathworks.com/help/slcontrol/ug/sllinearizer.html
https://fr.mathworks.com/help/slcontrol/batch-linearization.html
https://fr.mathworks.com/help/slcontrol/ug/ways-to-generate-parameter-samples.html
I don't get how to link the parameters to the simulink model.
Thank you !
AsterixWalkerhttps://www.mathworks.com/matlabcentral/profile/authors/15691263-asterixwalkertag:www.mathworks.com,2005:Question/4721592019-07-17T13:10:18Z2019-07-22T09:14:31ZCross sections of 3D surface (stl)Dear Matlab community,
I am working towards a project and one of my tasks is to generate 0.3mm increment cross-sections of an STL file. The delicate part of the process is that I generated cross-sections to similar STL files using a different software (VMTK) but due to the limitations of that software i now need to refer to matlab.
My Question:
Is there a way where I can generate a script which enables me to get cross sections of my STL in 0.3mm increments AND using a pre-determined cutting plane? In other words, I would like to use the same cutting plane as used in VMTK to generate these new cross-sections using MATLAB (for consistency).
Please provide me with some help or guiadance.
I thank you for your time,
-Dev.Devrim Tugberkhttps://www.mathworks.com/matlabcentral/profile/authors/13461396-devrim-tugberktag:www.mathworks.com,2005:Question/4727572019-07-22T06:50:58Z2019-07-22T09:10:59Zi have a text file contains x,y coordinates along with corresponding class numbers.i would like to prepare matrix for that datai have a text file contains x,y coordinates of hyperion training pixels inforamtion along with corresponding class numbers.i would like to prepare ground truth matrix with x,y coordinates and place corresponding class numbers.i given following typical example text file for your consideration. X and Y denotes pixels coordinates and c represents class value. size of matrix to be 425 by 250 with 8 class values
ID X Y C
1 21 1 1
2 22 1 1
3 20 1 1
4 106 20 2
5 150 15 2
Manikandan Sathianarayananhttps://www.mathworks.com/matlabcentral/profile/authors/15838431-manikandan-sathianarayanantag:www.mathworks.com,2005:Question/4727852019-07-22T09:09:23Z2019-07-22T09:09:23Zfind false minutae points in fingerprintI am currently studying fingerprint biometrics and have been doing a lot of research into how fingerprint minutia is extracted. I have come across a demo in mathworks website that I am trying to understand. I have got as far as to understanding pre processing stages,such as Enhancement,Binarization,Thinning and minutia extraction. I am now trying to understand how the false minutia process operates. I understand that it works by use of distance computing, i.e If the distance between a termination and a biffurcation is smaller than D,remove this minutia etc. What I have trouble understanding in the code below, is how is D assigned a value of 6? I understand that the function DistEuclidian is being called (this is calulating Euclidatian Distance,which I understand! But don't understand were D=6 comes from?? Thank you in advance.
D=6;
Distance=DistEuclidian(CentroidBif,CentroidTerm);
SpuriousMinutae=Distance<D;
[i,j]=find(SpuriousMinutae);
CentroidBif(i,:)=[];
CentroidTerm(j,:)=[];Nupur Goyalhttps://www.mathworks.com/matlabcentral/profile/authors/15565168-nupur-goyaltag:www.mathworks.com,2005:Question/4727842019-07-22T09:07:52Z2019-07-22T09:07:52ZThermal image based segmentationI'm working on a project to do segmentation of thermal images. So far, the methods have produced limited segmentation performance (k-means, Otsu's Method, Sobel, Canny, LoG).
I am trying to achieve good segmentation of doors and windows in image like these. What approaches would you suggest to try?
SBakchttps://www.mathworks.com/matlabcentral/profile/authors/14737531-sbakctag:www.mathworks.com,2005:Question/4440592019-02-09T14:18:21Z2019-07-22T09:06:36ZHow to segment an image?I am new to image processing and I am attempting to segment an image.
horizontalKernel = [-1,-1,-1;2,2,2;-1,-1,-1];
verticalKernel = [-1,2,-1;-1,2,-1;-1,2,-1];
diagUpKernel = [-1,-1,2;-1,2,-1;2,-1,-1];
diagDownKernel = [2,-1,-1;-1,2,-1;-1,-1,2];
building=imread('https://i.imgur.com/jUcx20p.jpg');
figure;
horizontalBuilding = imfilter(building, horizontalKernel);
subplot(2,2,1), image(horizontalBuilding);
verticalBuilding = imfilter(building, verticalKernel);
subplot(2,2,2), image(verticalBuilding);
diagDownBuilding = imfilter(building, diagDownKernel);
subplot(2,2,3), image(diagDownBuilding);
diagUpBuilding = imfilter(building, diagUpKernel);
subplot(2,2,4), image(diagUpBuilding);
How can I more accurately segment this image?SBakchttps://www.mathworks.com/matlabcentral/profile/authors/14737531-sbakctag:www.mathworks.com,2005:Question/4727822019-07-22T09:03:44Z2019-07-22T09:03:44Zpartial word search text analytics toolboxhow do I undertake a partial word search in the text analysis toolbox, so for example I am seacrhing for 'wind' using context, but also want 'winds' or 'windspeed'Bjoern Elsaesserhttps://www.mathworks.com/matlabcentral/profile/authors/15594732-bjoern-elsaessertag:www.mathworks.com,2005:Question/4727812019-07-22T09:00:41Z2019-07-22T09:00:41Zinverse of a subset of a matrixHi everyone,
I have a matrix that has an n by p dimension and I would like to grab all the 3x3 submatrices and inverse them. also by the end of the operation, I would like to put them back as n by p matrix.
As an exemple 3x28 matrix.
Hope to hear from you.
zakaria azdadhttps://www.mathworks.com/matlabcentral/profile/authors/7602091-zakaria-azdadtag:www.mathworks.com,2005:Question/4727802019-07-22T08:58:33Z2019-07-22T08:58:33ZWhy a2 is sym, but a1 a3 and a4 are double?a=0.336;
Ta=9.476;
Te=1.208;
Tw=1.498;
eqh=[0.661;0.619;0.568];
ex=[-1.24;-1.346;-1.441];
en=-ex;
ey=[0.376;0.705;0.968];
eqx=[-0.309;-0.357;-0.392];
eh=[1.594;1.583;1.545];
eyqh=[0.642;0.78;0.897];
a0=a*Ta*Te^2;
a1=sym([]);a2=sym([]);a3=sym([]);a4=sym([]);exqh=sym([]);
figure('Name','i-Stable');
r = -100:1:100;
[bt,Td]=meshgrid(r);
syms Ki Kp;
i=1;
Kp=1./bt;
exqh(i)=en(i).*eqh(i)+eqx(i).*eh(i);
Ki=1./(bt.*Td);
a1=Ta.*Tw.*eqh(i)+a.*Te^2.*en(i)+a.*Te^2.*ey(i).*Kp;
a2=a.*Te^2.*ey(i).*Ki+Ta+Tw.*exqh(i)-eyqh(i).*Kp.*Tw;
a3=en(i)+ey(i).*Kp-eyqh(i).*Ki.*Tw;
a4=ey(i).*Ki;
zhenyu zenghttps://www.mathworks.com/matlabcentral/profile/authors/14061743-zhenyu-zeng