https://ch.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2020-11-27T17:17:28Ztag:ch.mathworks.com,2005:Question/6644832020-11-27T04:52:29Z2020-11-27T17:17:28ZCant understand how the values are storedA = load('r08_edfm.mat');
B = load('r08_edfm.mat');
d = A.val(1,:);
d_T = d';
input_channel = 3;
noisy_sig = B.val(input_channel,:);
noisy_sig_T = noisy_sig'
at workspace im getting these values
Rehman Tanimhttps://ch.mathworks.com/matlabcentral/profile/authors/17846837tag:ch.mathworks.com,2005:Question/6654832020-11-27T17:17:03Z2020-11-27T17:17:03ZCan anyone help me to write code for ROF to denoise imageshi
I have some ultrasound images, i would like to perform ROF for denoising. Please help to write code for thatMINO GEORGEhttps://ch.mathworks.com/matlabcentral/profile/authors/18929086tag:ch.mathworks.com,2005:Question/6654782020-11-27T17:16:32Z2020-11-27T17:16:32ZHow can I call multiple M functions?Hello guys,
I'm trying to run the function "WattsStrogatz" 100 times and in each iteration I want to run the function "Test_Healing" 300 times, kindly see the attached screenshots. When I run my script, MATLAB says that variable G is not defined. Could you please teach me how to do it.
Thanks!
Waseem AL Aqqadhttps://ch.mathworks.com/matlabcentral/profile/authors/4628443tag:ch.mathworks.com,2005:Question/5674412020-07-19T13:49:00Z2020-11-27T17:16:21ZHow to crop circle from an image?Here I have have defined a circle using viscircles. Now i want to get the image inside the circle. How can I do that? I have tried it with impolygon but I have to crop the image for all the image in folder and turns out its really slow. Is there any way to do that?
im = imread('flower.jpg');
imshow(im);
[x,y] = getpts;
j = viscircles([x(1),y(2)], sqrt((x(1)-x(2))^2+(y(1)-y(2))^2));
Hardik Poudelhttps://ch.mathworks.com/matlabcentral/profile/authors/18714719tag:ch.mathworks.com,2005:Question/6654732020-11-27T17:14:43Z2020-11-27T17:14:43ZError :Converged to an infeasible point. fmincon stopped because the size of the current step is less than the value of the step size tolerance but constraints are not satisfied to within the value of the constraint tolerance. <stopping criteria deI want to minimize for wxo by means of fmincon, which can be calculated with a certain equation 'theta'. I have the nonlinear constraints:
function [c,ceq] = simple_constraints(wxo)
vxo=0;
vyo=1;
vzo=1;
wyo=0;
Rb=0.1155; %radius ball [m]
g=9.81;
a=0.83;
ez=0.84;
C1=1/(a+1);
C2=a*Rb/(a+1);
C3=ez;
c = [];
ceq= acos((C1*(vxo^2+vyo^2)+C2*(wyo*vxo-wxo*vyo))/(sqrt((C1*vxo+C2*wyo)^2+(C1*vyo-C2*wxo)^2)*sqrt(vxo^2+vyo^2)))-pi;
end
In which I want theta=acos((C1*....)) = pi. This is captured in the equality constraint as ceq = acos((C1*...))-pi;. I use this for the calculation of fmincon:
clear all;
close all;
clc
vxo=0;
vyo=1;
vzo=1;
wyo=0;
objective = @(wxo) (wxo)^2; %minimize wxo;
% initial guess
x0 = 10;
% variable bounds
lb = [];
ub = [];
% show initial objective
disp(['Initial Objective: ' num2str(objective(x0))])
% linear constraints
A = [];
b = [];
Aeq = [];
beq = [];
Rb=0.1155; %radius ball [m]
g=9.81;
a=0.83;
ez=0.84;
C1=1/(a+1);
C2=a*Rb/(a+1);
C3=ez;
% nonlinear constraints
nonlincon = @simple_constraints;
% optimize with fmincon
%[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN]
% = fmincon(FUN,X0,A,B,Aeq,Beq,LB,UB,NONLCON,OPTIONS)
options = optimoptions('fmincon', 'Algorithm','sqp', 'MaxIterations', 1000,'ConstraintTolerance', 1e-2, 'OptimalityTolerance', 1e-6, 'StepTolerance', 1e-12, 'MaxFunctionEvaluations', 5000);
wxo = fmincon(objective,x0,A,b,Aeq,beq,lb,ub,nonlincon,options);
% show final objective
disp(['Final Objective: ' num2str(objective(wxo))])
% print solution
disp('Solution')
disp(['min wx0^2 = ' num2str(wxo)])
But then I get the error:
Initial Objective: 100
Converged to an infeasible point.
fmincon stopped because the size of the current step is less than
the value of the step size tolerance but constraints are not
satisfied to within the value of the constraint tolerance.
<stopping criteria details>
Final Objective: 6.9676e-16
Solution
min wx0^2 = -2.6396e-08
I know that theta=pi for wxo=>10.43, and theta=0 for wxo<=10.43, but this isn't what comes out of my fmincon. I have no clue why this error is persisting. Changing the steptolerance didn't help. Can someome help me with this?Isabellehttps://ch.mathworks.com/matlabcentral/profile/authors/11725260tag:ch.mathworks.com,2005:Question/6635632020-11-26T12:15:40Z2020-11-27T17:12:01ZHow to trace the boundray of object in an image using MATLAB?Hi,
I want to trace the boundary of an object in an image.(the bended black part)
I am attaching the binarised image herewith.
My questions are:
when I use dim= size(I) inin the following code, it gives different size and when I type in dim = size(BW), it gives different pixel size, so which should I follow?
I = imread('flap2.png');
imshow(I);
dim = size(I)
secondly how can I define the row and coloumn using this size information in order to continue with bwtraceboundary , because when i use this command it gives me a following error:
Error using bwtraceboundary
Expected input number 1, BW, to be two-dimensional.
waiting for a kind response.
Regards
TayyabaTayyaba Banohttps://ch.mathworks.com/matlabcentral/profile/authors/20460465tag:ch.mathworks.com,2005:Question/6650482020-11-27T10:34:10Z2020-11-27T17:11:49ZProblem with creating matrixI'm trying to create a 36x36 matrix where each column has two 18x1 vectors stacked. The vectors correspond to deflections in both the y and z direction and were calculated by setting the loads in the y direction (1st potition) as a 1x18 vector where the first value is 1 and others zero ([1 0 0 0 0 ..]), the loads in the z direction were set all to zero with the same vector length.
For the second column of the matrix, the deflection in the y and z direction must be calculated by setting the loads in the z direction(still 1st position) as [0 1 0 0 0 ..] with the same 1x18 length, and the loads in the y direction were all zero.
The deflections in y and z are inside a for loop with 18 positions.
For the third column of the matrix, I need the deflections in y and z but setting the loads in the y direction(now 2nd position) to [0 0 1 0 0 ...] and the loads in z as zero. The forth column would correspond to the loads in the z directions as [0 0 0 1 0 0 ..] and loads in y zero.
Is there a way I could create this matrix with a for loop that changes where the value of "1" in the vectors for the loads is located? I'm trying to solve a vibrations problem involving a flexibility matrixMaria Sarcoshttps://ch.mathworks.com/matlabcentral/profile/authors/17943360tag:ch.mathworks.com,2005:Question/6653482020-11-27T15:40:30Z2020-11-27T17:11:41ZPopulating matrix with data from a tableHello .Sorry for this questions but I am not very familiar with the table function.I am attaching a csv file .I am reading this file which basically contains some stock prices for some days .I am trying to populate a matrix with the data .For some reason it looks really cumbersome to use the table function but it might be my stupidity.Before I was using textread,except I do not know in general how many names I have so is hard (or impossible) to do that.I have read the documentation for table but nothing seems to work!
so I do something like this
opts=detectImportOptions('ii.csv');
opts.VariableNamingRule = "preserve";
P=readtable('ii.csv',opts);
nDates=length(P(:,1);
nBlIds=length(P(1,:);
closes=nan*ones(nDates,nBlIds);
% here I write the date in different way
trDates=P(:,1);tradingDates=table2array(trDates);
formatOut='yyyymmdd';
Dates=str2num(datestr(tradingDates,formatOut));
No clue how to populate the columns using P.... All my attempts failed .Many thanks Mihai Mileahttps://ch.mathworks.com/matlabcentral/profile/authors/19575961tag:ch.mathworks.com,2005:Question/6640732020-11-26T21:14:57Z2020-11-27T17:10:42ZError message saying "Matrix dimensions must agree"Hi
Keep getting error message saying "Matrix dimensions must agree".
not too sure why this is.
any help would be greatly appriciated reuben alexanderhttps://ch.mathworks.com/matlabcentral/profile/authors/17790254tag:ch.mathworks.com,2005:Question/6654682020-11-27T17:07:20Z2020-11-27T17:07:20ZAutomated grouping of time series data using a sliding window of different lengthsI have an hourly time series for 30 days and want to group them into three different time periods but want to do it in an automated way. I want to start the window using 1 day and then keep increasing it so I have different time periods with changing window lengths. How can I do that?galadrielhttps://ch.mathworks.com/matlabcentral/profile/authors/15465138tag:ch.mathworks.com,2005:Question/6654382020-11-27T16:44:20Z2020-11-27T17:01:56ZIndexing of a size() objectHello,
If I have an array named arr, and run the following:
size(arr)(1)
then I get an error: "Indexing with parentheses '()' must appear as the last operation of a valid indexing expression."
However when adding an intermediate step:
s = size(arr);
s(1)
then everything runs as expected. So I don't have a practical problem to solve here, but was curious to know more about the reasons for that behavior, and when indexing should not be used.Adrian Valentehttps://ch.mathworks.com/matlabcentral/profile/authors/16926561tag:ch.mathworks.com,2005:Question/6654632020-11-27T17:01:34Z2020-11-27T17:01:34ZRead multiple images from folder and subfolder within a for loopHi,
I intend to read image files placed inside folder (.jpg) and subfolder (.bmp) within a for loop opeartion. Could someone please help me out with this ??
%%% Read from main folder%%% Read from main folder Read from main folder
for f = 1:1:1
if (f>=1) && (f<=9)
fname_strt = 'B0000' ;
elseif (f>=10) && (f<=99)
fname_strt='B000';
elseif (f>=100) && (f<=999)
fname_strt='B00';
else
fname_strt='B0';
end
fname_end = num2str(f);
fname = strcat(fname_strt,fname_end,'.jpg');
I=imread(fname);
G = imagesc(x,y,flipud(I));
G.AlphaData = 0.5;
hold on;
%%%%%%% Needs to be read from subfolder
if (f>=1) && (f<=9)
fname_strt = 'B0000' ;
elseif (f>=10) && (f<=99)
fname_strt='B000';
elseif (f>=100) && (f<=999)
fname_strt='B00';
else
fname_strt='B0';
end
fname_end = num2str(f);
fname = strcat(fname_strt,fname_end,'.jpg');
h=readimx(fname);
H1 = imagesc(flipud(h));
H1.AlphaData = 0.5;
axis equal
hold on;
endTurbulence Analysishttps://ch.mathworks.com/matlabcentral/profile/authors/19143687tag:ch.mathworks.com,2005:Question/6654582020-11-27T17:00:03Z2020-11-27T17:00:03Ztwo different color axis for two surfaces on the same plot?Hi everyone,
I´ve been running some simple wavepacket simulations, which are running nice, but I am having some issues for plotting them. I am plotting the potential energy with meshc, so I get some nice contour lines at the bottom of the plot, and mesh for the wavepacket itself on the same plot using hold on. What I would like to do is to plot the potential energy with a preseted color axis and the wavepacket with a different color axis that adapts to the size of the wavepacket as its develop. But so far I have failed miserably at just trying to set two distinctive color schemes for each one.
The code I am using for this is
levels = 5.8e-20:0.2e-20:8.6e-20;
figure;
hold on
sc=meshc(r_ab,r_bc,V_e);
axis('square')
set(sc(2),'LevelList',levels)
zlim([1e-21 1e-19])
sc(2).ContourZLevel = 1e-21;
caxis(1.0e-20*[5 10])
global Plothandle2, Plothandle2 = mesh(r_ab,r_bc,abs(psi_ex));
view([120 30])
where r_ab and r_bc are coordinates generated with meshgrid, V_e is the potential surface and psi_ex is the wavepacket. The following is a snapshot, clearly the features of the wavepacket cant be seen when both surfaces share the same color axis.
Thanks!Luishttps://ch.mathworks.com/matlabcentral/profile/authors/4699475tag:ch.mathworks.com,2005:Question/6654532020-11-27T16:59:44Z2020-11-27T16:59:44Z1x2 Cell with each ?field? containing 2 valuesI have a Cell called "a" which is 2x1.
so from "a" to "a{1,1}" and "a{1,2}"
Each ?field? correct me pls if this is not the right term. contains 2 values.
How can i extract the first value of both fields? If i try t = a(1,1) it gives me both values but i jsut want the first one.
Patrick Petrehttps://ch.mathworks.com/matlabcentral/profile/authors/10411263tag:ch.mathworks.com,2005:Question/6653682020-11-27T16:00:49Z2020-11-27T16:48:20ZUsing Help using filter function in Matlabclear all
G = @(u,t)(25-(5-(u)).^2);
u = 0;
%g0 = G(0.1,0);
phase = 0;
% Extremum Seeking Control Parameters
freq = 10*2*pi; % sample frequency
dt = 1/freq;
T = 10; % total period of simulation (in seconds)
A = .2; % amplitude
omega = 10*2*pi; % 10 Hz
phase = 0;
K = 5; % integration gain
%*****************************************************************
% Design of High Pass filter. the cut of frequency is 0.2
%a and b at the output variable from the butter function
b_order = 1; % The butterworth filter order
butter_freq = 1;
[b,a] = butter(b_order,butter_freq * 2 * dt, 'high');
%freqz(b,a)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Intial condition
%ys = zeros(1,b_order+1);
uhat(1) = u(1);
for i = 1 : T/dt
t = (i-1)*dt;
yvals(i) = G(u,t);% This variable stores the values of G at every interation
ys(i) = yvals(i);
HPFnew = filter(b,a,ys(i)); % This is the value of the output signal after passing through the filter.
HPFnew_vals(i) = HPFnew;
xi = HPFnew.*sin(omega.*t + phase);
uhat = uhat + xi.*K.*dt;
u = uhat + A*sin(omega*t + phase);
uhats(i) = uhat;
uvals(i) = u;
end
t = dt:dt:T;
figure
plot(t, HPFnew_vals)
%figure
%fplot(@(u) (25-(5-(u)).^2),[0 T]) % Ploting the original function.
% The next step is to multiply the output cost function G with the filter
% I will call that variable rho
t = dt:dt:T;
% Plot of U against Time
figure
subplot(2,1,1)
%ax1 = nexttile;
%plot([1:length(uhat)],uhat,'r','lineWidth',1)
plot(t,uhats,'r','lineWidth',1)
hold on
%plot([1:i],uvals,'k','lineWidth',1)
plot(t,uvals,'k','lineWidth',1)
hold off
xlabel ('Time')
ylabel('U')
legend('Uhat','U')
grid on
subplot(2,1,2)
%ax2 = nexttile;
%plot([1:length(yvals)],yvals,'r','lineWidth',1)
plot(t,yvals,'b','lineWidth',1)
xlabel ('Time')
ylabel('G')
grid on
I am trying to pass my output signal yvals(i) = G(u,t) through a butter highpass filter. The code runs but my results is totally different from what I was expecting.
This is the result obtained.
This is the result expected. I don't know what i'm doing wrong?
Telema Harryhttps://ch.mathworks.com/matlabcentral/profile/authors/19252137tag:ch.mathworks.com,2005:Question/6654482020-11-27T16:46:04Z2020-11-27T16:47:23ZIn the LU decomposition method, I used a 4*5 matrix. However, L and U should originally come out as 4*5 matrices, but both come out only 4*4 matrices. What is the cause?
function [L,U] = LU(A)
A = [4 -2 -3 6 12;-6 7 6.5 -6.5 -6.5;1 7.5 6.25 5.5 16;-12 22 15.5 -1 17];
[m,n] = size(A);
for i = 1:m
L(i,1) = A(i,1);
U(i,i) = 1;
end
for j = 2:m
U(1,j)= A(1,j)/L(1,1);
end
for i = 2:m
for j = 2:i
L(i,j)=A(i,j)-L(i,1:j-1)*U(1:j-1,j);
end
for j = i+1:m
U(i,j)=(A(i,j)-L(i,1:i-1)*U(1:i-1,j))/L(i,i);
end
end
L
U
----------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------
so. The answer comes out like this, but what is the problem here >>??? And I only need to show L U, but I don’t know if ans comes............
L =
4.0000 0 0 0
-6.0000 4.0000 0 0
1.0000 8.0000 3.0000 0
-12.0000 16.0000 -1.5000 6.5000
U =
1.0000 -0.5000 -0.7500 1.5000
0 1.0000 0.5000 0.6250
0 0 1.0000 -0.3333
0 0 0 1.0000
ans =
4.0000 0 0 0
-6.0000 4.0000 0 0
1.0000 8.0000 3.0000 0
-12.0000 16.0000 -1.5000 6.5000SUNGJIN KIMhttps://ch.mathworks.com/matlabcentral/profile/authors/16499864tag:ch.mathworks.com,2005:Question/6654432020-11-27T16:45:13Z2020-11-27T16:47:23ZFitting Truncated Normal Distribution by Using the Distribution Fitter AppIn the distribution fitter app, is there a way to fit the truncated normal distribution to data? Currently, I can obtain that fit outside of the app, while the fits for standard distributions such as normal, lognormal, weibull, etc can be obtained within the app. It would be convenient to do all by using the app.
HBhttps://ch.mathworks.com/matlabcentral/profile/authors/2216477tag:ch.mathworks.com,2005:Question/6605082020-11-24T15:13:36Z2020-11-27T16:44:33Zbiterr Error on 3D MatrixB = [1 2 3; 4 5 6; 7 8 9];
size(B) % ans = 3 3
biterr(B,B) % ans = 0
Why does biterr work here, but not below?
A = B;
A(:,:,2) = [10 11 12; 13 14 15; 16 17 18];
size(A) % ans = 3 3 2
biterr(A,A)
Operands to the || and && operators must be convertible to logical scalar values.
Error in biterr (line 212)
if aIsNumeric && (num_bits > 1)
212 if aIsNumeric && (num_bits > 1)Paul Hoffrichterhttps://ch.mathworks.com/matlabcentral/profile/authors/17585002tag:ch.mathworks.com,2005:Question/6654332020-11-27T16:44:02Z2020-11-27T16:44:02ZGetting error on setting up CCA for a BCI feature extraction Hi Dears,
I have below CCA for BCI feature extraction and even after setting up the/defining the parameters mentioned in the error message, I get error. can you pls help?
classdef CCA < eegtoolkit.featextraction.PSDExtractionBase%FeatureExtractionBase
%
% works only on our datasets, for other datasets needs modifications
%
properties (Access = public)
channel=126;
avgTime=5;
stimulus_freqs =[6.66, 7.50, 8.57, 10.00, 12.00];
FreqSamp=250;
NumHarm=3;
allFeatures;
end
methods (Access = public)
function CCA = CCA(sti_f,chans,fs,numH)
if ( nargin ~= 4 )
error('It is needed to define the simulus freqs, the channels, frequency sampling and number of harmonics');
else
CCA.stimulus_freqs = sti_f;
CCA.channel = chans;
CCA.FreqSamp = fs;
CCA.NumHarm = numH;
CCA.allFeatures = 0;
end
end
function extract(CCA)
sti_f = CCA.stimulus_freqs;
mLen=size(CCA.trials{1}.signal,2);
refSignals=CCA.ck_signalTrans(sti_f,mLen,CCA.FreqSamp,CCA.NumHarm);
NumStim = size(refSignals,3);
numTrials = length(CCA.trials);
for i=1:numTrials
data = CCA.trials{i}.signal(CCA.channel,:);
if(CCA.allFeatures == 1)
features=NaN*ones(NumStim,min(rank(data),CCA.NumHarm*2));
for j=1:NumStim
[wx1,wy1,r1] = canoncorr(data',refSignals(:,:,j)');
features(j,:) = r1;
end
tempfeatures = features(1,:);
for j=2:NumStim
tempfeatures = horzcat(tempfeatures,features(j,:));
end
instances(i,:) = tempfeatures(:);
labels(i,1) = floor(CCA.trials{i}.label);
else
features=NaN*ones(NumStim,1);
for j=1:NumStim
% [wx1,wy1,r1] = CCA.cca(data,refSignals(:,:,j));
[wx1,wy1,r1] = canoncorr(data',refSignals(:,:,j)');
features(j) = max(r1);
end
instances(i,:) = features(:);
labels(i,1) = floor(CCA.trials{i}.label);
end
end
% unique(labels)
if (sum(unique(labels)) == 41)
labels(labels==6)=1;
labels(labels==7)=2;
labels(labels==8)=3;
labels(labels==9)=4;
labels(labels==11)=5;
end
% unique(labels)
CCA.instanceSet = eegtoolkit.util.InstanceSet(instances, labels);
end
function configInfo = getConfigInfo(CCA)
configInfo = sprintf('CCA');
end
function refSignal=ck_signalTrans(CCA,f,mLen,FreqSamp,NumHarm)
p=mLen;%1250;
fs=FreqSamp;%250;
TP=1/fs:1/fs:p/fs;
for j=1:length(f)
tempComp=[];
for k=1:NumHarm
Sinh1=sin(2*pi*k*f(j)*TP);
Cosh1=cos(2*pi*k*f(j)*TP);
tempComp = [tempComp; Sinh1;Cosh1;];
end
refSignal(:,:,j)=tempComp;
end
end
function time = getTime(CCA)
time = CCA.avgTime;
end
end
end
Below is the error I am getting:
>> eegtoolkit.featextraction.CCA
Error using eegtoolkit.featextraction.CCA (line 16)
It is needed to define the simulus freqs, the channels, frequency sampling and number of harmonicsBayar Shahabhttps://ch.mathworks.com/matlabcentral/profile/authors/5158865tag:ch.mathworks.com,2005:Question/6654182020-11-27T16:30:36Z2020-11-27T16:42:42Zarg min for Optimization problemu=argmin{||X-A*w-B*v||^2}
Inputs : A,B,X,w,v
outputs:u which contain optimized vector of w,v
how to write code for this.Please help meMurali Krishna AGhttps://ch.mathworks.com/matlabcentral/profile/authors/16002500tag:ch.mathworks.com,2005:Question/6654282020-11-27T16:41:34Z2020-11-27T16:41:34Zregarding matlab code for assignmenthi everyone,
i am new to matlab. i have assignment in which i have to find distance between minutiaes. i have to write matlab code for function to find distance.this is incomplete function, i have to complete:
% FINGERPRINT MATCHING SCORE
% Argument: M1 - First transformed Fingerprint
% M2 - Second transformed Fingerprint
% Returns: Distance
function Distance = Match_fingerprints_URV(ff1,ff2)
Distance=0;
% TO DO
% END TO DO
end
this above code should be implemented in the below code:
clear;
clc;
close all;
addpath(genpath(pwd));
[filename1,~]=uigetfile('*.txt','Fingerprint identification register');
[filename2,~]=uigetfile('*.txt','Fingerprint identification register');
ff1=load(filename1);
ff2=load(filename2);
[ff1_aligned,ff2_aligned,DeltaX,DeltaY,DeltaAngle] = Transform_fingerprints(ff1,ff2,1);
Distance=Match_fingerprints_URV(ff1_aligned,ff2_aligned);
display(Distance,'Distance');
display(DeltaX,'DeltaX');
display(DeltaY,'DeltaY');
display(DeltaAngle,'DeltaAngle');
help on how to write code :
kindly tell me how to do it?
Gurwinder pal singh Bhinderhttps://ch.mathworks.com/matlabcentral/profile/authors/16745048tag:ch.mathworks.com,2005:Question/6654132020-11-27T16:23:33Z2020-11-27T16:37:58Zhow can i solve this functionThe classic quadratic formula says that the two roots of the quadratic equation ax2+bx+c=0 are x1,x2=(-b±√(b2-4ac). Write a function that keep solutions x1,x2 and use this function in another script file. It takes as integers to input the values of a, b, and c and solve the equation using the first function you define in step one. Finally, use this to solve the equation 8x2+4x-2=0.afrah azizhttps://ch.mathworks.com/matlabcentral/profile/authors/20005580tag:ch.mathworks.com,2005:Question/3980122018-04-29T09:22:11Z2020-11-27T16:36:10ZAdding a scatter of points to a boxplot Does anyone come with with a code which can match the python generated boxplot? Peyman Obeidyhttps://ch.mathworks.com/matlabcentral/profile/authors/7599016tag:ch.mathworks.com,2005:Question/6654232020-11-27T16:35:43Z2020-11-27T16:35:43ZHow does MATLAB's stereo rectification algorithm work?I have a stereo camera that has been correctly calibrated in MATLAB. rectifyStereoImages gives the correct output when supplied the stereoParameters obtained during calibration.
I have been struggling to recreate the algorithm without using libraries, so I have modified the contents of StereoParametersImpl.m in the vision toolbox in order to retrieve the homographies/transformations that are used in rectifyStereoImages.
The code of interest is shown below:
function [Hleft, Hright, Q, xBounds, yBounds, success] = ...
computeRectificationParameters(this, imageSize, outputView)
% Make the two image planes coplanar, by rotating each half way
[Rl, Rr] = computeHalfRotations(this);
% rotate the transltation vector
t = Rr * this.TranslationOfCamera2';
% Row align the image planes, by rotating both of them such
% that the translation vector coinsides with the X-axis.
RrowAlign = computeRowAlignmentRotation(t);
% combine rotation matrices
Rrectl = RrowAlign * Rl;
Rrectr = RrowAlign * Rr;
Kl = this.CameraParameters1.IntrinsicMatrix';
Kr = this.CameraParameters2.IntrinsicMatrix';
K_new = computeNewIntrinsics(this);
Hleft = projective2d((K_new * Rrectl / Kl)');
Hright = projective2d((K_new * Rrectr / Kr)');
...
If I use the homographies obtained here, my custom implementation gives the correct results (after distortion correction).
Since MATLAB's stereo rectification process involves Bouguet's algorithm, the rotation matrix Rrectl should map TranslationOfCamera2 to an x-axis vector, at least as far as I understand. Yet,
Rrectl' * this.TranslationOfCamera2'
produces a vector with non-zero x, y and z components, why is this?
I have confirmed that
Rrectl == Rrectr * this.RotationOfCamera2'
, so after rotation, both cameras are in same coordinate frame, but the translation vector is clearly not parallel to the x-axis.
I understand the general process behind the rectification, but the non-x-axis translation vector is making me doubt myself.Johnny Guitarhttps://ch.mathworks.com/matlabcentral/profile/authors/20471791tag:ch.mathworks.com,2005:Question/1064022013-11-16T17:55:18Z2020-11-27T16:32:45ZTrying to remove vocals from songs (create karaoke) Specifically, windowing and framing help.I have been trying to accoplish this for a little while now, but I am no expert in MATLAB (far from it). I came across a code in a forum that one guy used, but it doesn't work well at all. Thus, why he was asking for help in the forum. The advice that he was given was to:
"What this means is that you have to break up your signal in frames in the time-domain and do your fft and masking separately for each frame. Also you should consider to use an overlap in your time-domain framing."
and
"In addition to all of the points above, Windowing is also required to minimise bleed between adjacent bins of strong frequencies."
He later posted that he tried those things, and it worked well. He never reposted his code, though. I am not sure what he did to fix it. Can anyone advise me on how to do those things.
Here is the code:
[y, fs] = wavread('Song.wav');
left = y(:,1);
right = y(:,2);
fftL = fft(left);
fftR = fft(right);
for i = 1:683550 %in my example 683550
dif = fftL(i,1) / fftR(i,1);
dif = abs(dif);
if (dif > 0.7 & dif < 1.5)
fftL(i,1) = 0;
fftR(i,1) = 0;
end;
end;
leftOut = ifft(fftL);
rightOut = ifft(fftR);
yOut(:,1) = leftOut;
yOut(:,2) = rightOut;
wavwrite(yOut, fs, 'tmp.wav');
Here is the link: <http://stackoverflow.com/questions/14461210/matlab-removing-vocals>
Thank youErichttps://ch.mathworks.com/matlabcentral/profile/authors/4533807tag:ch.mathworks.com,2005:Question/6653932020-11-27T16:10:34Z2020-11-27T16:31:25ZCorrelating through specific rows in matrixDear all,
I want to correlate a 100*6 matrix against the respective 100*6 in a 1700*6 matrix. How do I go increasing the counter by 100 rows such that i increases 1:100, 101:200, 201:300 and so on?
for i = 1:1700
C_ET(i) = corr(Y_ET(i,:),Y_Compiled(i,:)); % Y_ET = 100*6 & Y_Compiled = 1700*6 matrix
end
Thank you for your help!Elizabeth Yeaphttps://ch.mathworks.com/matlabcentral/profile/authors/8460975tag:ch.mathworks.com,2005:Question/6653982020-11-27T16:14:11Z2020-11-27T16:28:27Zadd labels to x axisHi every body.
I have 10 mean plus/minus standard daviations of 10 patients. i want to plot an error bar with lables of patients in x axis. and i have written the code below, but it doesnt work and x lables are 1:10 instead of P1:P10
X = categorical({'P1','P2','P3','P4','P5','P6','P7','P8','P9','p10'});
X = reordercats(X,{'P1','P2','P3','P4','P5','P6','P7','P8','P9','p10'});
mean=[0.81,0.77,0.84,0.86,0.98,0.90,0.84,0.79,0.81,0.89]
STD=[0.36,0.22,0.11,0.13,0.05,0.01,0.06,0.06,0.1,0.02]
errorbar(X,mean,STD)
could anyone help me we that please? talayeh ghodsihttps://ch.mathworks.com/matlabcentral/profile/authors/14229557tag:ch.mathworks.com,2005:Question/6654082020-11-27T16:19:03Z2020-11-27T16:22:32ZWrite a function that mix a multi-column audio recording into one single record.write a function called mixit that takes two input arguments. The first is a K-by-N matrix of unit 16 values where N is the number of tracks and k is the number of samples per track, The second input argument is a vector of N double scalars representing the weights of the tracks. The output of the function is a K-element column vector of doubles representing a single-track audio recording obtained by mixing the individual tracks according to the static weights. Note that before any of the processing takes place, the audio data must be converted to standard interval of [-1 1]. That is, unit 0 needs to be mapped to -1, while 65536 becomes
+1. The output is expected to be in the same range. If any element of the final mixed audio is outside of this range, the output needs to be scaled. Hint find the maximum of the absolute value of the output vector. If it is greater than 1, you need to divide the entire vector with that valuechitra perumalhttps://ch.mathworks.com/matlabcentral/profile/authors/18610139tag:ch.mathworks.com,2005:Question/6214332020-10-21T14:25:38Z2020-11-27T16:20:30ZAccessing org.postgresql.util.PGobjects in Matlab tablesHI - I'm having a dificult time figuring out how to accessing the packed data below in 'check.data' that are long cells. I've been trying functions like cell2mat with out any luck. The common error I get is that 'Brace indexing is not supported for variables of this type'. Any help appreciated. Many thanks!
>> check = Narwhal(Narwhal.namespaced_collection=="shorebirds.check",:);
>> size(check.data)
ans =
1507 1
>> check.data(1:3)
ans =
3×1 cell array
{1×1 org.postgresql.util.PGobject}
{1×1 org.postgresql.util.PGobject}
{1×1 org.postgresql.util.PGobject}
>> check.data{1:3}
ans =
{"date": 1597862119404, "notes": "Greg testing", "nest_id": "0899094c-b5a0-4792-80d0-bad71d42d1a6", "sdzg_int": {"incubating": null, "nest_status": []}, "global_id": "a25a1121-2dfd-4091-a8d0-d5aee033b016", "populations": {"core": {"core_membership": {"isSample": true}}, "sdzg_int": {"sdzg_membership": {"isSample": true}}, "shorebirds": {"check_membership": {"isSample": true}}}, "eggs_abandoned": null, "date_time_created": 1597862119404}
ans =
{"date": 1586972714082, "notes": null, "nest_id": "2f3ece70-83ca-4a2b-a26d-5d82a460a095", "sdzg_int": {"nest_status": []}, "global_id": "616f9bc3-2668-4450-8a20-3c362e5c66e4", "populations": {"core": {"core_membership": {"isSample": true}}, "sdzg_int": {"sdzg_membership": {"isSample": true}}, "shorebirds": {"check_membership": {"isSample": true}}}, "eggs_abandoned": null, "date_time_created": 1586972714083}
ans =
{"date": 1588707892420, "notes": null, "nest_id": "96863fcc-bd8d-4534-9ade-ddb9f5f92c25", "sdzg_int": {"incubating": null, "nest_status": []}, "global_id": "f20afda4-890c-4d2d-a59a-60f18eec8785", "populations": {"core": {"core_membership": {"isSample": true}}, "sdzg_int": {"sdzg_membership": {"isSample": true}}, "shorebirds": {"check_membership": {"isSample": true}}}, "eggs_abandoned": null, "date_time_created": 1588707892421}Ignacio Vilchishttps://ch.mathworks.com/matlabcentral/profile/authors/2470319tag:ch.mathworks.com,2005:Question/6652582020-11-27T14:42:37Z2020-11-27T16:15:55Zread files from multiple folders in for loopI have for loop code which performs two kinds of opearation with files in the two diffferent folder.
For instance, first part of the code delas with files located in the Folder A, second part of the code deals with Folder A1 which is located inside Folder A. How to exceute this ???. Thanks in advamce for support..Turbulence Analysishttps://ch.mathworks.com/matlabcentral/profile/authors/19143687tag:ch.mathworks.com,2005:Question/6654032020-11-27T16:14:47Z2020-11-27T16:14:47ZBest package to download.I have to make an algorithm and code -and run the code- for heuristics for uni, I am thinking about TSP with ant colony optimization, which package is the best for me to download?Maria Santahttps://ch.mathworks.com/matlabcentral/profile/authors/17487579tag:ch.mathworks.com,2005:Question/574252012-12-26T13:23:19Z2020-11-27T16:13:03Zquestion about dicomwrite functionHi all,
I use dicomwrite function to write a three dimensional matrix to a dicom file with MR image storage,but I get a error "Cannot determine photometric interpretation."
example:
x=100*rand(63,53,46);
dicomwrite(x,'x.dcm','ObjectType','MR Image Storage');
??? Error using ==> dicom_prep_ImagePixel>getPhotometricInterp at 90
Cannot determine photometric interpretation.
Thank youyanhonghttps://ch.mathworks.com/matlabcentral/profile/authors/3941200tag:ch.mathworks.com,2005:Question/6641432020-11-27T00:09:30Z2020-11-27T16:12:21ZHow can I straighten edges of calibrated images ?Hello guys,
I am trying to calibrate my camera (fisheye calibration) , I succeded but after calibration, my images doesn't looks like rectangular. You can see the image attached below. How can I crop this image after calibration? Should I do this process manually or is there any function for undistorted images to transform into rectangular image. Basically, I would like to remove black parts from final image .
Thanks a lot.
Umut Ersoyumut ersoyhttps://ch.mathworks.com/matlabcentral/profile/authors/9353092tag:ch.mathworks.com,2005:Question/6651932020-11-27T12:46:36Z2020-11-27T16:10:33Z"Unable to perform assignment because dot indexing is not supported for variables of this type. " Error in GAF_Improved (line 61) S(i).xd=rand(1,1)*xm;% GAF Random + TPut
clc;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%
rmax=25;
data_time=0;
bytes=0;
Routing_pack=0;
%Field Dimensions - x and y maximum (in meters)
xm=100;
ym=100;
%x and y Coordinates of the Sink
sink.x=xm;
sink.y=ym;
%Number of Nodes in the field
n=90;
%Optimal Election Probability of a node
%to become cluster head
p=0.1;
%Energy Model (all values in Joules)
%Initial Energy
Eo=0.5;
%Eelec=Etx=Erx
ETX=50;
ERX=50;
%Transmit Amplifier types
Efs=0.01;
Emp=0.0000013;
%Data Aggregation Energy
EDA=5;
%Values for Hetereogeneity
%Percentage of nodes than are advanced
m=0.1;
%\alpha
a=1;
%variables for finding max distance between cluster nodes
min_d1=0;min_d2=0;min_d3=0;
%%%%%%%%%%%%%%%%%%%%%%%%% END OF PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%
%Computation of do
do=sqrt(Efs/Emp);
%Creation of the random Sensor Network
figure(1);
for i=1:1:3
area(i)=0;
end
for i=1:1:n
%Getting random initial position of all the nodes
S(i).xd=rand(1,1)*xm;
XR(i)=S(i).xd;
S(i).yd=rand(1,1)*ym;
YR(i)=S(i).yd;
S(i).name=i;
X=S();
[C_id]= cluster_id(X,i);
S(i).id=C_id;
%Find the number of nodes in each of 9 areas
% area(i) defines the number of nodes in all 9 areas
if (C_id==1)
area(1)=area(1)+1;
elseif (C_id==2)
area(2)=area(2)+1;
elseif (C_id==3)
area(3)=area(3)+1;
end
S(i).E=Eo;
S(i).ENERGY=0;
% Plotting all the nodes
if (S(i).id==1)
plot(S(i).xd,S(i).yd,'r o');
hold on;
elseif (S(i).id==2)
plot(S(i).xd,S(i).yd,'g o');
hold on;
elseif (S(i).id==3)
plot(S(i).xd,S(i).yd,'m o');
hold on;
end
end
figure(1);
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
% area(i) defines the number of nodes in all 9 areas
disp('nodes in each area');
for i=1:1:3
disp(area(i));
end
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
%total number of nodes
disp('total nodes in all area');
area_all=0;
for i=1:1:3
area_all=area_all+area(i);
end
disp(area_all);
%Plotting Sink
S(n+1).xd=sink.x;
S(n+1).yd=sink.y;
plot(S(n+1).xd,S(n+1).yd,'^','linewidth',3);
hold on;
%cluster on;
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
disp('Minimum cluster Size');
min_cluster_size=min(area);
disp(min_cluster_size);
disp('Maximum cluster Size');
max_cluster_size=max(area);
disp(max_cluster_size);
figure(1);
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
X=S();
[C1,C2,C3]=cluster_maker(X,n);
% disp('nodes for cluster1');
% disp(C1);
% disp('nodes for cluster2');
% disp(C2);
% disp(' nodes for cluster3');
% disp(C3);
% disp('nodes for cluster4');
% disp(C4);
% disp('nodes for cluster5');
% disp(C5);
% disp('nodes for cluster6');
% disp(C6);
% disp('nodes for cluster7');
% disp(C7);
% disp('nodes for cluster8');
% disp(C8);
% disp('nodes for cluster9');
% disp(C9);
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
dead_all=0;
dead=0;
min_round=3;
for r=1:min_round:rmax
disp('round=');
disp(r);
if(r>25)
break;
end
disp ('Nodes after Sorting');
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
X=S();
[M1,M2,M3,S,count, r_pack]=Max_Energy_Nodes(X,n);
data_time=data_time+1;
Routing_pack=Routing_pack + r_pack;
disp('sorted nodes for cluster1'); disp(M1);
for p=1:1:count(1)
disp(S(M1(p)).E);
end
% disp('sorted nodes for cluster2'); disp(M2);
% disp('sorted nodes for cluster3'); disp(M3);
% disp('sorted nodes for cluster4'); disp(M4);
% disp('sorted nodes for cluster5'); disp(M5);
% disp('sorted nodes for cluster6'); disp(M6);
% disp('sorted nodes for cluster7'); disp(M7);
% disp('sorted nodes for cluster8'); disp(M8);
% disp('sorted nodes for cluster9'); disp(M9);
figure(1);
% Selection of 50% nodes after Sorting
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
y1=0; y2=0; y3=0;
for i=1:1:3
t(i) = ceil (count(i) /2); % select the upper roundoff value for running the loops
if t(i)==0
t(i)=1;
end
end
max_round=max(t);
disp('max round');
disp (max_round);
min_round=min(t);
disp('min round');
disp (min_round);
for f1=1:1:min_round
r=r+1;
disp('round=');
disp(r);
if(r>25)
break;
disp('break');
end
%%%%%%%%%%%%%%%%%%% Routing_pack=Routing_pack+1; %%%%%%%%%%%%%
figure(1);
X=S();
if count(1)>0
active(1)=M1(f1); %making a node Active Node active(1)
disp('In Grid 1 Active Node is:');disp(active(1));
plot(S(active(1)).xd,S(active(1)).yd,'o','markerfacecolor','k');
hold on;
figure(1);
end
figure(1);
X=S();
if count(2)>0
active(2)=M2(f1); %making a node Active Node active(2)
% disp('In Grid 2 Active Node is:');disp(active(2));
plot(S(active(2)).xd,S(active(2)).yd,'o','markerfacecolor','k');
hold on;
figure(1);
end
figure(1);
X=S();
if count(3)>0
active(3)=M3(f1); %making a node Active Node active(3)
% disp('In Grid 3 Active Node is:');disp(active(3));
plot(S(active(3)).xd,S(active(3)).yd,'o','markerfacecolor','k');
hold on;
end
end
X=S();
for k1=1:1:3
for k2=1:1:3
sender=active(k1);
receiver=active(k2);
if ((S(sender).xd < S(receiver).xd) && (S(sender).yd < S(receiver).yd))
[d]=distance(S,sender,receiver);
if(min_d1<d)
min_d1=d;
end
disp('d is');disp(min_d1);
[bal_energy_receiver,bal_energy_sender,time,data_bytes]=data_send(sender,receiver,X,min_d1); %communication between Normal node and CH
bytes=bytes+data_bytes;
S(sender).E = bal_energy_sender;
S(receiver).E = bal_energy_receiver;
end
end
end
data_time=data_time+1;
plot(S(active(1)).xd,S(active(1)).yd,'o','markerfacecolor','white');
hold on;
plot(S(active(2)).xd,S(active(2)).yd,'o','markerfacecolor','white');
hold on;
plot(S(active(3)).xd,S(active(3)).yd,'o','markerfacecolor','white');
hold on;
%pause(2);
end
r=r+min_round;
%data_time=data_time+1;
%end
%loop r=1:1:rmax
disp('Balance Energy of all the nodes:');
for E2=1:1:n
disp(S(E2).E);
end
X=S();
[dead]=dead_count(X,n);
disp('dead nodes'); disp(dead); %number of dead nodes into dead nodes
total_bal_E=0;
for i=1:1:n
if(S(i).E>0)
total_bal_E = total_bal_E + S(i).E;
end
end
avg_bal_E = total_bal_E/n;
disp('Average Bal Energy');
disp(avg_bal_E);
tput=0;
tput=bytes/data_time;
disp('bytes is:');
disp(bytes);
disp('time is:');
disp(data_time);
disp('throughput is:');
disp(tput);
%
% %disp(S(n+1).xd);
% %disp(S(n+1).yd);
% %disp(S(1));
% %disp(S(2));
% %disp(S(3));
% %a=S(2).xd;
% %b=S(2).yd;
% %display_val(a,b);
r_overhead=0;
r_overhead = Routing_pack/bytes;
disp('r_overhead');
disp(r_overhead);
cephas mulungihttps://ch.mathworks.com/matlabcentral/profile/authors/17815927tag:ch.mathworks.com,2005:Question/6653882020-11-27T05:00:00Z2020-11-27T16:10:09ZWhy do I get the error "Timeout occurred while waiting for the String Terminator"?I am trying to create a TCP/IP client connection with a TCP/IP server using tcpclient() (formerly tcpip()). But I get the following error:
>> echotcpip("on",5000);
>> t = tcpclient("10.10.10.100",5000);
>> val = writeread(t,"ctrlcmd");
Error reading String.
Timeout occurred while waiting for the String Terminator.MathWorks Support Teamhttps://ch.mathworks.com/matlabcentral/profile/authors/4622813tag:ch.mathworks.com,2005:Question/6653832020-11-27T16:08:41Z2020-11-27T16:08:41Z ؤcalculation an inline function 1. Write a function as hesap.m that calculates the interplanetary distance as d = a/(√h2+k2+l2) and write a text file called cagiran.m asking users a, h. K. l Values and calculate the interplanetary distance d by using hesap.m.afrah azizhttps://ch.mathworks.com/matlabcentral/profile/authors/20005580tag:ch.mathworks.com,2005:Question/6652682020-11-27T14:46:57Z2020-11-27T16:08:06ZUsing Linear congruential to generate 10,000 uniform random variablesI want to generate uniform random variables between 0 and 1 by using X(n+1)=(1664525*X(n)+1013904223) mod^32, but i couldn't.
Please help...
this is my code:
clear all; clc;
a=1664525; c=1013904223; m=2^32;
for n=1:10000
X(n)=mod((a*X(n)+c), m);
end
disp(X);Beom soo Kimhttps://ch.mathworks.com/matlabcentral/profile/authors/19950795tag:ch.mathworks.com,2005:Question/6653782020-11-27T16:05:53Z2020-11-27T16:05:53Z"dsp_rt.h" missing after code generation (2020b)Setup:
Simulink 2020b
Simulink model configured for embedded coder
Subsystem uses Chirp
Generate code
dsp_rt.h is missing (is used by #include in codegen.c)
Everything works fine without using the Chirp block (other blocks do not use DSP Toolbox), but for some reason the dsp_rt.h file is not in the target folder of the code generationTobias Schindlerhttps://ch.mathworks.com/matlabcentral/profile/authors/14908703tag:ch.mathworks.com,2005:Question/6653732020-11-27T16:05:41Z2020-11-27T16:05:41ZModel diagram in the Simbiology freeze and disappear Dear MatLab,
I am building a PBPK model in Simbiology. The model is quite complex. Whenever I add a new compartment or specie into the model diagram, it froze for a few minutes. Somehow my model diagram never shows up again... How can I solve this problem? Is it a problem of insufficient RAM or CPU power? How can I let my matlab assess more RAM or CPU power than usual?
Link: https://drive.google.com/file/d/1epB8FlTthFvdmblmAmvmohybDsy1mmVn/view?usp=sharing
The link is a video showed my screen record. The first project I opened is the problematic model that has no model diagram. The second is the confirmation that the other project works okay.Jesse Chaohttps://ch.mathworks.com/matlabcentral/profile/authors/19346793tag:ch.mathworks.com,2005:Question/6651182020-11-27T11:52:02Z2020-11-27T16:03:39ZThe function "estimateWorldCameraPose"returns null values for rotation matrix and the translateur vectorGood morning,
I need to use the function "estimateWorldCameraPose" to calculate the rotation matrix and the translation vector.
I am using a picture where the object is a circle.
With a function I designed based on a tutorial, I got the coordinates in 2D of the center of the circle.
I also have the 3D coordinates of the center measured by other software.
My problem is that I have Null values for the rotation matrix and the translation vector and I cannot figure out.
Can you help me please?
Thanks for your help.
The picture used is that one:
The function I used is that one:
function [markers, diameter] = Find_the_center_circle(fullImages)
%% Definition of plotting variables
captionFontSize = 14;
%% Convertion to gray scale
GrayImage = rgb2gray(fullImages);
%% Identification of each blob which are constituted the picture
% Identify individual blobs by seeing which pixels are connected to each other.
% Each group of connected pixels will be given a label, a number, to identify it and distinguish it from the other blobs.
% Do connected components labeling with either bwlabel() or bwconncomp().
% Label each blob so we can make measurements of it.
labeledImage = bwlabel(GrayImage, 8);
% Get all the blob properties. Can only pass in originalImage in version R2008a and later.
blobMeasurements = regionprops(labeledImage, GrayImage, 'all');
numberOfBlobs = size(blobMeasurements, 1);
%% Plot the the circle's imprint
imshow(GrayImage);
title('Outlines, from bwboundaries()', 'FontSize', captionFontSize);
% Make sure image is not artificially stretched because of screen's aspect ratio.
axis image;
hold on;
boundaries = bwboundaries(GrayImage);
numberOfBoundaries = size(boundaries, 1);
for k = 1 : numberOfBoundaries
thisBoundary = boundaries{k};
plot(thisBoundary(:,2), thisBoundary(:,1), 'g', 'LineWidth', 2);
end
hold off;
%% Deterination of the centre abd tge size of each circle
% We can get the centroids of ALL the blobs into 2 arrays,
% one for the centroid x values and one for the centroid y values.
allBlobCentroids = [blobMeasurements.Centroid];
centroidsX = allBlobCentroids(1:2:end-1);
centroidsY = allBlobCentroids(2:2:end);
hold on;
% Loop through all blobs.
for k = 1 : numberOfBlobs
plot(centroidsX(k), centroidsY(k), 'bx', 'MarkerSize', 10, 'LineWidth', 2);
end
%% Outputs of the function
markers = [centroidsX, centroidsY];
diameter = blobMeasurements.Perimeter;
end
The following code is what I used:
%Definition of loop counters
% Ncams = length(imRects);
nCams = 1;
Npicture = 1;
%Definition parameters for estimateWorldCameraPose
confidence = 99.9; %Confidence parameter for 'Confidence'
max_error_repro = 1.5; %Reprojecction error for 'MaxReprojectionError'
%Focal length in meters (given by the datasheet of the camera)
Focal_length = 3.04e-3;
%Blender resolution
res_x = 1920;
res_y = 1800;
markerLocations = 1.0e+03 *[0.13689/(pi*2), 2.2718/(pi*2), 0.011503];
%Definition structures
gantryCalib.R = cell(1, nCams);
gantryCalib.T = cell(1, nCams);
markerCamLocalisation = cell(1, nCams);
goodMeasure = cell(1, nCams);
triPositions = cell(1, nCams);
camCsTot = cell(1, nCams);
usedPicture = cell(1, nCams);
%Definition tables
Rs = zeros(3, 3, Npicture);
Ts = zeros(Npicture, 3);
markerLocationsCalculate = zeros(length(markerLocations), 2, Npicture);
measure = false(Npicture, 1);
goodPicture = zeros(Npicture, 1);
camCs(1: Npicture) = CoOrdinateSystem_R_T;
%% Generation intrinsic parameters
%Determination of the size of the picture
fPicture = ['Cam', int2str(1), '_', sprintf('%0.4d', 1)];
imSize = size(CropImage);
%Calculation of the intrinsic matrix K = [f_x, s, o_x; 0, f_y, o_y; 0, 0, 1]
piCam.F = Focal_length; % focal length in meters
piCam.r = [res_x, res_y]; % origional resolution
piCam.p = 1.4e-6 * piCam.r(1)/imSize(1); % pixel size in meters, scaled for the cropped image resolution
piCam.s = 1 /piCam.p; % pixels per metre
piCam.f = piCam.F * piCam.s; % focal length in pixels
piCam.c = imSize([2,1])/2; % principal point in pixels
piCam.I = [piCam.f, 0,0; 0 piCam.f,0;piCam.c,1];
piCam.camParam = cameraParameters('IntrinsicMatrix', piCam.I);
%% Calibration
for i = 1:nCams
camName = ['Camera', int2str(i),'_*.png'];
FlistFull = dir(fullfile(FullFolder, camName));
FlistFull.name;
for j = 1:Npicture
%Load picture
FullImage = imread(fullfile(FullFolder, FlistFull(j).name));
%Detection markers
if(100 < length(CropImage))
[markers, diameter] = Find_the_center_circle(FullImage);
% %Verification place of the markers
f = figure;
imshow(FullImage);
hold on;
plotDots(markers1, 200, 'b', '.');
hold off;
%
else
markers = 0;
fprintf('Error in image %d, camera %d, incorrect number of markets \n', j, i);
end
[s, add] = size(markers);
if(s == 1)
%Calibration
[r, t, inliers, status] = estimateWorldCameraPose(markers, markerLocations, piCam.camParam, ...
'Confidence', confidence, ...
'MaxReprojectionError', max_error_repro);
end
end
endClaire Pottierhttps://ch.mathworks.com/matlabcentral/profile/authors/20169073tag:ch.mathworks.com,2005:Question/6653532020-11-27T15:52:17Z2020-11-27T16:02:57ZHow can I open the Code-Generation Report of the hdlcoderWhen I generate an IP-Core with the hdlcoder Matlab opens a window with the Code Generation Report like it is shown in this tutorial (4. Generate and view the IP core report):
https://www.mathworks.com/help/hdlcoder/ug/getting-started-with-hardware-software-codesign-workflow-for-xilinx-zynq-platform.html
How can I open this window again after I closed it?
I know that I can find the corresponding html files in the IP-Core folder but is it possible to open this exact window again? (It is much more comfortable than opening the single files one by one).
Kind regards
Niklas
Niklas Weishttps://ch.mathworks.com/matlabcentral/profile/authors/11318475tag:ch.mathworks.com,2005:Question/6653632020-11-27T15:59:32Z2020-11-27T15:59:32ZMultiplying by inverse of a matrixHello,
I want to calculate where is a scalar (it's for calculating the estimated variance of a parameter). Using
alpha*inv(X'X)
gives the correct results but (a) Matlab suggest not doing so (although the backward slash gives the wrong results) and (b) I've always avoided multiplying by the inverse of a matrix due to potential inaccuracy.
Is there a better way?
Thank youJuan Paez-Farrellhttps://ch.mathworks.com/matlabcentral/profile/authors/6010760tag:ch.mathworks.com,2005:Question/6631582020-11-26T07:30:08Z2020-11-27T15:58:48Zsim('') command with supressed ";" still displays a variable on command window (it's spamming it)I am currently trying to run a number of different load cases in a simulink model, and I thus use the "sim('model')" command in a for loop. My code is seen below
LoadCases = [30, 31];
idx = 1;
for i = LoadCases
LoadCase = i;
sim('WPSCMM82_IEC_Simulations_V009_lima_23_nov_2020');
KeyData{idx} = KeyDataDisplay.signals.values(end,:)';
for k = 1:size(KeyDataScope.signals,2)
scopedata(:,k) = KeyDataScope.signals(k).values;
end
TimeSeriesData{idx} = scopedata;
idx = idx + 1;
end
Where LoadCases is the variable in the simulink model I change for each loop. The data variables are just used for logging the data that I save to workspace. This functions just fine. The problem is, even with the suppresion ";" on the sim command, my command windown is spammed with a display of a variable, that I have no idea what is, or where it belongs (see fig). This happens while my simulation is running. I am trying to get rid of it - any ideas?Rasmus Visgaardhttps://ch.mathworks.com/matlabcentral/profile/authors/20457727tag:ch.mathworks.com,2005:Question/3348892017-04-11T18:00:52Z2020-11-27T15:57:57ZCan't install any toolboxes because can't write to /usr/local/MATLAB/R2017I have not been able to install any toolboxes because the installation runs into PermissionDenieds on /usr/local/MATLAB/R2017/. I've included a logfile /tmp/mathworks_pjhellemn.log below which includes the error. I tried running Matlab with sudo, but my license is only for user pjhellemn and not for root, so Matlab would exit with a License Manager Error -9. I also ran "sudo chmod -R 777 *" at /usr/local/MATLAB/ before trying to install the toolbox, but then ended up getting "java.io.IOException: Error 1 setting permissions for /usr/local/MATLAB/R2017a/toolbox/local/pathdef.m. Operation not permitted" (also in the logfile below, but nearer to the bottom).
I am running Ubuntu 16.04. I'm using R2017 and trying to install the Bioinformatics toolbox right now, but I've had this same issue with R2016 and the Statistics and Machine Learning Toolbox. I am installing Matlab by downloading the zip, extracting it, and then running "sudo ./install" in the proper directory, and using all defaults in the installation.
Since trying "chmod 777" I have deleted the Matlab installation directory ("sudo rm -rf /usr/local/MATLAB/") and freshly installed, but am running into the same problems.
How do I get around these permission / licensing errors?
Log file:
(Apr 10, 2017 21:04:42) ##################################################################
(Apr 10, 2017 21:04:42) #
(Apr 10, 2017 21:04:42) # Today's Date:
(Apr 10, 2017 21:04:42) Mon Apr 10 21:04:42 CDT 2017
(Apr 10, 2017 21:04:42)
(Apr 10, 2017 21:04:42) System Info
(Apr 10, 2017 21:04:42) OS: Linux 4.4.0-72-generic
(Apr 10, 2017 21:04:42) Arch: amd64
(Apr 10, 2017 21:04:42) Data Model: 64
(Apr 10, 2017 21:04:42) Language: en
(Apr 10, 2017 21:04:42) Java Vendor: Oracle Corporation
(Apr 10, 2017 21:04:42) Java Home: /usr/local/MATLAB/R2017a/sys/java/jre/glnxa64/jre
(Apr 10, 2017 21:04:42) Java Version: 1.7.0_60
(Apr 10, 2017 21:04:42) Java VM Name: Java HotSpot(TM) 64-Bit Server VM
(Apr 10, 2017 21:04:42) Java Class Path: Skipped
(Apr 10, 2017 21:04:42) User Name: pjhellemn
(Apr 10, 2017 21:04:42) Current Directory: /usr/local/MATLAB/R2017a/bin
(Apr 10, 2017 21:04:42) Total upgradeable support packages found = 0
(Apr 11, 2017 04:26:37) ##################################################################
(Apr 11, 2017 04:26:37) #
(Apr 11, 2017 04:26:37) # Today's Date:
(Apr 11, 2017 04:26:37) Tue Apr 11 04:26:37 CDT 2017
(Apr 11, 2017 04:26:37)
(Apr 11, 2017 04:26:37) System Info
(Apr 11, 2017 04:26:37) OS: Linux 4.4.0-72-generic
(Apr 11, 2017 04:26:37) Arch: amd64
(Apr 11, 2017 04:26:37) Data Model: 64
(Apr 11, 2017 04:26:37) Language: en
(Apr 11, 2017 04:26:37) Java Vendor: Oracle Corporation
(Apr 11, 2017 04:26:37) Java Home: /usr/local/MATLAB/R2017a/sys/java/jre/glnxa64/jre
(Apr 11, 2017 04:26:37) Java Version: 1.7.0_60
(Apr 11, 2017 04:26:37) Java VM Name: Java HotSpot(TM) 64-Bit Server VM
(Apr 11, 2017 04:26:37) Java Class Path: /usr/local/MATLAB/R2017a/java/config/trialsinstaller/pathlist.jar
(Apr 11, 2017 04:26:37) User Name: pjhellemn
(Apr 11, 2017 04:26:37) Current Directory: /home/pjhellemn/pjh5/stat450/MLSiml/jimmy/demo_GMKL
(Apr 11, 2017 04:26:37) Input arguments:
(Apr 11, 2017 04:26:37) root /usr/local/MATLAB/R2017a
(Apr 11, 2017 04:26:37) libdir /usr/local/MATLAB/R2017a
(Apr 11, 2017 04:26:37) matlabargs "-r "matlab.internal.addons.cdAndShowAddon('BI')""
(Apr 11, 2017 04:26:37) addonMode trialMode
(Apr 11, 2017 04:26:37) entitlementId 3284817
(Apr 11, 2017 04:26:37) Argument not logged
(Apr 11, 2017 04:26:37) basecode.BI true
(Apr 11, 2017 04:26:37) standalone true
(Apr 11, 2017 04:26:38) Starting local product/component search in download directory
(Apr 11, 2017 04:26:38) Searching for archives...
(Apr 11, 2017 04:26:38) /home/pjhellemn/Downloads/MathWorks/R2017a/archives doesn't exist ... skipping.
(Apr 11, 2017 04:26:39) Archive search complete. 0 total files found.
(Apr 11, 2017 04:26:39) Completed local product/component search
(Apr 11, 2017 04:26:41) Contacting MathWorks
*(Apr 11, 2017 04:26:47) Error: Unable to write to
/usr/local/MATLAB/R2017a.*
Select a different folder.
(Apr 11, 2017 04:26:54) The installation is not complete. If you quit now, you will need to restart the installation from the beginning.
Do you really want to quit now?
(Apr 11, 2017 04:26:57) Exiting with status -1
(Apr 11, 2017 04:26:58) End - Unsuccessful.
(Apr 11, 2017 04:28:37) ##################################################################
(Apr 11, 2017 04:28:37) #
(Apr 11, 2017 04:28:37) # Today's Date:
(Apr 11, 2017 04:28:37) Tue Apr 11 04:28:37 CDT 2017
(Apr 11, 2017 04:28:37)
(Apr 11, 2017 04:28:37) System Info
(Apr 11, 2017 04:28:37) OS: Linux 4.4.0-72-generic
(Apr 11, 2017 04:28:37) Arch: amd64
(Apr 11, 2017 04:28:37) Data Model: 64
(Apr 11, 2017 04:28:37) Language: en
(Apr 11, 2017 04:28:37) Java Vendor: Oracle Corporation
(Apr 11, 2017 04:28:37) Java Home: /usr/local/MATLAB/R2017a/sys/java/jre/glnxa64/jre
(Apr 11, 2017 04:28:37) Java Version: 1.7.0_60
(Apr 11, 2017 04:28:37) Java VM Name: Java HotSpot(TM) 64-Bit Server VM
(Apr 11, 2017 04:28:37) Java Class Path: /usr/local/MATLAB/R2017a/java/config/trialsinstaller/pathlist.jar
(Apr 11, 2017 04:28:37) User Name: pjhellemn
(Apr 11, 2017 04:28:37) Current Directory: /home/pjhellemn/pjh5/stat450/MLSiml/jimmy/demo_GMKL
(Apr 11, 2017 04:28:37) Input arguments:
(Apr 11, 2017 04:28:37) root /usr/local/MATLAB/R2017a
(Apr 11, 2017 04:28:37) libdir /usr/local/MATLAB/R2017a
(Apr 11, 2017 04:28:37) matlabargs "-r "matlab.internal.addons.cdAndShowAddon('BI')""
(Apr 11, 2017 04:28:37) addonMode trialMode
(Apr 11, 2017 04:28:37) entitlementId 3284817
(Apr 11, 2017 04:28:37) Argument not logged
(Apr 11, 2017 04:28:37) basecode.BI true
(Apr 11, 2017 04:28:37) standalone true
(Apr 11, 2017 04:28:38) Starting local product/component search in download directory
(Apr 11, 2017 04:28:38) Searching for archives...
(Apr 11, 2017 04:28:38) /home/pjhellemn/Downloads/MathWorks/R2017a/archives doesn't exist ... skipping.
(Apr 11, 2017 04:28:38) Archive search complete. 0 total files found.
(Apr 11, 2017 04:28:38) Completed local product/component search
(Apr 11, 2017 04:28:41) Contacting MathWorks
(Apr 11, 2017 04:28:46) Error: Unable to write to
/usr/local/MATLAB/R2017a.
Select a different folder.
(Apr 11, 2017 04:29:55) Error: Unable to write to
/usr/local/MATLAB/R2017a.
Select a different folder.
(Apr 11, 2017 04:30:19) Retrieving license data
(Apr 11, 2017 04:30:21) Retrieving product data
(Apr 11, 2017 04:30:23) Verifying account information
(Apr 11, 2017 04:30:26) Completed local product/component search
(Apr 11, 2017 04:30:34) Confirmation Text:
Requested Products:
Bioinformatics Toolbox 4.8
Required Products:
MATLAB 9.2
Statistics and Machine Learning Toolbox 11.1
Required products are automatically included in your trial.
Installation folder:
/usr/local/MATLAB/R2017a
Download Size: 526 MB
Installation Size: 1,301 MB
(Apr 11, 2017 04:30:39) Starting Download: Bioinformatics Toolbox 4.8 : 179,886,072 bytes
(Apr 11, 2017 04:31:17) Starting Download: Statistics and Machine Learning Toolbox 11.1 : 372,455,664 bytes
(Apr 11, 2017 04:32:33) Installing Product: Bioinformatics Toolbox 4.8
*(Apr 11, 2017 04:32:33) java.io.FileNotFoundException: /usr/local/MATLAB/R2017a/bin/glnxa64/libAffymetrixSDK.so (Permission denied)*
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.(Unknown Source)
at com.mathworks.instutil.FileIO.copyToFileFromStream(FileIO.java:491)
at com.mathworks.instutil.FileIO.createFileFromStream(FileIO.java:166)
at com.mathworks.instutil.FileIO.createFileFromStream(FileIO.java:157)
at com.mathworks.install.archive.zip.commonscompress.ArchiveEntryExtractorImpl.extract(ArchiveEntryExtractorImpl.java:37)
at com.mathworks.install.archive.zip.commonscompress.CopyInputStreamToTempZipFileExtractor.extractEntry(CopyInputStreamToTempZipFileExtractor.java:79)
at com.mathworks.install.archive.zip.commonscompress.CopyInputStreamToTempZipFileExtractor.extract(CopyInputStreamToTempZipFileExtractor.java:46)
at com.mathworks.install.archive.DecodeArchiveInputStreamExtractor.extract(DecodeArchiveInputStreamExtractor.java:34)
at com.mathworks.install.input.ArchiveComponentSource.extract(ArchiveComponentSource.java:26)
at com.mathworks.install.InstallableComponentImpl.install(InstallableComponentImpl.java:102)
at com.mathworks.install.ComponentInstallerImpl.installComponent(ComponentInstallerImpl.java:99)
at com.mathworks.install.ComponentInstallerImpl.installComponents(ComponentInstallerImpl.java:58)
at com.mathworks.install.ProductInstallerImpl.installComponents(ProductInstallerImpl.java:225)
at com.mathworks.install.ProductInstallerImpl.installProduct(ProductInstallerImpl.java:211)
at com.mathworks.install.ProductInstallerImpl.installProducts(ProductInstallerImpl.java:88)
at com.mathworks.install.InstallerImpl.install(InstallerImpl.java:113)
at com.mathworks.installwizard.model.InstallTask.execute(InstallTask.java:46)
at com.mathworks.installwizard.model.AbstractBackgroundTask.execute(AbstractBackgroundTask.java:38)
at com.mathworks.installwizard.model.AbstractTask.call(AbstractTask.java:74)
at com.mathworks.installwizard.model.AbstractTask.call(AbstractTask.java:24)
at com.mathworks.wizard.worker.WorkerImpl.doInBackground(WorkerImpl.java:24)
at javax.swing.SwingWorker$1.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at javax.swing.SwingWorker.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
(Apr 11, 2017 04:32:33) The following error was detected while installing 3p/affymetrixsdk_glnxa64:
*/usr/local/MATLAB/R2017a/bin/glnxa64/libAffymetrixSDK.so (Permission denied)*
Would you like to retry installing 3p/affymetrixsdk_glnxa64? If you press No, the installer will exit without completing the installation. More information can be found at /tmp/mathworks_pjhellemn.log
(Apr 11, 2017 04:38:25) Installing Product: Statistics and Machine Learning Toolbox 11.1
*(Apr 11, 2017 04:38:47) java.io.FileNotFoundException: /usr/local/MATLAB/R2017a/toolbox/local/pathdef.m (Permission denied)*
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.(Unknown Source)
at com.mathworks.instutil.FileIO.copyToFileFromStream(FileIO.java:491)
at com.mathworks.instutil.FileIO.createFileFromStream(FileIO.java:166)
at com.mathworks.instutil.FileIO.createFileFromStream(FileIO.java:157)
at com.mathworks.install.command.PathdefGeneratorCommand.writePathdefFile(PathdefGeneratorCommand.java:285)
at com.mathworks.install.command.PathdefGeneratorCommand.generatePathdef(PathdefGeneratorCommand.java:93)
at com.mathworks.install.command.PathdefGeneratorCommand.execute(PathdefGeneratorCommand.java:59)
at com.mathworks.matlabinstaller.AbstractMatlabInstallConfiguration$3.execute(AbstractMatlabInstallConfiguration.java:489)
at com.mathworks.install.InstallModule$1.installProducts(InstallModule.java:202)
at com.mathworks.install.InstallerImpl.install(InstallerImpl.java:113)
at com.mathworks.installwizard.model.InstallTask.execute(InstallTask.java:46)
at com.mathworks.installwizard.model.AbstractBackgroundTask.execute(AbstractBackgroundTask.java:38)
at com.mathworks.installwizard.model.AbstractTask.call(AbstractTask.java:74)
at com.mathworks.installwizard.model.AbstractTask.call(AbstractTask.java:24)
at com.mathworks.wizard.worker.WorkerImpl.doInBackground(WorkerImpl.java:24)
at javax.swing.SwingWorker$1.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at javax.swing.SwingWorker.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
(Apr 11, 2017 04:38:47) Error: The application encountered an unexpected error and needs to close. You may want to try re-installing your product(s). More information can be found at /tmp/mathworks_pjhellemn.log
(Apr 11, 2017 04:40:26) Exiting with status -1
(Apr 11, 2017 04:40:27) End - Unsuccessful.
(Apr 11, 2017 04:42:03) ##################################################################
(Apr 11, 2017 04:42:03) #
(Apr 11, 2017 04:42:03) # Today's Date:
(Apr 11, 2017 04:42:03) Tue Apr 11 04:42:03 CDT 2017
(Apr 11, 2017 04:42:03)
(Apr 11, 2017 04:42:03) System Info
(Apr 11, 2017 04:42:03) OS: Linux 4.4.0-72-generic
(Apr 11, 2017 04:42:03) Arch: amd64
(Apr 11, 2017 04:42:03) Data Model: 64
(Apr 11, 2017 04:42:03) Language: en
(Apr 11, 2017 04:42:03) Java Vendor: Oracle Corporation
(Apr 11, 2017 04:42:03) Java Home: /usr/local/MATLAB/R2017a/sys/java/jre/glnxa64/jre
(Apr 11, 2017 04:42:03) Java Version: 1.7.0_60
(Apr 11, 2017 04:42:03) Java VM Name: Java HotSpot(TM) 64-Bit Server VM
(Apr 11, 2017 04:42:03) Java Class Path: /usr/local/MATLAB/R2017a/java/config/trialsinstaller/pathlist.jar
(Apr 11, 2017 04:42:03) User Name: pjhellemn
(Apr 11, 2017 04:42:03) Current Directory: /home/pjhellemn/pjh5/stat450/MLSiml/jimmy/demo_GMKL
(Apr 11, 2017 04:42:03) Input arguments:
(Apr 11, 2017 04:42:03) root /usr/local/MATLAB/R2017a
(Apr 11, 2017 04:42:03) libdir /usr/local/MATLAB/R2017a
(Apr 11, 2017 04:42:03) matlabargs "-r "matlab.internal.addons.cdAndShowAddon('BI')""
(Apr 11, 2017 04:42:03) addonMode trialMode
(Apr 11, 2017 04:42:03) entitlementId 3284817
(Apr 11, 2017 04:42:03) Argument not logged
(Apr 11, 2017 04:42:03) basecode.BI true
(Apr 11, 2017 04:42:03) standalone true
(Apr 11, 2017 04:42:04) Starting local product/component search in download directory
(Apr 11, 2017 04:42:04) Searching for archives...
(Apr 11, 2017 04:42:04) Reading /home/pjhellemn/Downloads/MathWorks/R2017a/archives
(Apr 11, 2017 04:42:04) 84 files found in /home/pjhellemn/Downloads/MathWorks/R2017a/archives
(Apr 11, 2017 04:42:04) Archive search complete. 84 total files found.
(Apr 11, 2017 04:42:04) Completed local product/component search
(Apr 11, 2017 04:42:08) Contacting MathWorks
(Apr 11, 2017 04:42:18) Retrieving license data
(Apr 11, 2017 04:42:19) Assembling product list...
(Apr 11, 2017 04:42:19) Retrieving product data
(Apr 11, 2017 04:42:20) Verifying account information
(Apr 11, 2017 04:42:26) Completed local product/component search
(Apr 11, 2017 04:42:29) Confirmation Text:
Requested Products:
Bioinformatics Toolbox 4.8
Required Products:
MATLAB 9.2
Statistics and Machine Learning Toolbox 11.1
Required products are automatically included in your trial.
Installation folder:
/usr/local/MATLAB/R2017a
Installation Size: 774 MB
(Apr 11, 2017 04:42:32) Installing Product: Bioinformatics Toolbox 4.8
(Apr 11, 2017 04:42:42) Installing Product: Statistics and Machine Learning Toolbox 11.1
*(Apr 11, 2017 04:42:59) java.io.FileNotFoundException: /usr/local/MATLAB/R2017a/toolbox/local/pathdef.m (Permission denied)*
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.(Unknown Source)
at com.mathworks.instutil.FileIO.copyToFileFromStream(FileIO.java:491)
at com.mathworks.instutil.FileIO.createFileFromStream(FileIO.java:166)
at com.mathworks.instutil.FileIO.createFileFromStream(FileIO.java:157)
at com.mathworks.install.command.PathdefGeneratorCommand.writePathdefFile(PathdefGeneratorCommand.java:285)
at com.mathworks.install.command.PathdefGeneratorCommand.generatePathdef(PathdefGeneratorCommand.java:93)
at com.mathworks.install.command.PathdefGeneratorCommand.execute(PathdefGeneratorCommand.java:59)
at com.mathworks.matlabinstaller.AbstractMatlabInstallConfiguration$3.execute(AbstractMatlabInstallConfiguration.java:489)
at com.mathworks.install.InstallModule$1.installProducts(InstallModule.java:202)
at com.mathworks.install.InstallerImpl.install(InstallerImpl.java:113)
at com.mathworks.installwizard.model.InstallTask.execute(InstallTask.java:46)
at com.mathworks.installwizard.model.AbstractBackgroundTask.execute(AbstractBackgroundTask.java:38)
at com.mathworks.installwizard.model.AbstractTask.call(AbstractTask.java:74)
at com.mathworks.installwizard.model.AbstractTask.call(AbstractTask.java:24)
at com.mathworks.wizard.worker.WorkerImpl.doInBackground(WorkerImpl.java:24)
at javax.swing.SwingWorker$1.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at javax.swing.SwingWorker.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
(Apr 11, 2017 04:42:59) Error: The application encountered an unexpected error and needs to close. You may want to try re-installing your product(s). More information can be found at /tmp/mathworks_pjhellemn.log
(Apr 11, 2017 04:45:03) Exiting with status -1
(Apr 11, 2017 04:45:04) End - Unsuccessful.
(Apr 11, 2017 04:46:50) ##################################################################
(Apr 11, 2017 04:46:50) #
(Apr 11, 2017 04:46:50) # Today's Date:
(Apr 11, 2017 04:46:50) Tue Apr 11 04:46:50 CDT 2017
(Apr 11, 2017 04:46:50)
(Apr 11, 2017 04:46:50) System Info
(Apr 11, 2017 04:46:50) OS: Linux 4.4.0-72-generic
(Apr 11, 2017 04:46:50) Arch: amd64
(Apr 11, 2017 04:46:50) Data Model: 64
(Apr 11, 2017 04:46:50) Language: en
(Apr 11, 2017 04:46:50) Java Vendor: Oracle Corporation
(Apr 11, 2017 04:46:50) Java Home: /usr/local/MATLAB/R2017a/sys/java/jre/glnxa64/jre
(Apr 11, 2017 04:46:50) Java Version: 1.7.0_60
(Apr 11, 2017 04:46:50) Java VM Name: Java HotSpot(TM) 64-Bit Server VM
(Apr 11, 2017 04:46:50) Java Class Path: /usr/local/MATLAB/R2017a/java/config/trialsinstaller/pathlist.jar
(Apr 11, 2017 04:46:50) User Name: pjhellemn
(Apr 11, 2017 04:46:50) Current Directory: /home/pjhellemn/pjh5/stat450/MLSiml/jimmy/demo_GMKL
(Apr 11, 2017 04:46:50) Input arguments:
(Apr 11, 2017 04:46:50) root /usr/local/MATLAB/R2017a
(Apr 11, 2017 04:46:50) libdir /usr/local/MATLAB/R2017a
(Apr 11, 2017 04:46:50) matlabargs "-r "matlab.internal.addons.cdAndShowAddon('BI')""
(Apr 11, 2017 04:46:50) addonMode trialMode
(Apr 11, 2017 04:46:50) entitlementId 3284817
(Apr 11, 2017 04:46:50) Argument not logged
(Apr 11, 2017 04:46:50) basecode.BI true
(Apr 11, 2017 04:46:50) standalone true
(Apr 11, 2017 04:46:51) Starting local product/component search in download directory
(Apr 11, 2017 04:46:51) Searching for archives...
(Apr 11, 2017 04:46:51) Reading /home/pjhellemn/Downloads/MathWorks/R2017a/archives
(Apr 11, 2017 04:46:51) 84 files found in /home/pjhellemn/Downloads/MathWorks/R2017a/archives
(Apr 11, 2017 04:46:51) Archive search complete. 84 total files found.
(Apr 11, 2017 04:46:51) Completed local product/component search
(Apr 11, 2017 04:46:53) Contacting MathWorks
(Apr 11, 2017 04:47:01) Retrieving license data
(Apr 11, 2017 04:47:02) Retrieving product data
(Apr 11, 2017 04:47:03) Verifying account information
(Apr 11, 2017 04:47:05) Completed local product/component search
(Apr 11, 2017 04:47:08) Confirmation Text:
Requested Products:
Bioinformatics Toolbox 4.8
Required Products:
MATLAB 9.2
Statistics and Machine Learning Toolbox 11.1
Required products are automatically included in your trial.
Installation folder:
/usr/local/MATLAB/R2017a
Installation Size: 774 MB
(Apr 11, 2017 04:47:14) Installing Product: Bioinformatics Toolbox 4.8
(Apr 11, 2017 04:47:21) Installing Product: Statistics and Machine Learning Toolbox 11.1
*(Apr 11, 2017 04:47:36) java.io.IOException: Error 1 setting permissions for /usr/local/MATLAB/R2017a/toolbox/local/pathdef.m. Operation not permitted*
at com.mathworks.instutil.FilePermissionsUtil.setUnixFilePerms(Native Method)
at com.mathworks.instutil.FilePermissionsUtil.setFilePermissions(FilePermissionsUtil.java:263)
at com.mathworks.instutil.FileIO.createFileFromStream(FileIO.java:168)
at com.mathworks.instutil.FileIO.createFileFromStream(FileIO.java:157)
at com.mathworks.install.command.PathdefGeneratorCommand.writePathdefFile(PathdefGeneratorCommand.java:285)
at com.mathworks.install.command.PathdefGeneratorCommand.generatePathdef(PathdefGeneratorCommand.java:93)
at com.mathworks.install.command.PathdefGeneratorCommand.execute(PathdefGeneratorCommand.java:59)
at com.mathworks.matlabinstaller.AbstractMatlabInstallConfiguration$3.execute(AbstractMatlabInstallConfiguration.java:489)
at com.mathworks.install.InstallModule$1.installProducts(InstallModule.java:202)
at com.mathworks.install.InstallerImpl.install(InstallerImpl.java:113)
at com.mathworks.installwizard.model.InstallTask.execute(InstallTask.java:46)
at com.mathworks.installwizard.model.AbstractBackgroundTask.execute(AbstractBackgroundTask.java:38)
at com.mathworks.installwizard.model.AbstractTask.call(AbstractTask.java:74)
at com.mathworks.installwizard.model.AbstractTask.call(AbstractTask.java:24)
at com.mathworks.wizard.worker.WorkerImpl.doInBackground(WorkerImpl.java:24)
at javax.swing.SwingWorker$1.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at javax.swing.SwingWorker.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
(Apr 11, 2017 04:47:36) Error: The application encountered an unexpected error and needs to close. You may want to try re-installing your product(s). More information can be found at /tmp/mathworks_pjhellemn.log
(Apr 11, 2017 04:48:24) Exiting with status -1
(Apr 11, 2017 04:48:25) End - Unsuccessful.
(Apr 11, 2017 12:32:00) ##################################################################
(Apr 11, 2017 12:32:00) #
(Apr 11, 2017 12:32:00) # Today's Date:
(Apr 11, 2017 12:32:00) Tue Apr 11 12:32:00 CDT 2017
(Apr 11, 2017 12:32:00)
(Apr 11, 2017 12:32:00) System Info
(Apr 11, 2017 12:32:00) OS: Linux 4.4.0-72-generic
(Apr 11, 2017 12:32:00) Arch: amd64
(Apr 11, 2017 12:32:00) Data Model: 64
(Apr 11, 2017 12:32:00) Language: en
(Apr 11, 2017 12:32:00) Java Vendor: Oracle Corporation
(Apr 11, 2017 12:32:00) Java Home: /usr/local/MATLAB/R2017a/sys/java/jre/glnxa64/jre
(Apr 11, 2017 12:32:00) Java Version: 1.7.0_60
(Apr 11, 2017 12:32:00) Java VM Name: Java HotSpot(TM) 64-Bit Server VM
(Apr 11, 2017 12:32:00) Java Class Path: /usr/local/MATLAB/R2017a/java/config/trialsinstaller/pathlist.jar
(Apr 11, 2017 12:32:00) User Name: pjhellemn
(Apr 11, 2017 12:32:00) Current Directory: /home/pjhellemn/pjh5/stat450/MLSiml/jimmy/demo_GMKL
(Apr 11, 2017 12:32:00) Input arguments:
(Apr 11, 2017 12:32:00) root /usr/local/MATLAB/R2017a
(Apr 11, 2017 12:32:00) libdir /usr/local/MATLAB/R2017a
(Apr 11, 2017 12:32:00) matlabargs "-r "matlab.internal.addons.cdAndShowAddon('BI')""
(Apr 11, 2017 12:32:00) addonMode trialMode
(Apr 11, 2017 12:32:00) entitlementId 3284817
(Apr 11, 2017 12:32:00) Argument not logged
(Apr 11, 2017 12:32:00) basecode.BI true
(Apr 11, 2017 12:32:00) standalone true
(Apr 11, 2017 12:32:01) Starting local product/component search in download directory
(Apr 11, 2017 12:32:01) Searching for archives...
(Apr 11, 2017 12:32:01) /home/pjhellemn/Downloads/MathWorks/R2017a/archives doesn't exist ... skipping.
(Apr 11, 2017 12:32:01) Archive search complete. 0 total files found.
(Apr 11, 2017 12:32:01) Completed local product/component search
(Apr 11, 2017 12:32:03) Contacting MathWorks
(Apr 11, 2017 12:32:08) Error: Unable to write to
/usr/local/MATLAB/R2017a.
Select a different folder.
(Apr 11, 2017 12:32:15) The installation is not complete. If you quit now, you will need to restart the installation from the beginning.
Do you really want to quit now?
(Apr 11, 2017 12:32:16) Exiting with status -1
(Apr 11, 2017 12:32:17) End - Unsuccessful.Paul Hellemnhttps://ch.mathworks.com/matlabcentral/profile/authors/8607892tag:ch.mathworks.com,2005:Question/6653582020-11-27T15:57:04Z2020-11-27T15:57:04ZHow to plot sum of series?
I am trying to plot the function above on interval [-2,2]. I was wondering if the code below is a correct way to do it.
syms n x
f(x)=symsum((((((-1)^(n+1))/(5*n)))*cos((n-1)*x)),n,1,Inf);
figure
fplot(x,[-2 2])
Also, how do I plot the partial sums F1,F2 and F10 on the interval [-2,2] and have them all on the same plot figure.Teb Kebhttps://ch.mathworks.com/matlabcentral/profile/authors/19284581tag:ch.mathworks.com,2005:Question/6613832020-11-25T05:10:22Z2020-11-27T15:56:57ZConditionally select rows and add to new tableFor example, I have a 2000 x 3 table: Column_1: Datetime Column_2: Rain Column_3: Soil Moisture
The actual table has more variables but I plan to get to it once I know how to undergo the coding.
The idea is to append the rows to a new table if they meet these conditions:
1) While rain > 3 and ends when rain < 2 for 2 subsequent days
2) The 1st condition cannot be less than 4 days
I've been trying to code this out but have gone nowhere:
for i = 1:height(ddtable)
ii = 0;
finaldd(:,:) = [];
while ddtable.RAIN > 3
ii = ii + 1;
if ii < 4
break
elseif ii > 4
finaldd(ddtable);
end
end
endJonathan Cheonghttps://ch.mathworks.com/matlabcentral/profile/authors/15392330tag:ch.mathworks.com,2005:Question/6650632020-11-27T10:47:54Z2020-11-27T15:56:04ZHow can i convert my code from symbolic to numerical so that i can use if statementsfunction [Result1] = Untitled3(u)
syms X1(t) X2(t) M g alph Y t S R
Dy = diff(X1,t);
Dx = diff(X2,t);
EqX1 = diff(X1,2) == -g + (R*R*( acos(1 - abs(X1)/(R*sind(20))) - (1 - abs(X1)/(R*sind(20)))*( 1 - (1 - abs(X1)/(R*sind(20)))^2)^0.5 ))*(0.5*997*(Dx^2+Dy^2)*abs(sind(alph+atan(Dy/Dx))*cosd(alph)))/M; %Y COORDINATES
EqX2 = diff(X2,2) == - (R*R*( acos(1 - abs(X1)/(R*sind(20))) - (1 - abs(X1)/(R*sind(20)))*( 1 - (1 - abs(X1)/(R*sind(20)))^2)^0.5 ))*(0.5*997*(Dx^2+Dy^2)*abs(sind(alph+atan(Dy/Dx))*sind(alph)))/M; %X COORDINATES
%S == (R*R*( acos(1 - abs(X1)/(R*sind(20))) - (1 - abs(X1)/(R*sind(20)))*( 1 - (1 - abs(X1)/(R*sind(20)))^2)^0.5 ));
[ODE,Vars] = odeToVectorField(EqX2, EqX1);
Sys = matlabFunction(ODE, 'Vars', {t, Y, M ,g , alph, S , R });
M=0.1;
g=9.81;
alph=20;
R=0.05;
ic = [0 -u*sind(alph) 0 u*cosd(alph)];
% initial conditions- [Y Y' X X']
tspan = [0,0.02];
[T,Y] = ode45(@(t,Y)Sys(t, Y, M ,g , alph, S , R ), tspan, ic);
plot(Y(:,3),Y(:,1),'r');
hold on;
% plot(T,Y(:,1),'r'); %Y plot
% plot(T,Y(:,3),'g'); %Y'plot
% plot(T,Y(:,2),'b'); %X plot
% plot(T,Y(:,4),'k'); %X'plot
hold off
grid;
end
Ajay Paralkarhttps://ch.mathworks.com/matlabcentral/profile/authors/15009110tag:ch.mathworks.com,2005:Question/6639332020-11-26T17:50:36Z2020-11-27T15:36:47ZCreating M histograms from an NxM table on separate plots Hi there,
I have an N x M table and I am trying to create M histograms on different plots, I can't seem to figure out how to plot them on different figures. If I hold on, they all plot on the same axis'
data = readtable('file.csv'); % Import in wine raw data
predictors = data(:,1:width(data)-1); % remove quality as it is our output
headers = predictors.Properties.VariableNames; % Get predictor labels
%% Lets check to see how our predictors are distributed
statarray = grpstats(predictors,[],{'mean','std'})
for k = width(headers);
a = table2array(predictors(:,k)); % Converting from table to array for hist
histogram(a)
title(headers(1,k))
end
I'm also not sure why I can't pass a table row to a histogram and need to table2array the data.
Any help would be greatly appreciated. Thank youJeremy Brecevichttps://ch.mathworks.com/matlabcentral/profile/authors/20142413tag:ch.mathworks.com,2005:Question/6653382020-11-27T15:22:30Z2020-11-27T15:35:28ZOptimization of a unknown vector variableHello ,
I have a code
a,b -----> variables should be vector(like a=[a1,a2,a3,a4])
x=h1*a^2+h2*b^2+h3;------>objctive fun(h1,h2,h3 are constants)
---->constraints are also present here.. so I am writting the code like
for i=1:4
obj(i)= h1*a^2+h2*b^2+h3;
end
x0=[1,1];
lb = [];
ub = [];
Aeq = [];
beq =[];
A = [];
b = [];
fun=obj;
nonlcon =@constraintfcn;
opts = optimoptions('fmincon','Display','iter','Algorithm','sqp');
[x_value,fval] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,opts);
But I am not getting the ans,I want optimized value as vector .Soumili Senhttps://ch.mathworks.com/matlabcentral/profile/authors/19922466tag:ch.mathworks.com,2005:Question/6588582020-11-23T13:25:00Z2020-11-27T15:34:29ZIs it possible to find out an unknown variable within constraint which is not present in the objective for a optimization problem?Hello all,
Suppose I have a objective function with unknown variable x(1). But my constraint is depend on unknown variable x(1) and x(2). Is it logically possible to find out a optimized value for x(2) using 'fmincon' command?Soumili Senhttps://ch.mathworks.com/matlabcentral/profile/authors/19922466