https://nl.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2019-04-21T20:13:17Ztag:nl.mathworks.com,2005:Question/4575142019-04-20T10:47:25Z2019-04-21T20:13:17ZHow to crop matrices at the maximal non-NaN values and then center the dataHi all,
I am new to MATLAB and I have the following problem:
I have matrices something like:
H(1).matrix = [1 2 3
3 4 5
3 4 4
6 NaN 7
NaN NaN NaN]
H(2).matrix = [3 4 5
5 6 7
4 4 4
NaN 3 3
NaN 4 4
NaN NaN 7]
H(3).matrix = [3 3 3
2 1 3
NaN 1 2]
Now, I see that these matrices all have 3 columns but different row number, first is 5x3, second 6x3, third 3x3, but also within columns they have different row length with actual numbers and not NaN. I see that the longest rows length where each columns have non NaN values is 2 (in the third matrix, the first row and the second row with all non NaN values). So now I want to crop all the matrices to have size 2x3. Then I want to center all these matrices.
Something like:
H(1).matrix = [1 2 3
3 4 5]
H(2).matrix = [3 4 5
5 6 7]
H(3).matrix = [3 3 3
2 1 3]
Then I want to center the data (remove from each element the average of the column it belongs to).
Thank you in advance!Spresihttps://nl.mathworks.com/matlabcentral/profile/authors/12750159-spresitag:nl.mathworks.com,2005:Question/4576802019-04-21T18:20:15Z2019-04-21T20:10:42ZRearrange matrix and concatenate cellsHi everyone,
I have a 3492x5 matrix with variable names say variable1, variable2,...,variable5. I have been trying to cut this matrix into 12 291x5 cells and rearrange them into a 291x60 matrix. But when I did this, I had error of duplicate variable names. So, I'm wondering if there way to circumvent this? With or without variable names is ok for me since they are not really useful.
Here is the code I used:
filename=datadimer
[m n]=size(filename)
sZ=291;
Numofrows= m/(sZ);
C=mat2cell(filename,sZ*ones(1,Numofrows),size(filename,2));
for i=1:Numofrows
D(:,i)=C(i,:);
end
output=horzcat(D{:});
The input matrix ('filename') contains one row of string and first 16 rows look like this:
Any help will be much appreciated, thank you!
Heathen233https://nl.mathworks.com/matlabcentral/profile/authors/5066685-heathen233tag:nl.mathworks.com,2005:Question/4576972019-04-21T20:07:22Z2019-04-21T20:07:22Zcalculating line integral code checkso below is my code just wanna know if what i have done is correct
N = 101;
tmin = 0;
tmax = 3;
t = linspace(tmin,tmax,N);
x=2*cos(2*pi*t)+0.4*sin(16*pi*t);
y=4*sin(2*pi*t)+0.2*cos(16*pi*t)+t;
z=0.1*cos(16*pi*t)+t;
r = [ x; y ; z];
dt = t(2)-t(1);
%using central difference approximation
dxdt = (x(3:end)-x(1:end-2))/(2*dt);
dydt = (y(3:end)-y(1:end-2))/(2*dt);
dzdt = (z(3:end)-z(1:end-2))/(2*dt);
drdt = [ dxdt; dydt; dzdt];
n = (N-1)/2; %here we store the number of points that dldt are stored at
dldt = zeros(1,n); %initialise dldt
for i = 1:n
dldt(i) = norm(drdt.*drdt);
end
%integral
l = sum(dldt)*2*dtdulangahttps://nl.mathworks.com/matlabcentral/profile/authors/5545365-dulangatag:nl.mathworks.com,2005:Question/4576772019-04-21T18:07:15Z2019-04-21T20:04:09Ztangent at specific pointi plotted parametric curve r(t)=<t , t^2 , 2>, now i have to plot tangent at P(-1 , 1, 2) but i cant figure it out. can you help me please.
t = 0:pi/50:10*pi;
st = t;
ct = t.^2;
figure(1)
plot3(st,ct,repmat(2,1,numel(t)))
hold onKuatra Patilhttps://nl.mathworks.com/matlabcentral/profile/authors/15291254-kuatra-patiltag:nl.mathworks.com,2005:Question/4576942019-04-21T19:45:57Z2019-04-21T20:03:30Zwhat is the difference between rgb2gray and im2bw ?I want to know the difference between the two functions ... arent both convert the rgb image to black and white image ?!Mahmoud Hassanhttps://nl.mathworks.com/matlabcentral/profile/authors/13358401-mahmoud-hassantag:nl.mathworks.com,2005:Question/4572822019-04-18T23:38:55Z2019-04-21T20:02:36Zreindexing a correlation matrixI have a matrix 100x100.
I would like to re-sort the indices of the elements, and re-create the matrix with the new numbering scheme.
showing this as a 3x3 to simplfy my question:
[1 1 1 ; 2 2 2 ; 3 3 3 ]
So that a vector of the element names is 1,2,3,...100.
I want to rename the elements with a new vector, that looks random: 97,5,6... etc
so that I have a new matrix with the new naming arrangement and
so that the value of original element (1,2) will now be the values that was (97,5)
I hope this makes sense. The matrix is not symmetric across the diagonal.
Can someone help me?
thanks
Teena
teena dobbshttps://nl.mathworks.com/matlabcentral/profile/authors/10977233-teena-dobbstag:nl.mathworks.com,2005:Question/4576932019-04-21T19:44:24Z2019-04-21T19:57:23Zplotting help needed (increasing resolution)this is my code how would i increase the resolution of the graph?
N = 101;
tmin = 0;
tmax = 3;
t = linspace(tmin,tmax,N);
x=2*cos(2*pi*t)+0.4*sin(16*pi*t);
y=4*sin(2*pi*t)+0.2*cos(16*pi*t)+t;
z=0.1*cos(16*pi*t)+t;
plot3(x,y,z)dulangahttps://nl.mathworks.com/matlabcentral/profile/authors/5545365-dulangatag:nl.mathworks.com,2005:Question/4576952019-04-21T19:51:46Z2019-04-21T19:51:46Zhow to know if image is rgb?i want to set an if condition to know if the image i am reading is rgb image or not Mahmoud Hassanhttps://nl.mathworks.com/matlabcentral/profile/authors/13358401-mahmoud-hassantag:nl.mathworks.com,2005:Question/4576482019-04-21T11:34:07Z2019-04-21T19:51:36Zreturn row index of values greater than 0 to a 3 dimensional arrayI have a Matrix A, of m x n dimensions.
I wish to go through each row from left to right and return the index of values greater than 0. I have tried the folowing which returns the column index for the first row which has values. for example row 26.
I have tried the following but I am not getting the outputmatrix with all entries. I fear the entries are being overwritten
A =[2,-4,-0.5,0.34;0.01,4,-0.5,0.34;-10,4,-0.2,0.6;-10,4,-0.2,0.6;-19,15,-0.7,0.6];
% Now we have input matrix A we want to return the col index of each row element greater than 0.
% inputMatrix= A
outputMatrix=zeros(1,[],size(A,1));
for i = 26:size(A(2:end,:),1)
for ij = 1:size(A(2:end,:),2)
[rows, columns] = find(inputMatrix > 0)
outputMatrix=columns;
end
end
A =
2 -4 -0.5 0.34
0.01 4 -0.5 0.34
-10 4 -0.2 0.6
-10 4 -0.2 0.6
-19 15 -0.7 0.6
However I wish to go through each row, and store these column indices in a 3 dimensional array where each page represents the set of column indices from each row of A
Example output is a 3 dimensional array of column indices. - Matrix E
1, 4 (page 1)
1, 2, 4 (page 2)
2, 4 (page 3
2, 4 (page 4)
2,4 (page 5)
I then want to use these column indices to return the value from the corresponding rows of a matrix C and matrix D. Matrix C and D are the same dimentions as A
I then want to multiply C values by D values and return a 3 dimension array of results. - Matrix F
The results will be of the same dimension as Matrix E
Any help appreciated.
Charleshttps://nl.mathworks.com/matlabcentral/profile/authors/5506466-charlestag:nl.mathworks.com,2005:Question/4571692019-04-18T12:54:14Z2019-04-21T19:49:15ZHow to compute the homography Dear Community,
I have some issue to getting the trasnform image for homography
I want to apply the homography to an image, I do have homography martix from the general formulation
H = R+1/d*n*t'
H = rotation_matrix + t.* Normal
H =
0 -1.0000 0
-0.3420 0 -0.9397
5.9397 5.0000 4.6580
The basic concept of idea is to trying get image from vitrual camera, so the question I that how I can get the image from virtual camera ?
As you can see figure below , I have perspective image but I want to use inverse perspective mapping
Thanking you so much
Sushil Sharmahttps://nl.mathworks.com/matlabcentral/profile/authors/14231039-sushil-sharmatag:nl.mathworks.com,2005:Question/4576922019-04-21T19:43:54Z2019-04-21T19:43:54ZWhen using the FFT tool from the powergui, a whole cycle is not analyzed despite indicating the number of cycles is 1.The signal being used as the input to the FFT analysis tool is a filtered inverter signal (filtered by hardware and PWM control). I expect the THD to be much less than 48.34% as this is the THD expected from an unfiltered inverter. If I increase the number of cycles to include more of my waveform, the THD increases.
Any suggestions?
Frank Moselyhttps://nl.mathworks.com/matlabcentral/profile/authors/6938941-frank-moselytag:nl.mathworks.com,2005:Question/4575412019-04-20T14:56:34Z2019-04-21T19:37:50Zregexrep for the neophyteHow to write expression to find and convert financial strings written with comma separator to be able to parse numerically?
Example stirng is something like:
recipients={'John Doe $200, Freddy Flint $132.40 SP19; Mary Lamb $1,423.00-SP19, Joe Blow $1,200'};
which is a list of student scholarship awards entered, unfortunately, free-style in a remarks field in an Excel spreadsheet. I need to parse by student and extract each.
I managed to find/return the location/token of the amounts containing the punctuation, but I'm illiterate with regexp and haven't figured out how to locate the comma then within that substring to remove it.
K>> regexp(recipients,'([$]\d+[,]\d+)','match')
ans =
1×1 cell array
{1×2 cell}
K>> ans{:}
ans =
1×2 cell array
{'$1,423'} {'$1,200'}
K>>
As can be seen, the original text also has "issues" in that the separator between students isn't consistent--it may be a comma or semicolon, not sure what else I'll find as I progress.
For context, this is the next step past the previous Q? of piecing back together disparate databases/spreadsheets...now that I can compare the award to the billing by account, I can find coding or other errors--but need to be able compare the details.
dpbhttps://nl.mathworks.com/matlabcentral/profile/authors/28872-dpbtag:nl.mathworks.com,2005:Question/4576822019-04-21T18:27:42Z2019-04-21T19:34:13Zinserting image in a tableHey, I want to add an image to the table and then in next cell add it's quantitative measure(found through quality metrics). How can that be done in matlab? Fatima Rashidhttps://nl.mathworks.com/matlabcentral/profile/authors/8981413-fatima-rashidtag:nl.mathworks.com,2005:Question/4575202019-04-20T11:50:25Z2019-04-21T19:25:31ZTwo graphs at the same time PLEASE HELP
Hello,
I have this code that is used with arduino package
the code will be used to get data from two sensors:
load cell that measures load
displacement sensor that measures displacement
problems:
this code is showing two graphs but only one graph has labels
only one graph is showing data results
this is the code: (please note that i'm new to MATLAB and coding in general)
clear
clc
a=arduino('com3','Uno')
loadcell=addon(a,'ExampleAddon/HX711',{'D2','D3'})
plotTitle1 = 'Load VS Time';
xLabel1 = 'Elapsed Time (s)';
yLabel1 = 'Load (KN)';
legend1 = 'Load Cell 1'
plotTitle2 = 'Displacement VS Time';
xLabel2 = 'Elapsed Time (s)';
yLabel2 = 'Displacement (mm)';
legend2 = 'Displacement Sensor 1'
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
yMax1 = 10000000
yMin1 = 0
yMax2 = 10000000
yMin2 = 0
plotGrid = 'on';
min1 = 0;
max1 = 10000;
min2 = 0;
max2 = 10000;
delay = .001;
time = 0;
data1 = 0;
data11 = 0;
data12 = 0;
data2 = 0;
data21 = 0;
data22 = 0;
count = 0;
subplot(2,4,1)
plotGraph1 = plot(time,data1,'-r')
subplot(2,4,2)
plotGraph2 = plot(time,data2,'-r')
hold on
title(plotTitle1,'FontSize',5);
xlabel(xLabel1,'FontSize',5);
ylabel(yLabel1,'FontSize',5);
axis([yMin1 yMax1 min1 max1]);
title(plotTitle2,'FontSize',5);
xlabel(xLabel2,'FontSize',5);
ylabel(yLabel2,'FontSize',5);
axis([yMin2 yMax2 min2 max2]);
grid(plotGrid);
tic
figure (1)
while ishandle(plotGraph1)
dat1 = read_HX711(loadcell)-1940.225269
count = count + 1;
time(count) = toc;
data1(count) = dat1(1);
set(plotGraph1,'XData',time,'YData',data1);
axis([0 time(count) min1 max1]);
pause(delay);
end
hold on
figure (2)
while ishandle(plotGraph2)
dat2 = readVoltage(a,'A0')*80
count = count + 1;
time(count) = toc;
data2(count) = dat2(1);
set(plotGraph2,'XData',time,'YData',data2);
axis([0 time(count) min2 max2]);
pause(delay);
end
hold off
delete(a);
disp('Plot Closed and arduino object has been deleted');
Ameen Mouazzenhttps://nl.mathworks.com/matlabcentral/profile/authors/14732767-ameen-mouazzentag:nl.mathworks.com,2005:Question/4576902019-04-21T19:12:13Z2019-04-21T19:16:33Zhow to plot this ?i have a circle and i want to plot his half radius in the same figure can anyone help me :
angle=linspace(0,2*pi,360);
x=cos(angle);
y=sin(angle);
plot(x,y)
axis('equal')
diadalinahttps://nl.mathworks.com/matlabcentral/profile/authors/6918672-diadalinatag:nl.mathworks.com,2005:Question/4576812019-04-21T18:24:10Z2019-04-21T19:13:27ZHow to plot realtime ECG graph using arduino uno MATLABSorry for broken English
I'm working on a project that need to displaying a realtime ECG graph by using MATLAB and arduino uno. This is my arduino code.
void setup() {
Serial.begin(57600);
}
void loop() {
float voltage = analogRead(A0)*(5.0/1023.0);
Serial.println(voltage);
}
and this is my code in MATLAB
close all
clear all
delete(instrfind(('Port'),('COM5')));
s = serial('COM5','baudrate',57600,'Databits',8);
fopen(s);
ylim([-2,5]);
x = 1:100000;
h = animatedline('MaximumNumPoint',500);
grid on
grid minor
while(1)
for i = 1:100000
voltage = fscanf(s);
y(i)=str2double(voltage);
addpoints(h,x(i),y(i));
drawnow;
end
clearpoints(h)
end
for some reason, an ECG graph didn't show up on a moving graph.
EDIT : an ECG graph is showing up right now, but this ECG graph's width on x-axis is too large.Natthakrit Loe-anurithttps://nl.mathworks.com/matlabcentral/profile/authors/15293924-natthakrit-loe-anurittag:nl.mathworks.com,2005:Question/4573772019-04-19T13:35:12Z2019-04-21T19:11:07ZHow to check Excel sheet data of one with Excel sheet data of another on matlab and print the output on another Excel sheetSo,
I'm reading a list of flights data from an excel sheet called plot:
journeys = readtable('plot.xlsx');
And I have an ATS route givwen by lat10 and lon10:
lat10 = [12.9933,19.0852]; lon10 = [80.1705,72.8752];
I'm reading the flight data and selecting them based on groups (flight numbers) of flights that have 80% of their data within the ats route:
[x10, y10]= mfwdtran(mstruct,lat10,lon10);
X = [x10,fliplr(x10)];
Y = [y10,fliplr(y10)-d];
%Y = [y10,fliplr(y10)-d];
plot(x10,y10,'-','color','m');%plotting ats
hold on;
plot(x10,y10-d,'-','color','m');%only for 2nd and 3rd batch
%plot(x10-d,y10,'-','color','m');%only for first batch
hold on;
%selecting flights--------------
[journeys.x, journeys.y] = mfwdtran(mstruct, journeys.latitude, journeys.longitude); %transform the flights latitude and longitude
in = inpolygon(journeys.x, journeys.y, X, Y);
[groupid, flights] = findgroups(journeys.flight); %assign unique id to each flight and apply to rows of the table
inratio = splitapply(@(in)nnz(in)/numel(in), in, groupid); %ratio of points in polygon to points in flight
selectedflights = flights(inratio >= .8); %for flights that have 70% of their journey in the polygon
% isallin = splitapply(@all, in, groupid); %are ALL points of the flight in the polygon? logical output
% selectedflights = flights(isallin); %list of flights where all points are in the polygon
selectedjourneys = journeys(ismember(journeys.flight, selectedflights), :); %portion of the table with only the selected flights.
%selecting flights--------------
Now, I have a list of ATS routes in an excel sheet called ATS and I want to compare each flight data with each route that they correspond to. If a flight has 80% of its data within the route I want an excel sheet called Match to have the flight number and the ATS route it matches with.
I'm stuck with this problem from a long time now... kindly help please...
I have attached the excel sheets here.harman bhavejahttps://nl.mathworks.com/matlabcentral/profile/authors/15243328-harman-bhavejatag:nl.mathworks.com,2005:Question/4576892019-04-21T19:03:24Z2019-04-21T19:03:24ZHow can I mean multiple matrices, element by element in a n*n cell array?
I've got a data looks like this. size(16*6) cell array. I want to get the average of each columns, but keep the size of each matrice(650*1).Wenyi Xiaohttps://nl.mathworks.com/matlabcentral/profile/authors/13762167-wenyi-xiaotag:nl.mathworks.com,2005:Question/4576882019-04-21T19:01:26Z2019-04-21T19:01:26ZApplying Boundary Condition to ODE45Hi all,
I have a set of coupled differential equations which are readily arranged to be solved on ode45 in a domain [0 L]. However, all the boundary conditions of the differential equations are given at x=L instead of x=0. I cannot enforce these BCs to my problem using MATLAB. How can i accomplish that ? (I would like to solve set of ODEs using 4th order Runge Katta Method)
Kind RegardsOguz Altunkashttps://nl.mathworks.com/matlabcentral/profile/authors/14673472-oguz-altunkastag:nl.mathworks.com,2005:Question/4576852019-04-21T18:37:49Z2019-04-21T19:00:22ZHow to randomly choose 5% of a matrix to be of value 1.I have a 256 x 256 matrix which has value 1 inside a small square 20 x 20 around the center, and zero elsewhere. I need to randomly choose say 5% elsewhere to be 1 also. How do I go about this?
Thank you.Gideon Idumahhttps://nl.mathworks.com/matlabcentral/profile/authors/13428802-gideon-idumahtag:nl.mathworks.com,2005:Question/14272011-02-16T09:53:30Z2019-04-21T19:00:11ZWhat frustrates you about MATLAB?I love MATLAB. It is so quick and easy to write software to do what you want. It has excellent debugging and profiling tools. It is cross platform, making code easy to share (assuming the other people have forked out for the not-so-cheap license). It has interfaces to other software.
However, there are some things about it that irk me. I'd like to hear from other people what things annoy them about MATLAB.Oliver Woodfordhttps://nl.mathworks.com/matlabcentral/profile/authors/1073021-oliver-woodfordtag:nl.mathworks.com,2005:Question/4387652019-01-08T13:24:43Z2019-04-21T18:58:34ZCalculate slope of a discrete pointsHi all,
Can anyone please help me to find the instantaneous gradient (slope) at each points from the following datasets.
data=[
% X Y
%===================
0.7761 0.5715
0.794 0.5729
0.8117 0.5744
0.8292 0.5762
0.8465 0.5782
0.8637 0.5804
0.8807 0.5828
0.8977 0.5853
0.9144 0.5879
0.9311 0.5907
0.9477 0.5937
0.9641 0.5968
0.9805 0.6
0.9967 0.6033
1.0129 0.6067
1.0289 0.6103
1.0449 0.6139
1.0608 0.6176
1.0767 0.6215
1.0924 0.6254
1.1081 0.6294
1.1238 0.6334
1.1393 0.6376
1.1548 0.6418
1.1703 0.6461
1.1857 0.6505
1.201 0.6549
1.2163 0.6593
1.2316 0.6639
1.2468 0.6685
1.2619 0.6731
1.277 0.6778
1.2921 0.6825
1.3071 0.6873
1.3221 0.6921
1.3371 0.697
1.352 0.7019
1.3669 0.7069
1.3818 0.7119
1.3966 0.7169
1.4114 0.722
1.4262 0.727
1.441 0.7322
1.4557 0.7373
1.4704 0.7425
1.4851 0.7477
1.4997 0.753
1.5143 0.7583
1.5289 0.7635
1.5435 0.7689
1.5581 0.7742
1.5726 0.7796
1.5872 0.785
1.6017 0.7904
1.6162 0.7958
1.6307 0.8013
1.6451 0.8067
1.6596 0.8122
1.674 0.8178
1.6884 0.8233
1.7028 0.8288
1.7172 0.8344
1.7315 0.84
1.7459 0.8456
1.7602 0.8512
1.7746 0.8568
1.7889 0.8624
1.8032 0.8681
1.8175 0.8737
1.8318 0.8794
1.8461 0.8851
1.8603 0.8908
1.8746 0.8965
1.8888 0.9023
1.9031 0.908
1.9173 0.9137
1.9315 0.9195
1.9457 0.9253
1.9599 0.931
1.9741 0.9368
1.9883 0.9426
2.0025 0.9484
2.0166 0.9543
2.0308 0.9601
2.0449 0.9659
2.0591 0.9718
2.0732 0.9776
2.0874 0.9835
2.1015 0.9893
2.1156 0.9952
2.1297 1.0011
2.1438 1.007
2.1579 1.0128
2.172 1.0187
2.1861 1.0247
2.2002 1.0306
2.2143 1.0365
2.2284 1.0424
2.2425 1.0483
2.2565 1.0543];
The plot of the dataset is shown below
I have calculated the slope based on the two neighboring points, the results is copied below.
the gradient (m) is calculated using the following formula:
and the angle is just the arc-tan of the result.
Now, is it possible to obtain the instantaneous slope (gradient) at each point without using any curve-fitting to find the equation of the dataset? How can we do this numerically?
out =[
% X Y m atan atandeg
%================================================================
0.7761 0.5715
0.794 0.5729 0.078212291 0.078053394 4.472130064
0.8117 0.5744 0.084745763 0.084543756 4.844000375
0.8292 0.5762 0.102857143 0.102496699 5.872628281
0.8465 0.5782 0.115606936 0.115096 6.594515032
0.8637 0.5804 0.127906977 0.127216217 7.288952324
0.8807 0.5828 0.141176471 0.14024961 8.035710711
0.8977 0.5853 0.147058824 0.146012258 8.365886124
0.9144 0.5879 0.155688623 0.154448697 8.849258471
0.9311 0.5907 0.167664671 0.166119551 9.517949161
0.9477 0.5937 0.180722892 0.178793055 10.24408745
0.9641 0.5968 0.18902439 0.186820161 10.70400675
0.9805 0.6 0.195121951 0.192700759 11.04094018
0.9967 0.6033 0.203703704 0.200954264 11.51383118
1.0129 0.6067 0.209876543 0.206873949 11.85300417
1.0289 0.6103 0.225 0.221314442 12.68038349
1.0449 0.6139 0.225 0.221314442 12.68038349
1.0608 0.6176 0.232704403 0.228635393 13.09984308
1.0767 0.6215 0.245283019 0.240534248 13.78159724
1.0924 0.6254 0.248407643 0.243479414 13.95034281
1.1081 0.6294 0.25477707 0.249469651 14.29355811
1.1238 0.6334 0.25477707 0.249469651 14.29355811
1.1393 0.6376 0.270967742 0.264613602 15.16124258
1.1548 0.6418 0.270967742 0.264613602 15.16124258
1.1703 0.6461 0.277419355 0.270614072 15.50504418
1.1857 0.6505 0.285714286 0.278299659 15.9453959
1.201 0.6549 0.287581699 0.280025283 16.04426686
1.2163 0.6593 0.287581699 0.280025283 16.04426686
1.2316 0.6639 0.300653595 0.292056315 16.73359422
1.2468 0.6685 0.302631579 0.293869335 16.83747263
1.2619 0.6731 0.304635762 0.295704342 16.94261077
1.277 0.6778 0.311258278 0.30175322 17.28918598
1.2921 0.6825 0.311258278 0.30175322 17.28918598
1.3071 0.6873 0.32 0.309702945 17.74467163
1.3221 0.6921 0.32 0.309702945 17.74467163
1.3371 0.697 0.326666667 0.315738603 18.09048937
1.352 0.7019 0.32885906 0.317718318 18.20391871
1.3669 0.7069 0.33557047 0.323762624 18.55023193
1.3818 0.7119 0.33557047 0.323762624 18.55023193
1.3966 0.7169 0.337837838 0.325799115 18.66691427
1.4114 0.722 0.344594595 0.331851221 19.01367439
1.4262 0.727 0.337837838 0.325799115 18.66691427
1.441 0.7322 0.351351351 0.337878188 19.35899418
1.4557 0.7373 0.346938776 0.333945072 19.13364321
1.4704 0.7425 0.353741497 0.340004105 19.48080023
1.4851 0.7477 0.353741497 0.340004105 19.48080023
1.4997 0.753 0.363013699 0.348220949 19.95159069
1.5143 0.7583 0.363013699 0.348220949 19.95159069
1.5289 0.7635 0.356164384 0.342155885 19.60408815
1.5435 0.7689 0.369863014 0.354259423 20.29756977
1.5581 0.7742 0.363013699 0.348220949 19.95159069
1.5726 0.7796 0.372413793 0.356501385 20.42602476
1.5872 0.785 0.369863014 0.354259423 20.29756977
1.6017 0.7904 0.372413793 0.356501385 20.42602476
1.6162 0.7958 0.372413793 0.356501385 20.42602476
1.6307 0.8013 0.379310345 0.362544237 20.77225468
1.6451 0.8067 0.375 0.35877067 20.55604522
1.6596 0.8122 0.379310345 0.362544237 20.77225468
1.674 0.8178 0.388888889 0.370891289 21.25050551
1.6884 0.8233 0.381944444 0.364845007 20.90407908
1.7028 0.8288 0.381944444 0.364845007 20.90407908
1.7172 0.8344 0.388888889 0.370891289 21.25050551
1.7315 0.84 0.391608392 0.373251365 21.38572793
1.7459 0.8456 0.388888889 0.370891289 21.25050551
1.7602 0.8512 0.391608392 0.373251365 21.38572793
1.7746 0.8568 0.388888889 0.370891289 21.25050551
1.7889 0.8624 0.391608392 0.373251365 21.38572793
1.8032 0.8681 0.398601399 0.379300105 21.73229519
1.8175 0.8737 0.391608392 0.373251365 21.38572793
1.8318 0.8794 0.398601399 0.379300105 21.73229519
1.8461 0.8851 0.398601399 0.379300105 21.73229519
1.8603 0.8908 0.401408451 0.381719969 21.87094317
1.8746 0.8965 0.398601399 0.379300105 21.73229519
1.8888 0.9023 0.408450704 0.387770172 22.21759427
1.9031 0.908 0.398601399 0.379300105 21.73229519
1.9173 0.9137 0.401408451 0.381719969 21.87094317
1.9315 0.9195 0.408450704 0.387770172 22.21759427
1.9457 0.9253 0.408450704 0.387770172 22.21759427
1.9599 0.931 0.401408451 0.381719969 21.87094317
1.9741 0.9368 0.408450704 0.387770172 22.21759427
1.9883 0.9426 0.408450704 0.387770172 22.21759427
2.0025 0.9484 0.408450704 0.387770172 22.21759427
2.0166 0.9543 0.418439716 0.396300932 22.70637084
2.0308 0.9601 0.408450704 0.387770172 22.21759427
2.0449 0.9659 0.411347518 0.390250283 22.35969418
2.0591 0.9718 0.415492958 0.39379062 22.56254053
2.0732 0.9776 0.411347518 0.390250283 22.35969418
2.0874 0.9835 0.415492958 0.39379062 22.56254053
2.1015 0.9893 0.411347518 0.390250283 22.35969418
2.1156 0.9952 0.418439716 0.396300932 22.70637084
2.1297 1.0011 0.418439716 0.396300932 22.70637084
2.1438 1.007 0.418439716 0.396300932 22.70637084
2.1579 1.0128 0.411347518 0.390250283 22.35969418
2.172 1.0187 0.418439716 0.396300932 22.70637084
2.1861 1.0247 0.425531915 0.402321098 23.05130092
2.2002 1.0306 0.418439716 0.396300932 22.70637084
2.2143 1.0365 0.418439716 0.396300932 22.70637084
2.2284 1.0424 0.418439716 0.396300932 22.70637084
2.2425 1.0483 0.418439716 0.396300932 22.70637084
2.2565 1.0543 0.428571429 0.404891786 23.19859051];BeeTiawhttps://nl.mathworks.com/matlabcentral/profile/authors/318942-beetiawtag:nl.mathworks.com,2005:Question/1795992015-02-21T19:58:29Z2019-04-21T18:56:04ZHow can I calculate the slope of a line given two points?I need a function which can output the slope of a 2D line given two points. Ofcourse, I could just use m = (y2-y1)/(x2-x1), however, I have a long list of points/lines which I need to find the slope of and I don't believe this would be the most efficient method.
Something similar to the pdist2(point_a, point_b) function which I've previously used to find the distance between two points would be ideal.
Thanks in advance.
Neal Younghttps://nl.mathworks.com/matlabcentral/profile/authors/6204447-neal-youngtag:nl.mathworks.com,2005:Question/4575212019-04-20T12:04:37Z2019-04-21T18:52:17Zfinding the slope and plotting it in graphi need to find the x,y points and plot those points finding the slope making a line in x,y plane. How can i get it automatically sisir regmihttps://nl.mathworks.com/matlabcentral/profile/authors/12162188-sisir-regmitag:nl.mathworks.com,2005:Question/4576872019-04-21T18:51:01Z2019-04-21T18:51:01Zdecimal specification change in a tableI have my data in a table that the user input as a matrix [a 'time', 'temp' b; c,d]. and assigned the first column to time, and sec column be temperature.
a=table(Time,temp)
And the time variable values was converted from min to hours, but how can I make the time variable show to 2 decimal places in the table. mat geekhttps://nl.mathworks.com/matlabcentral/profile/authors/9600941-mat-geektag:nl.mathworks.com,2005:Question/4575802019-04-20T21:01:51Z2019-04-21T18:50:41Zlimits are too large i have parametrized surface equation T(u,v)=e^(u^2+v^2) i + ln(2*v) j + tan(5*u) k . I used this code to plot it in 3D but it gives error 'limits are too large '. can yu help me pls.
clc; clear all ;
M = 100 ; N = 100 ;
uinf = 100 ;
u = linspace(0,uinf,M) ;
v = linspace(0,2*pi,N) ;
[U V] = meshgrid(u,v) ;
X = exp(U.^2+V.^2) ;
Y = log(2.*V) ;
Z = tan(5*U) ;
surf(X,Y,Z) ;Kuatra Patilhttps://nl.mathworks.com/matlabcentral/profile/authors/15291254-kuatra-patiltag:nl.mathworks.com,2005:Question/4576692019-04-21T15:14:31Z2019-04-21T18:49:49ZHow can I build a Polynomial Equation from an array without using Polyval/PolyfitSo, I've completed my homework assignment and it works great! But my Professor said that I couldn't use polyval or poly fit for Polynomial Regression.
So, I've started a new code, and I understand what to do to make it work the long way (i.e. without the poly functions) but I need to build a code that takes the data from a 28x2 matrix and build the polynomial equation, and I'd rather not just code in X'.^27,X^26,X^25...... etc.
I'm sure it's an easy code to make, but I've spent a couple days digging through the internet and pretty much everything tells me to use the poly functions.
My original code is the first set of code, my new code..... minus the power function is the second set of code and all the bells and whistles to find r^2 and plot in lenear,quadratic and cubic form.
function O=PolyLeast(x,y,A)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Establish index so program will solve to a degree based on matrix length %
fid=fopen('data-1.txt','rt');
C=textscan(fid,'%f%f','MultipleDelimsAsOne',true,'Delimiter',...
'[;','HeaderLines',1);
fclose(fid);
A=cell2mat(C);
x=A(:,1);
y=A(:,2);
%a=str2double(inputdlg({'Degree'},...
% 'Input desired degree to solve for',[1 75;]));
n=length(x);
plot(x,y,'o','MarkerSize',6,'MarkerFaceColor','b')
hold on
p1=polyfit(x,y,1);
f1=polyval(p1,x);
p2=polyfit(x,y,2);
f2=polyval(p2,x);
p3=polyfit(x,y,3);
f3=polyval(p3,x);
pn=polyfit(x,y,n);
fn=polyval(pn,x);
plot(x,f1,'r','LineWidth',2)
plot(x,f2,'m','LineWidth',2)
plot(x,f3,'k','LineWidth',2)
legend('Original Data','Linear Data','Quadratic Data','Cubic Data')
title('Polynomial Least Square')
hold off
disp('--------------------------------------------------------------------')
disp('Calculated y-Coefficients')
disp('--------------------------------------------------------------------')
Q=[f1,f2,f3,fn];
R={'Linear','Quadratic','Cubic','n-th degree'};
M=[R;num2cell(Q)];
disp(M)
disp('--------------------------------------------------------------------')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Solves for Coefficient of Determination and Reports to Command Window %
disp('Coefficient of Determination and Regression Polynomials')
disp('--------------------------------------------------------------------')
F=p1(1)*x+p1(2);
Fy=y-F;
Xpy=sum(Fy.^2);
XPxy=(length(y)-1)*var(y);
O=1-Xpy/XPxy;
fprintf('Linear Coefficient of Determination= %f\n',O);
formatspec='Linear Regression Polynomial: y=%5.3f(x)+%5.3f\n';
fprintf(formatspec,p1(1),p1(2));
F1=p2(1)*x.^2+p2(2)*x+p2(3);
F1y=y-F1;
Xpy1=sum(F1y.^2);
Xpxy1=(length(y)-1)*var(y);
O1=1-Xpy1/Xpxy1;
fprintf('Quadratic Coefficient of Determination= %f\n',O1);
formatspec='Quadratic Regression Polynomial: y=%5.3f(x^2)+%5.3f(x)+%5.3f\n';
fprintf(formatspec,p2(1),p2(2),p2(3));
F2=p3(1)*x.^3+p3(2)*x.^2+p3(3)*x+p3(4);
F2y=y-F2;
Xpy2=sum(F2y.^2);
Xpxy2=(length(y)-1)*var(y);
O2=1-Xpy2/Xpxy2;
fprintf('Cubic Coefficient of Determination= %f\n',O2);
formatspec='Cubic Regression Polynomial: y=%5.3f(x^3)+%5.3f(x^2)+%5.3f(x)+%5.3f\n';
fprintf(formatspec,p3(1),p3(2),p3(3),p3(4));
Fn=pn(1)*x.^27+pn(2)*x.^26+pn(3)*x.^25+pn(4)*x.^24;
Fny=y-Fn;
Xpy3=sum(Fny.^2);
Xpxy3=(length(y)-1)*var(y);
O3=1-Xpy3/Xpxy3;
fprintf('n-th Coefficient of Determination= %f\n',O3);
formatspec=...
'n-th order Regression Polynomial:\n y=%7.7e(x^27)+%7.7e(x^26)+%7.5e(x^25)+%7.5e(x^24)\n';
fprintf(formatspec,pn(1),pn(2),pn(3),pn(4));
disp('And so on for 23 more iterations')
disp('--------------------------------------------------------------------')
-----------------------------------------new unfinished code below -----------------------------------------------------------------
fid=fopen('data-1.txt','rt');
C=textscan(fid,'%f%f','MultipleDelimsAsOne',true,'Delimiter',...
'[;','HeaderLines',1);
fclose(fid);
A=cell2mat(C);
x=A(:,1);
y=A(:,2);
n=length(x);
X=[ones(n,1) x(:)];
f=% Power function goes here
a=(X'.*X)\(X'.*f(:));
plot(x,y,'.b')Terry Poolehttps://nl.mathworks.com/matlabcentral/profile/authors/12282800-terry-pooletag:nl.mathworks.com,2005:Question/4573982019-04-19T16:42:09Z2019-04-21T18:49:28ZHelp with nested structureHello,
I use Matlab for my data analysis. I did a script in which, as output, I obtain a nested structure organized by sublevels. Now I would like to access all my files and analyse them by groups.
So to say.... I would like to select only some of them and extrapolate some parameters from them, then I would like to do this for a different group of them and so on...
I have a structure array like this:
For example, I would like to calculate the mean of each column of the field Currents for all the levels "file_...." that have in the field "FolderLev_3" the value pH8 or things like this...
Is there an easy way to do it?
Thank you very much,
ManuelManuel Arcangelettihttps://nl.mathworks.com/matlabcentral/profile/authors/10449686-manuel-arcangelettitag:nl.mathworks.com,2005:Question/4576862019-04-21T18:48:47Z2019-04-21T18:48:47ZDownload stock price from a reliable APIHello,
I am new to matlab.
I wondering if Matlab can import stock price data from any API , just like Python does
Thank youBai chenhttps://nl.mathworks.com/matlabcentral/profile/authors/14210816-bai-chentag:nl.mathworks.com,2005:Question/4575972019-04-20T23:10:47Z2019-04-21T18:47:45ZHow to use polyfit to get the difference out of two functions?Hi
I have two datasets (X,Y). For every value of Y that corresponds to a value of X.
I am thinking of applying a polyfit command to get the best curve fitting for the data, and as a result I will come up with a function (slope+intercept).
How do I find the difference between those two functions? What command do I apply to subtract Function A from Function B?
Stelios Fanourakishttps://nl.mathworks.com/matlabcentral/profile/authors/10865530-stelios-fanourakistag:nl.mathworks.com,2005:Question/4576662019-04-21T15:07:11Z2019-04-21T18:42:52ZFrequency scale in fft after zero filling (odd/even number of data)Product: Matlab 2017b
If we have data set "A" which consists of time versus light absorbance.There is another set of data "B". Both data are sampled at the same rate Fs.
The two sets are to be divided in the frequency domain. C= fft(A)/fft(B). Prior to division, in order to make the length of A and B equal, zero filling in done or one can use the fft(X, n). Sometimes there are odd number of data points and sometimes, even in A and B after zero filling.
In such a case, how do we make a frequency axis for C in MATLAB? The number of original data points have changed after zero filling in either A or B.
Example: The key question is, assume we had initially 1000 data points in A, and 800 data points in B. Let us use C= fft (A, 1024) ./ fft(B, 1024). We get a new vector C. How should we make a frequency scale for C now given that the number of data points were changed.
Thanks.Farooqhttps://nl.mathworks.com/matlabcentral/profile/authors/9766874-farooqtag:nl.mathworks.com,2005:Question/4576792019-04-21T18:19:51Z2019-04-21T18:39:17Zparametrized surface equation - result i get is different than i expecti have parametrized surface equation T(u,v)=e^(u^2+v^2) i + ln(2*v) j + tan(5*u) k . result is not what i expected actually can you help me please?
clc; clear all ;
M = 10 ; N = 10 ;
uinf = 5 ;
u = linspace(0,uinf,M) ;
v = linspace(0,2*pi,N) ;
[U V] = meshgrid(u,v) ;
X = exp(U.^2+V.^2) ;
Y = log(2.*V) ;
Z = tan(5*U) ;
surf(X,Y,Z) ;Kuatra Patilhttps://nl.mathworks.com/matlabcentral/profile/authors/15291254-kuatra-patiltag:nl.mathworks.com,2005:Question/4576842019-04-21T18:32:13Z2019-04-21T18:32:13ZWater flow in a bend pipe?Hello Everyone,
I am a beginner in MATLAB. I am trying to simulate water flow in bend converging steel pipe. Friction is considered. Can someone please guide me or tell, where can I find similar tutorials to write the code? I understand the theory part. But I don’t have the knowledge to write in code.
Cheers.Abeed Hassan Nurhttps://nl.mathworks.com/matlabcentral/profile/authors/10555567-abeed-hassan-nurtag:nl.mathworks.com,2005:Question/4576832019-04-21T18:31:49Z2019-04-21T18:31:49ZHow do you verify and show independence/dependence of a pair of uniform random variables?If is a subset of and is a random variable. I have two variables and . being if in subset , and if not in . ~ Let and determine if this pair is independent. Verify your claim using simulation in Matlab.
I determined that this pair is not independent because and similarly for . However, . Now I am quite unfamiliar with MATLAB. To verify, do I call on many times and tally how many times the values fall within the bounds of each random variable and make a histogram? Or do I make a plot of various values ranging from and show how the two random variables act at each value? Any type of suggestions will help get me started! I've searched forums for examples, but with no luck of understanding. I do have about 5 different pairs of uniform random variables with same setup, some being independent and some not. I must run and verify each pair. Patricia Serrethttps://nl.mathworks.com/matlabcentral/profile/authors/13776714-patricia-serrettag:nl.mathworks.com,2005:Question/4572852019-04-18T23:58:53Z2019-04-21T18:24:46Zhow can we create database with .mat files ?hello
i have .mat files
its contain heart beat
i want to add it to database and then link it to matlab
how i can add these type of file to database ?
I've attached here one of them here
Rahaf mutlaqhttps://nl.mathworks.com/matlabcentral/profile/authors/14458701-rahaf-mutlaqtag:nl.mathworks.com,2005:Question/4576762019-04-21T17:28:37Z2019-04-21T18:24:11Zvectors must be the same lengthI have position vector
r(t)=<t , t^2 , 2>,
I have to plot it using plot3 function and also plot tangent at the point P(-1 , 1, 2) but I cant figure it out. Can you help me please?
t = 0:pi/50:10*pi;
st = t;
ct = t.^2;
figure
plot3(st,ct,2)Kuatra Patilhttps://nl.mathworks.com/matlabcentral/profile/authors/15291254-kuatra-patiltag:nl.mathworks.com,2005:Question/4576312019-04-21T07:38:35Z2019-04-21T18:23:47ZSerial interrupt to automatically update edit boxes, I want to design a GUI that automatically updates an edit box every time it receives new data over the serial port. I cannot figure out the proper syntax GUIDE/Matlab uses to pass arguments to functions or what arguments are necessary.
I have looked https://www.mathworks.com/matlabcentral/answers/280169-gui-serial-communication-interrupt-function but the syntax makes no sense to me and I can't find documentation that explains it past the basic user level.
% --- Executes on button press in Connect.
function Connect_Callback(hObject, eventdata, handles)
% hObject handle to Connect (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
instrreset
handles.s = serial('COM9');
handles.s.ReadAsyncMode = 'continuous';
handles.BytesAvailableFcnMode = 'byte';
handles.s.BytesAvailableFcnCount = 1;
handles.s.BytesAvailableFcn = @Serial_int_Fcn;
set(handles.s,'BaudRate',115200);
fopen(handles.s);
function Serial_int_Fcn (hObject, eventdata, handles)
%
i = 1;
Serial_in = strsplit(fscanf(hObject),';') ? Why does this work and not handles.s as argument?
ADC_raw1(i) = str2double(Serial_in(1,1)) **Error - Not enough input arguments.
Filter_out(i) = str2double(Serial_in(1,2))
WSB_voltage(i) = str2double(Serial_in(1,3))
AmbientT(i) = str2double(Serial_in(1,4))
set(handles.Loadcell1,'String',ADC_raw1(i)) **Error - Not enough input arguments.
set(handles.Loadcell2,'String',ADC_raw1(i))
set(handles.Loadcell3,'String',ADC_raw1(i))
set(handles.TotalWeight,'String',Filter_out(i)+Filter_out(i)+Filter_out(i))
set(handles.AmbientT,'String',AmbientT(i))
set(handles.FluidT,'String',WSB_voltage(i))
i = i + 1;
Corne van Zylhttps://nl.mathworks.com/matlabcentral/profile/authors/11043221-corne-van-zyltag:nl.mathworks.com,2005:Question/4576732019-04-21T16:26:05Z2019-04-21T18:18:26ZIs there a way to add constraints (other than nonnegativity) on ode15s?I am using ode15s to solve a DAE system describing oil-water flow in a pipe. Some of the variables in the solution are physically unrealistic, and I was wondering whether there is a way to add specific constraints?
Thank you.Georgios Pasiashttps://nl.mathworks.com/matlabcentral/profile/authors/11127140-georgios-pasiastag:nl.mathworks.com,2005:Question/4576782019-04-21T18:07:42Z2019-04-21T18:12:33ZAudio Toolbox: Error Message - Undefined function or variable 'reverberator'.Why do I get this message?
The 'reverberator' should be part of the Audio Toolbox?Hartmut Schröderhttps://nl.mathworks.com/matlabcentral/profile/authors/4116415-hartmut-schrodertag:nl.mathworks.com,2005:Question/4085912018-07-03T14:13:08Z2019-04-21T18:04:52ZHow to save each iteration of a loop into the same sheet of an Excel spreadsheet using a mac and the function Mac OSX friendly function xlwriteHow I am trying to write the outputs of each iteration of each loop to the same spreadsheet but in different sheets.
Thus if i have 5 iterations, I want the output of the same iteration to be saved to sheet1, the output o the second iteration . be saved to sheet2.....etc..etc
Note I am using a macbook, and this a custom function called xlwrite which works on a mac osx system.Charleshttps://nl.mathworks.com/matlabcentral/profile/authors/5506466-charlestag:nl.mathworks.com,2005:Question/4576542019-04-21T13:14:33Z2019-04-21T17:57:32ZHow do I extrapolate a point from a generated graph.So this is the question
The velocity (ms-1) of a car is measured every minute for 24 minutes and recorded as:
vel = [0 .45 1.79 4.02 7.15 11.18 16.09 21.90 29.05 29.05
29.05 29.05 29.05 22.42 17.9 17.9 17.9 17.9 14.34 11.01 8.9
6.54 2.03 0.55 0];
How long did the object take to pass 250m?
I have successfully generated a time against cummulative distance graph, but I'm stuck now.
Many thanksCheng-Han Yanghttps://nl.mathworks.com/matlabcentral/profile/authors/14131871-cheng-han-yangtag:nl.mathworks.com,2005:Question/19712011-02-24T17:31:12Z2019-04-21T17:56:06ZWhen using ODE45 (or similar functions), what is the benefit of using anonymous functions over passing additional parameters as trailing arguments?When I want to solve a differential equation with additional parameters
function dx = myfun(t, x, p1, p2)
...
using <http://www.mathworks.com/help/matlab/ref/ode45.html |ode45|>, I used to call it by passing the parameters as trailing arguments:
[T, Y] = ode45(@myfun, ts, x0, [], p1, p2);
Now, the <http://www.mathworks.com/help/matlab/math/bsgprpq-5.html documentation> recommends that I use anonymous functions instead:
[T, Y] = ode45(@(t,x) myfun(t, x, p1, p2), ts, x0);
What is the benefit of the latter method over the former?jirohttps://nl.mathworks.com/matlabcentral/profile/authors/869871-jirotag:nl.mathworks.com,2005:Question/4576522019-04-21T12:58:04Z2019-04-21T17:53:30Zhow to solve "Dot Indexing not supported for this type of variable" error I trained a Faster R-CNN network by following the trainfasterrcnn page but i am unable to test the network as i get the error below
"Dot indexing is not supported for variables of this type.
Error in fasterRCNNObjectDetector/parseDetectInputs (line 713)
networkInputSize = this.Network.Layers(this.LayerIndices.ImageLayerIdx).InputSize;
Error in fasterRCNNObjectDetector/detect (line 441)
params = this.parseDetectInputs(I, varargin{:});"
% load training data
load('FiveClassesTraining.mat');
TestImg = imread(trainingData.Imagefilename{70});
figure
imshow(TestImg)
% Run the detector
[bboxes,scores] = detect(detector,TestImg);
% Annotate detections in the image.
TestImg = insertObjectAnnotation(TestImg,'rectangle',bboxes,scores);
figure
imshow(TestImg)
Zainab Olalekanhttps://nl.mathworks.com/matlabcentral/profile/authors/12643982-zainab-olalekantag:nl.mathworks.com,2005:Question/4575822019-04-20T21:10:51Z2019-04-21T17:49:35ZConverting user input char to an array As part of my university matlab module i was assigned to do an assigment from one of 4 options. I'm on a bit of a road block, part of code is requesting the user to type in 6 numbers for a lottery game, being that this data is recorded as a char i want to convert this to a numerial array (matrix). I have tried the following with no luck.
player_numbers = input ('Please enter your number: ','s');
player_lotto_numbers = str2num(player_numbers);
Mehmet Saglamhttps://nl.mathworks.com/matlabcentral/profile/authors/12224026-mehmet-saglamtag:nl.mathworks.com,2005:Question/4576402019-04-21T09:39:21Z2019-04-21T17:49:19Zhow can I save the real time values in Workspace?Can someone explain and help me? How can I save and update the value of EyePositions from workspace into excel?
Below is the code I had tried...But it only can save the initial value of eyepositions.
% Hough Transform
[centers, radii, metric] = imfindcircles(eyesImage,[floor(r-r/4) floor(r+r/4)],'Method','PhaseCode','ObjectPolarity','dark', 'Sensitivity', 0.95);
[M,I] = sort(radii, 'descend');
eyesPositions = centers;
% Displays full image in gray with Eye detection
subplot(2,2,2);
subimage(eyesImage);
hold on;
title('Eye Image');
%draw all the region that eye pupil
viscircles(centers, radii,'EdgeColor','b','Linestyle','--');
if ~isempty(centers)
disF=(centers(1));
disL=abs(0-disF); %distance from left edge to center point
disR=abs(bboxeyes(1,3)-disF);%distance from right edge to center point
subplot(2,2,4);
title('Direction');
if disL>disR+12 && disL>disR
subimage(right);
else if disR>disL && disR>disL-12
subimage(left);
else
subimage(straight);
end
end
filename = 'testdata.xlsx';
Results_Values=[centers];
Row_Num =1;
xlswrite(filename,centers,'Sheet1',['A' num2str(Row_Num)]);
winopen('testdata.xlsx');
end
end
else
subplot(2,2,4);
subimage(noface);
endchajhttps://nl.mathworks.com/matlabcentral/profile/authors/14268499-chajtag:nl.mathworks.com,2005:Question/4576252019-04-21T06:13:08Z2019-04-21T17:46:00Zget RGB data from imageI was working on some code for a small assignment and can't seem to figure out why I can't get my bright vector to come out as [251,251,251] using this attached picture. The RGB values for the white section of the image are all 251.
picture = imread('ColorWheel.png')
[a,b,c] = size(picture);
bright = [0,0,0];
for y = 1:b
for x = 1:a
if picture(x,y,1) >= bright(1) && picture(x,y,2) >= bright(2) && picture(x,y,3) >= bright(3)
bright(1) = picture(x,y,1);
bright(2) = picture(x,y,2);
bright(3) = picture(x,y,3);
end
endSorin Peñahttps://nl.mathworks.com/matlabcentral/profile/authors/13317590-sorin-penatag:nl.mathworks.com,2005:Question/4576512019-04-21T12:56:12Z2019-04-21T17:44:05ZPatch - Not enough input argumentsI am trying to create a rectangle where the sides all have different colors. I found another question asking about this, but the answer there didn't seem to work. This is the code I'm trying to run:
X = [0,1,1,0];
Y = [0,0,2,2];
C = [1,0,0;0,1,0;0,0,1;1,1,0];
patch(X,Y,'FaceVertexCData',C,'EdgeColor','flat','FaceColor','none','LineWidth',2)
Yet I always get this error message:
Error using patch
Not enough input arguments.
I don't understand what inputs are missing here. How do I fix this?Axel Sopphttps://nl.mathworks.com/matlabcentral/profile/authors/14513431-axel-sopptag:nl.mathworks.com,2005:Question/4553652019-04-09T19:04:56Z2019-04-21T17:32:17ZTimerFcn loop for arduino hi
I want to read some data from arduino with timer object and I want to read these data each 0.01 second as input datas and calculate datas and give output datas
the code that I want to use is:
t=timer('Period',0.01,'ExecutionMode','fixedRate');
t.TimerFcn=@(function1);
start(t)
function [T]=function1(x)
x=readCount(encoder);
k=5*x;
T=k+3;
end
is it correct?john whitehttps://nl.mathworks.com/matlabcentral/profile/authors/10514494-john-whitetag:nl.mathworks.com,2005:Question/4573472019-04-19T10:25:15Z2019-04-21T17:23:29ZWhy my MATLAB R2019a keeps busy status?Hello, my matlab just fails to do any calculation with its status alway "busy" like this, and I can't figure out why. My matlab is a genuine one. Looking forwards to your help, thx!
P.S. I once uninstalled my MATLAB 2017 once for the 2019 version, but it was too large, so I reinstall the 2017 version, and this is what happening now. Ctrl+C just doesn't work and CPU doesn't seem to be occupied
Mo Haoyuhttps://nl.mathworks.com/matlabcentral/profile/authors/14432015-mo-haoyutag:nl.mathworks.com,2005:Question/4576702019-04-21T15:52:28Z2019-04-21T17:20:56ZSimulation Markov Chain.hello,
i want to to know how can i write a programm to compute a realization of a MC for a given stochastic matrix(9x9) and initial distribution P[X0 =0] for five realizations of length 20 for example.
Thank you so much !ayoub bouayabenhttps://nl.mathworks.com/matlabcentral/profile/authors/15336961-ayoub-bouayaben