Category: Matlab
Category Archives: Matlab
CWT on each frequency one at a time
I have a very large matrix (512×1500000) and I want to run CWT on each row. However, since CWT creates a new dimension with its frequency bands, I am running into memory issues. I do not need to store all frequency bands; I just need to run the analysis on each frequency band individually. So, I am wondering if there is a way to run CWT on each frequency band one at a time in a for loop.I have a very large matrix (512×1500000) and I want to run CWT on each row. However, since CWT creates a new dimension with its frequency bands, I am running into memory issues. I do not need to store all frequency bands; I just need to run the analysis on each frequency band individually. So, I am wondering if there is a way to run CWT on each frequency band one at a time in a for loop. I have a very large matrix (512×1500000) and I want to run CWT on each row. However, since CWT creates a new dimension with its frequency bands, I am running into memory issues. I do not need to store all frequency bands; I just need to run the analysis on each frequency band individually. So, I am wondering if there is a way to run CWT on each frequency band one at a time in a for loop. signal processing, cwt MATLAB Answers — New Questions
Is there a way I can refer to current open tabs on my computer?
I want to make a GUI that makes the user select a tab on their computer to then look at that tab to analyse it as an input for an image analysis process. Is there a way to refer to open computer tabs in Matlab?I want to make a GUI that makes the user select a tab on their computer to then look at that tab to analyse it as an input for an image analysis process. Is there a way to refer to open computer tabs in Matlab? I want to make a GUI that makes the user select a tab on their computer to then look at that tab to analyse it as an input for an image analysis process. Is there a way to refer to open computer tabs in Matlab? gui, guide, image acquisition MATLAB Answers — New Questions
I am trying to solve a Matlab Simulink problem
Hello, I am having rrouble with this problem, i tried the constant block, ramp block but didnt work out, can ayone please help me with itHello, I am having rrouble with this problem, i tried the constant block, ramp block but didnt work out, can ayone please help me with it Hello, I am having rrouble with this problem, i tried the constant block, ramp block but didnt work out, can ayone please help me with it simulink block MATLAB Answers — New Questions
In HDL Workflow Advisor, why there doesn’t exist a platform for ZCU102 and FMCOMMS5?
In the documention: Hardware-Software Co-Design Workflow, it shows a way to deploy SDR algorithms for Xilinx® Zynq®-based radio hardware.
Actually, I got the message that ZCU102 is able to be linked with FMCOMMS5.
However, in the Step 4. Generate HDL IP Core Using HDL Workflow Advisor, I find the ZCU102 can only support FMCOMMS2/3/4, no FMCOMMS5!!
Is there somthing wrong with this documention? Is there some ways that I’m able to use the ZCU102 and FMCOMMS5 as my target platform?
I’m of strong desire for your replying, Thanks a lot!In the documention: Hardware-Software Co-Design Workflow, it shows a way to deploy SDR algorithms for Xilinx® Zynq®-based radio hardware.
Actually, I got the message that ZCU102 is able to be linked with FMCOMMS5.
However, in the Step 4. Generate HDL IP Core Using HDL Workflow Advisor, I find the ZCU102 can only support FMCOMMS2/3/4, no FMCOMMS5!!
Is there somthing wrong with this documention? Is there some ways that I’m able to use the ZCU102 and FMCOMMS5 as my target platform?
I’m of strong desire for your replying, Thanks a lot! In the documention: Hardware-Software Co-Design Workflow, it shows a way to deploy SDR algorithms for Xilinx® Zynq®-based radio hardware.
Actually, I got the message that ZCU102 is able to be linked with FMCOMMS5.
However, in the Step 4. Generate HDL IP Core Using HDL Workflow Advisor, I find the ZCU102 can only support FMCOMMS2/3/4, no FMCOMMS5!!
Is there somthing wrong with this documention? Is there some ways that I’m able to use the ZCU102 and FMCOMMS5 as my target platform?
I’m of strong desire for your replying, Thanks a lot! hdl workflow advisor, zcu102, fmcomms5, target platform MATLAB Answers — New Questions
How do I call Matlab polyfit function from C++?
Hello, I am trying to call the MATLAB polyfit function from a Windows application written in Visual Studio 2022 C++ and get the polynomial coefficients array, s, and mu from from polyfit.
int main(int argc, char* argv[])
{
double x[40];
double y[40];
double p[12]; // MATLAB returned array of coefficients
size_t dataSize;
// this function gets the data from a file and updates the unknown xy data size
// the data size = 40 elements
getXYpoints(x, y, &dataSize);
if (dataSize == 0)
{
cout << endl << "File Size is Zero, nothing to do";
return -2;
}
polyFit(x, y, p,dataSize, 12); // 12 is the order of the polynomials
}
The polyFit calls the MATLAB polyfit function
void polyFit(double* x, double* y, double* poly_coefficients, size_t xy_size, size_t poly_size)
{
using namespace matlab::engine;
// Start MATLAB engine synchronously
std::unique_ptr<MATLABEngine> matlabPtr = startMATLAB();
std::tuple<double, double, double> nresults;
// the following line gives a compile error for x, y, and the tuple definitions
nresults = matlabPtr->feval<std::tuple <double*, double, double>>(u"polyfit", x , y, poly_size);
//[p, s, mu] = polyfit (x,y, 12);
double P;
double S;
double MU;
std::tie(P, S, MU) = nresults;
for (auto it : p)
{
p[it] = P[it];
}
auto s = S;
auto mu = MU;
.
.
.
}
tuple <double*, double, double> tuple does not seem to support the first argument double*. Is there a better way to call polyfit from C++, or how do I overload the tuple class to accept a pointer to P (the polynomial coefficients array).Hello, I am trying to call the MATLAB polyfit function from a Windows application written in Visual Studio 2022 C++ and get the polynomial coefficients array, s, and mu from from polyfit.
int main(int argc, char* argv[])
{
double x[40];
double y[40];
double p[12]; // MATLAB returned array of coefficients
size_t dataSize;
// this function gets the data from a file and updates the unknown xy data size
// the data size = 40 elements
getXYpoints(x, y, &dataSize);
if (dataSize == 0)
{
cout << endl << "File Size is Zero, nothing to do";
return -2;
}
polyFit(x, y, p,dataSize, 12); // 12 is the order of the polynomials
}
The polyFit calls the MATLAB polyfit function
void polyFit(double* x, double* y, double* poly_coefficients, size_t xy_size, size_t poly_size)
{
using namespace matlab::engine;
// Start MATLAB engine synchronously
std::unique_ptr<MATLABEngine> matlabPtr = startMATLAB();
std::tuple<double, double, double> nresults;
// the following line gives a compile error for x, y, and the tuple definitions
nresults = matlabPtr->feval<std::tuple <double*, double, double>>(u"polyfit", x , y, poly_size);
//[p, s, mu] = polyfit (x,y, 12);
double P;
double S;
double MU;
std::tie(P, S, MU) = nresults;
for (auto it : p)
{
p[it] = P[it];
}
auto s = S;
auto mu = MU;
.
.
.
}
tuple <double*, double, double> tuple does not seem to support the first argument double*. Is there a better way to call polyfit from C++, or how do I overload the tuple class to accept a pointer to P (the polynomial coefficients array). Hello, I am trying to call the MATLAB polyfit function from a Windows application written in Visual Studio 2022 C++ and get the polynomial coefficients array, s, and mu from from polyfit.
int main(int argc, char* argv[])
{
double x[40];
double y[40];
double p[12]; // MATLAB returned array of coefficients
size_t dataSize;
// this function gets the data from a file and updates the unknown xy data size
// the data size = 40 elements
getXYpoints(x, y, &dataSize);
if (dataSize == 0)
{
cout << endl << "File Size is Zero, nothing to do";
return -2;
}
polyFit(x, y, p,dataSize, 12); // 12 is the order of the polynomials
}
The polyFit calls the MATLAB polyfit function
void polyFit(double* x, double* y, double* poly_coefficients, size_t xy_size, size_t poly_size)
{
using namespace matlab::engine;
// Start MATLAB engine synchronously
std::unique_ptr<MATLABEngine> matlabPtr = startMATLAB();
std::tuple<double, double, double> nresults;
// the following line gives a compile error for x, y, and the tuple definitions
nresults = matlabPtr->feval<std::tuple <double*, double, double>>(u"polyfit", x , y, poly_size);
//[p, s, mu] = polyfit (x,y, 12);
double P;
double S;
double MU;
std::tie(P, S, MU) = nresults;
for (auto it : p)
{
p[it] = P[it];
}
auto s = S;
auto mu = MU;
.
.
.
}
tuple <double*, double, double> tuple does not seem to support the first argument double*. Is there a better way to call polyfit from C++, or how do I overload the tuple class to accept a pointer to P (the polynomial coefficients array). polyfit, c++, visual studio c++, call matlab from c++ MATLAB Answers — New Questions
Sum function handles efficiently
I need to solve an ODE where the motion is determined by charges in position (where and ). For the sake of simplicity let’s just assume that and that the dynamic given by the particle in is given by (i.e. I need to solve). I just need to solve an ODE where the motion is determined by the effects of the charges combined, and in my case the dynamic is simply given by the sum of the functions . I tried definining function handles stored in a 2 dimensional array of size , where in position I store the function . Then, I would need to define and solve an ODE where the motion is determined by . The way I did this is by recursion, i.e.:
%I have already defined f as a 2D array, where f{i,j}=f_{i,j} described
%in the text
F= @(t,x) 0;
for i= 1:1:N
for j=1:1:N
F= @(t,x) F(t,x) + f{i,j}(t,x)
end
end
After this, I use the solve function:
fun = ode(ODEFcn=@(t,x) F(t,x),InitialTime=0,InitialValue=[0,0]); % Set up the problem by creating an ode object
sol = solve(fun,0,100); % Solve it over the interval [0,10]
The problem is: the performance is very bad. I already see this when defining . I think there might be some issues with the recursion, nad maybe there’s a better way for defining , in such a way that the performances get better.I need to solve an ODE where the motion is determined by charges in position (where and ). For the sake of simplicity let’s just assume that and that the dynamic given by the particle in is given by (i.e. I need to solve). I just need to solve an ODE where the motion is determined by the effects of the charges combined, and in my case the dynamic is simply given by the sum of the functions . I tried definining function handles stored in a 2 dimensional array of size , where in position I store the function . Then, I would need to define and solve an ODE where the motion is determined by . The way I did this is by recursion, i.e.:
%I have already defined f as a 2D array, where f{i,j}=f_{i,j} described
%in the text
F= @(t,x) 0;
for i= 1:1:N
for j=1:1:N
F= @(t,x) F(t,x) + f{i,j}(t,x)
end
end
After this, I use the solve function:
fun = ode(ODEFcn=@(t,x) F(t,x),InitialTime=0,InitialValue=[0,0]); % Set up the problem by creating an ode object
sol = solve(fun,0,100); % Solve it over the interval [0,10]
The problem is: the performance is very bad. I already see this when defining . I think there might be some issues with the recursion, nad maybe there’s a better way for defining , in such a way that the performances get better. I need to solve an ODE where the motion is determined by charges in position (where and ). For the sake of simplicity let’s just assume that and that the dynamic given by the particle in is given by (i.e. I need to solve). I just need to solve an ODE where the motion is determined by the effects of the charges combined, and in my case the dynamic is simply given by the sum of the functions . I tried definining function handles stored in a 2 dimensional array of size , where in position I store the function . Then, I would need to define and solve an ODE where the motion is determined by . The way I did this is by recursion, i.e.:
%I have already defined f as a 2D array, where f{i,j}=f_{i,j} described
%in the text
F= @(t,x) 0;
for i= 1:1:N
for j=1:1:N
F= @(t,x) F(t,x) + f{i,j}(t,x)
end
end
After this, I use the solve function:
fun = ode(ODEFcn=@(t,x) F(t,x),InitialTime=0,InitialValue=[0,0]); % Set up the problem by creating an ode object
sol = solve(fun,0,100); % Solve it over the interval [0,10]
The problem is: the performance is very bad. I already see this when defining . I think there might be some issues with the recursion, nad maybe there’s a better way for defining , in such a way that the performances get better. ode, matlab function, solve, performance MATLAB Answers — New Questions
Is MathWorks removing the concurrent license option from the Campus-Wide License offering?
MathWorks has announced their move away from MATLAB (Concurrent) to MATLAB (Individual) for shared teaching labs and computer classrooms. Does this mean that the MATLAB (Concurrent) license is being removed?MathWorks has announced their move away from MATLAB (Concurrent) to MATLAB (Individual) for shared teaching labs and computer classrooms. Does this mean that the MATLAB (Concurrent) license is being removed? MathWorks has announced their move away from MATLAB (Concurrent) to MATLAB (Individual) for shared teaching labs and computer classrooms. Does this mean that the MATLAB (Concurrent) license is being removed? MATLAB Answers — New Questions
Saving figure as .svg alters appearance
Hi,
I’m making figures in MATLAB and want to export them in .svg to work with them in other programs. So far, that has been no problem, but I’m stumbling into something odd now. I’m trying to export this figure:
As you can see, this works fine in .png. This is also what the figure looks like in MATLAB. However, when I export as .svg, the blue patch that I plotted around the line to indicate the SEM continues until 10 seconds instead of 5:
I think this might be because I’m first plotting the patch, and then alter the x axis. However, this is not visible in the matlab figure, and the red and green patches show no problem for this.
My code is as follows:
xaxeslimits = [-5 5];
f = figure(‘InvertHardcopy’,’off’,’Color’,[1 1 1]);
t = tiledlayout(size(ROIs,2)/2, 2);
x = linspace(-5, 10, 226);
tileind = 2;
for roi = 1:size(ROIs, 2)
nexttile(tileind)
title(ROInames{roi})
eval([‘yhbo = means.hbo.’ ROIs{roi} ‘;’])
eval([‘SEMhbo = sems.hbo.’ ROIs{roi} ‘;’])
eval([‘yhbr = means.hbr.’ ROIs{roi} ‘;’])
eval([‘SEMhbr = sems.hbr.’ ROIs{roi} ‘;’])
eval([‘y = means.fluo.’ ROIs{roi} ‘;’])
eval([‘SEM = sems.fluo.’ ROIs{roi} ‘;’])
y = y-1; % to get centered around 0
% HbO
yyaxis right
plot(x, yhbo, ‘Color’, ‘red’, ‘LineWidth’, 2)
patch([x, fliplr(x)], [yhbo + SEMhbo fliplr(yhbo – SEMhbo)], ‘r’ ,’EdgeColor’,’none’, ‘FaceAlpha’,0.25)
hold on
% HbR
plot(x, yhbr, ‘Color’, ‘blue’, ‘LineStyle’, ‘-‘, ‘LineWidth’, 2)
patch([x, fliplr(x)], [yhbr + SEMhbr fliplr(yhbr – SEMhbr)], ‘b’ ,’EdgeColor’,’none’, ‘FaceAlpha’,0.25)
ylim([-1.5 1.5]);
h_label = ylabel(‘Delta muM’, ‘interpreter’, ‘Tex’, ‘Rotation’, 270);
ax = gca;
ax.YColor = ‘red’;
ax.XColor = ‘k’;
set(ax, ‘FontSize’, 15, ‘LineWidth’, 2)
xlim(xaxeslimits);
% Fluo
yyaxis left
plot(x,y, ‘Color’, [0.4660 0.6740 0.1880], ‘LineWidth’, 2);
patch([x, fliplr(x)], [y + SEM fliplr(y – SEM)], ‘g’ ,’EdgeColor’,’none’, ‘FaceAlpha’,0.25)
f_label = ylabel(‘Delta F/F’);
ylim([-0.05 0.05]); % centered at 0
ax = gca;
ax.YColor = [0.4660 0.6740 0.1880];
ax.XColor = ‘k’;
set(ax, ‘FontSize’, 15, ‘LineWidth’, 2)
xlabel(‘Time (sec)’)
xlim(xaxeslimits);
if tileind == size(ROIs, 2)
tileind = 1;
else
tileind = tileind+2;
end
end
leg1 = legend({‘GCaMP’, ‘SEM’, ‘HbO’,’SEM’, ‘HbR’,’SEM’}, ‘Orientation’, ‘Horizontal’);
leg1.Location = ‘southoutside’;
% f.Position = [10 10 1800 1000];
f.Position = [10 10 900 1000];
% save
pause(0.5)
% saveas(gcf, [SaveDir ‘/NVC/Sham_RS/’ Acq ‘_’ type ‘_’ ROIsavename ‘_AvCurves.tiff’], ‘tiff’);
% saveas(gcf, [SaveDir ‘/NVC/Sham_RS/’ Acq ‘_’ type ‘_’ ROIsavename ‘_AvCurves.eps’], ‘epsc’);
saveas(gcf, [SaveDir ‘/NVC/Sham_RS/’ Acq ‘_’ type ‘_’ ROIsavename ‘_AvCurves.svg’], ‘svg’);
close(f)
Does anybody know how to fix this? I’d like to be able to easily alter the x-axis and have it still work.
Best,
MarleenHi,
I’m making figures in MATLAB and want to export them in .svg to work with them in other programs. So far, that has been no problem, but I’m stumbling into something odd now. I’m trying to export this figure:
As you can see, this works fine in .png. This is also what the figure looks like in MATLAB. However, when I export as .svg, the blue patch that I plotted around the line to indicate the SEM continues until 10 seconds instead of 5:
I think this might be because I’m first plotting the patch, and then alter the x axis. However, this is not visible in the matlab figure, and the red and green patches show no problem for this.
My code is as follows:
xaxeslimits = [-5 5];
f = figure(‘InvertHardcopy’,’off’,’Color’,[1 1 1]);
t = tiledlayout(size(ROIs,2)/2, 2);
x = linspace(-5, 10, 226);
tileind = 2;
for roi = 1:size(ROIs, 2)
nexttile(tileind)
title(ROInames{roi})
eval([‘yhbo = means.hbo.’ ROIs{roi} ‘;’])
eval([‘SEMhbo = sems.hbo.’ ROIs{roi} ‘;’])
eval([‘yhbr = means.hbr.’ ROIs{roi} ‘;’])
eval([‘SEMhbr = sems.hbr.’ ROIs{roi} ‘;’])
eval([‘y = means.fluo.’ ROIs{roi} ‘;’])
eval([‘SEM = sems.fluo.’ ROIs{roi} ‘;’])
y = y-1; % to get centered around 0
% HbO
yyaxis right
plot(x, yhbo, ‘Color’, ‘red’, ‘LineWidth’, 2)
patch([x, fliplr(x)], [yhbo + SEMhbo fliplr(yhbo – SEMhbo)], ‘r’ ,’EdgeColor’,’none’, ‘FaceAlpha’,0.25)
hold on
% HbR
plot(x, yhbr, ‘Color’, ‘blue’, ‘LineStyle’, ‘-‘, ‘LineWidth’, 2)
patch([x, fliplr(x)], [yhbr + SEMhbr fliplr(yhbr – SEMhbr)], ‘b’ ,’EdgeColor’,’none’, ‘FaceAlpha’,0.25)
ylim([-1.5 1.5]);
h_label = ylabel(‘Delta muM’, ‘interpreter’, ‘Tex’, ‘Rotation’, 270);
ax = gca;
ax.YColor = ‘red’;
ax.XColor = ‘k’;
set(ax, ‘FontSize’, 15, ‘LineWidth’, 2)
xlim(xaxeslimits);
% Fluo
yyaxis left
plot(x,y, ‘Color’, [0.4660 0.6740 0.1880], ‘LineWidth’, 2);
patch([x, fliplr(x)], [y + SEM fliplr(y – SEM)], ‘g’ ,’EdgeColor’,’none’, ‘FaceAlpha’,0.25)
f_label = ylabel(‘Delta F/F’);
ylim([-0.05 0.05]); % centered at 0
ax = gca;
ax.YColor = [0.4660 0.6740 0.1880];
ax.XColor = ‘k’;
set(ax, ‘FontSize’, 15, ‘LineWidth’, 2)
xlabel(‘Time (sec)’)
xlim(xaxeslimits);
if tileind == size(ROIs, 2)
tileind = 1;
else
tileind = tileind+2;
end
end
leg1 = legend({‘GCaMP’, ‘SEM’, ‘HbO’,’SEM’, ‘HbR’,’SEM’}, ‘Orientation’, ‘Horizontal’);
leg1.Location = ‘southoutside’;
% f.Position = [10 10 1800 1000];
f.Position = [10 10 900 1000];
% save
pause(0.5)
% saveas(gcf, [SaveDir ‘/NVC/Sham_RS/’ Acq ‘_’ type ‘_’ ROIsavename ‘_AvCurves.tiff’], ‘tiff’);
% saveas(gcf, [SaveDir ‘/NVC/Sham_RS/’ Acq ‘_’ type ‘_’ ROIsavename ‘_AvCurves.eps’], ‘epsc’);
saveas(gcf, [SaveDir ‘/NVC/Sham_RS/’ Acq ‘_’ type ‘_’ ROIsavename ‘_AvCurves.svg’], ‘svg’);
close(f)
Does anybody know how to fix this? I’d like to be able to easily alter the x-axis and have it still work.
Best,
Marleen Hi,
I’m making figures in MATLAB and want to export them in .svg to work with them in other programs. So far, that has been no problem, but I’m stumbling into something odd now. I’m trying to export this figure:
As you can see, this works fine in .png. This is also what the figure looks like in MATLAB. However, when I export as .svg, the blue patch that I plotted around the line to indicate the SEM continues until 10 seconds instead of 5:
I think this might be because I’m first plotting the patch, and then alter the x axis. However, this is not visible in the matlab figure, and the red and green patches show no problem for this.
My code is as follows:
xaxeslimits = [-5 5];
f = figure(‘InvertHardcopy’,’off’,’Color’,[1 1 1]);
t = tiledlayout(size(ROIs,2)/2, 2);
x = linspace(-5, 10, 226);
tileind = 2;
for roi = 1:size(ROIs, 2)
nexttile(tileind)
title(ROInames{roi})
eval([‘yhbo = means.hbo.’ ROIs{roi} ‘;’])
eval([‘SEMhbo = sems.hbo.’ ROIs{roi} ‘;’])
eval([‘yhbr = means.hbr.’ ROIs{roi} ‘;’])
eval([‘SEMhbr = sems.hbr.’ ROIs{roi} ‘;’])
eval([‘y = means.fluo.’ ROIs{roi} ‘;’])
eval([‘SEM = sems.fluo.’ ROIs{roi} ‘;’])
y = y-1; % to get centered around 0
% HbO
yyaxis right
plot(x, yhbo, ‘Color’, ‘red’, ‘LineWidth’, 2)
patch([x, fliplr(x)], [yhbo + SEMhbo fliplr(yhbo – SEMhbo)], ‘r’ ,’EdgeColor’,’none’, ‘FaceAlpha’,0.25)
hold on
% HbR
plot(x, yhbr, ‘Color’, ‘blue’, ‘LineStyle’, ‘-‘, ‘LineWidth’, 2)
patch([x, fliplr(x)], [yhbr + SEMhbr fliplr(yhbr – SEMhbr)], ‘b’ ,’EdgeColor’,’none’, ‘FaceAlpha’,0.25)
ylim([-1.5 1.5]);
h_label = ylabel(‘Delta muM’, ‘interpreter’, ‘Tex’, ‘Rotation’, 270);
ax = gca;
ax.YColor = ‘red’;
ax.XColor = ‘k’;
set(ax, ‘FontSize’, 15, ‘LineWidth’, 2)
xlim(xaxeslimits);
% Fluo
yyaxis left
plot(x,y, ‘Color’, [0.4660 0.6740 0.1880], ‘LineWidth’, 2);
patch([x, fliplr(x)], [y + SEM fliplr(y – SEM)], ‘g’ ,’EdgeColor’,’none’, ‘FaceAlpha’,0.25)
f_label = ylabel(‘Delta F/F’);
ylim([-0.05 0.05]); % centered at 0
ax = gca;
ax.YColor = [0.4660 0.6740 0.1880];
ax.XColor = ‘k’;
set(ax, ‘FontSize’, 15, ‘LineWidth’, 2)
xlabel(‘Time (sec)’)
xlim(xaxeslimits);
if tileind == size(ROIs, 2)
tileind = 1;
else
tileind = tileind+2;
end
end
leg1 = legend({‘GCaMP’, ‘SEM’, ‘HbO’,’SEM’, ‘HbR’,’SEM’}, ‘Orientation’, ‘Horizontal’);
leg1.Location = ‘southoutside’;
% f.Position = [10 10 1800 1000];
f.Position = [10 10 900 1000];
% save
pause(0.5)
% saveas(gcf, [SaveDir ‘/NVC/Sham_RS/’ Acq ‘_’ type ‘_’ ROIsavename ‘_AvCurves.tiff’], ‘tiff’);
% saveas(gcf, [SaveDir ‘/NVC/Sham_RS/’ Acq ‘_’ type ‘_’ ROIsavename ‘_AvCurves.eps’], ‘epsc’);
saveas(gcf, [SaveDir ‘/NVC/Sham_RS/’ Acq ‘_’ type ‘_’ ROIsavename ‘_AvCurves.svg’], ‘svg’);
close(f)
Does anybody know how to fix this? I’d like to be able to easily alter the x-axis and have it still work.
Best,
Marleen image export, svg, plotting, figure export MATLAB Answers — New Questions
Error using barrier Objective function is undefined at initial point. Fmincon cannot continue.
Hi, after running my code
R=readmatrix(filename1);
R=R.’;
w=readmatrix(filename2);
gamma = 2;
Aeq = ones(1,68);
beq = 1;
lb = zeros(68,1);
ub = ones(68,1);
x0=0.0147*ones(1,68);
u = @(x) 1/(1-gamma)*x.^(1-gamma);
obj = @(x)-sum(u(x*w*R));
x = fmincon(obj,x0,[],[],Aeq,beq,lb,ub);
I recived the following error
Error using barrier
Objective function is undefined at initial point. Fmincon cannot continue.
Error in fmincon (line 824)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] =
barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, …
I run the same code before but with a lees number of data and it works perfectly. Can you please help me what is wrong with my code ?
Thanks in advance
:::: UPDATE
after my discussion with Torsten : here
I reads my data carefully and found the problem with my dataHi, after running my code
R=readmatrix(filename1);
R=R.’;
w=readmatrix(filename2);
gamma = 2;
Aeq = ones(1,68);
beq = 1;
lb = zeros(68,1);
ub = ones(68,1);
x0=0.0147*ones(1,68);
u = @(x) 1/(1-gamma)*x.^(1-gamma);
obj = @(x)-sum(u(x*w*R));
x = fmincon(obj,x0,[],[],Aeq,beq,lb,ub);
I recived the following error
Error using barrier
Objective function is undefined at initial point. Fmincon cannot continue.
Error in fmincon (line 824)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] =
barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, …
I run the same code before but with a lees number of data and it works perfectly. Can you please help me what is wrong with my code ?
Thanks in advance
:::: UPDATE
after my discussion with Torsten : here
I reads my data carefully and found the problem with my data Hi, after running my code
R=readmatrix(filename1);
R=R.’;
w=readmatrix(filename2);
gamma = 2;
Aeq = ones(1,68);
beq = 1;
lb = zeros(68,1);
ub = ones(68,1);
x0=0.0147*ones(1,68);
u = @(x) 1/(1-gamma)*x.^(1-gamma);
obj = @(x)-sum(u(x*w*R));
x = fmincon(obj,x0,[],[],Aeq,beq,lb,ub);
I recived the following error
Error using barrier
Objective function is undefined at initial point. Fmincon cannot continue.
Error in fmincon (line 824)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] =
barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, …
I run the same code before but with a lees number of data and it works perfectly. Can you please help me what is wrong with my code ?
Thanks in advance
:::: UPDATE
after my discussion with Torsten : here
I reads my data carefully and found the problem with my data fmincon MATLAB Answers — New Questions
how extract two arrays in matlab of unequal length
I have datasets of unequal length, like data file 1 has 47 data points and data file 2 has 649 data points , now i want diffence of these two curves, but I am looking for options , how to extract them.
I am attaching image of the plots.
please guide.
Regards,
IqraI have datasets of unequal length, like data file 1 has 47 data points and data file 2 has 649 data points , now i want diffence of these two curves, but I am looking for options , how to extract them.
I am attaching image of the plots.
please guide.
Regards,
Iqra I have datasets of unequal length, like data file 1 has 47 data points and data file 2 has 649 data points , now i want diffence of these two curves, but I am looking for options , how to extract them.
I am attaching image of the plots.
please guide.
Regards,
Iqra arrays, different length, matlab MATLAB Answers — New Questions
how to remove noise from curves and take their derivates
Hello,
I have some curves which are not smooth, I have to take their derivative. therefore first requirement is remove the noise and take the derivative.
I am doing this work through curve fitting using rat35, poly9 etc. and then taking the derivative. but everytime i run the script, result changes slighty.
i am attaching the curve , their zoom version and then warnings which appeared in workspace, would you please guide me how i should handle this issue.
Regards,
KiranHello,
I have some curves which are not smooth, I have to take their derivative. therefore first requirement is remove the noise and take the derivative.
I am doing this work through curve fitting using rat35, poly9 etc. and then taking the derivative. but everytime i run the script, result changes slighty.
i am attaching the curve , their zoom version and then warnings which appeared in workspace, would you please guide me how i should handle this issue.
Regards,
Kiran Hello,
I have some curves which are not smooth, I have to take their derivative. therefore first requirement is remove the noise and take the derivative.
I am doing this work through curve fitting using rat35, poly9 etc. and then taking the derivative. but everytime i run the script, result changes slighty.
i am attaching the curve , their zoom version and then warnings which appeared in workspace, would you please guide me how i should handle this issue.
Regards,
Kiran curve fitting, noise, smooth curve, derivative, denoising, fitnlm, sgolayfilt MATLAB Answers — New Questions
Write a function called corners that takes a matrix as an input argument and returns four outputs: the elements at its four corners in this order: top_left, top_right, bottom_left and bottom_right. (Note that loops and if-statements are neither neces
This question is soft-locked: new answers that are equivalent to already posted answers may be deleted without prior notice.
Can’t find a solution to this problem im a noob, please help, example
>> [a, b, c, d] = corners([1 2; 3 4])
a =
1
b =
2
c =
3
d =
4This question is soft-locked: new answers that are equivalent to already posted answers may be deleted without prior notice.
Can’t find a solution to this problem im a noob, please help, example
>> [a, b, c, d] = corners([1 2; 3 4])
a =
1
b =
2
c =
3
d =
4 This question is soft-locked: new answers that are equivalent to already posted answers may be deleted without prior notice.
Can’t find a solution to this problem im a noob, please help, example
>> [a, b, c, d] = corners([1 2; 3 4])
a =
1
b =
2
c =
3
d =
4 functions, homework, soft-lock, corners of matrix MATLAB Answers — New Questions
Maximize my GUI window
How can i maximize my GUI window keeping the ratio of all my labels and buttons maximized with the windowHow can i maximize my GUI window keeping the ratio of all my labels and buttons maximized with the window How can i maximize my GUI window keeping the ratio of all my labels and buttons maximized with the window matlab gui, guide, app designer, appdesigner, resize, gui MATLAB Answers — New Questions
how to model a fire alarm system on simulink
KIndly advise as to how I can model and simulate a fire alarm system on simulink. So if you can suggest any crediable and reliable learning resources that would be best.KIndly advise as to how I can model and simulate a fire alarm system on simulink. So if you can suggest any crediable and reliable learning resources that would be best. KIndly advise as to how I can model and simulate a fire alarm system on simulink. So if you can suggest any crediable and reliable learning resources that would be best. fire alarms, simulink MATLAB Answers — New Questions
Sensor Fusion and Tracking Toolbox
I have installed Sensor Fusion and Tracking toolbox for my MATLAB R2019a but when i try to open example using this command:
openExample(‘shared_fusion_arduinoio/EstimateOrientationUsingInertialSensorFusionAndMPU9250Example’)
I get this message:
Error using exampleUtils.componentExamplesDir (line 13)
Invalid argument "shared_fusion_arduinoio".
Error in findExample (line 18)
componentExamplesDir =
exampleUtils.componentExamplesDir(component);
Error in openExample (line 24)
metadata = findExample(id);
Actualy I want to use HelperOrientationViewer command to view the 3D pose of my IMU sensor which is possible via this example because when i try to do that it just gives error:
Undefined function or variable ‘HelperOrientationViewer’.
Error in matlab_mpu9250 (line 72)
viewer = HelperOrientationViewer(‘Title’,{‘AHRS Filter’});
Please do help me i really need Viewer for proper visualization of my robot’s orientation.I have installed Sensor Fusion and Tracking toolbox for my MATLAB R2019a but when i try to open example using this command:
openExample(‘shared_fusion_arduinoio/EstimateOrientationUsingInertialSensorFusionAndMPU9250Example’)
I get this message:
Error using exampleUtils.componentExamplesDir (line 13)
Invalid argument "shared_fusion_arduinoio".
Error in findExample (line 18)
componentExamplesDir =
exampleUtils.componentExamplesDir(component);
Error in openExample (line 24)
metadata = findExample(id);
Actualy I want to use HelperOrientationViewer command to view the 3D pose of my IMU sensor which is possible via this example because when i try to do that it just gives error:
Undefined function or variable ‘HelperOrientationViewer’.
Error in matlab_mpu9250 (line 72)
viewer = HelperOrientationViewer(‘Title’,{‘AHRS Filter’});
Please do help me i really need Viewer for proper visualization of my robot’s orientation. I have installed Sensor Fusion and Tracking toolbox for my MATLAB R2019a but when i try to open example using this command:
openExample(‘shared_fusion_arduinoio/EstimateOrientationUsingInertialSensorFusionAndMPU9250Example’)
I get this message:
Error using exampleUtils.componentExamplesDir (line 13)
Invalid argument "shared_fusion_arduinoio".
Error in findExample (line 18)
componentExamplesDir =
exampleUtils.componentExamplesDir(component);
Error in openExample (line 24)
metadata = findExample(id);
Actualy I want to use HelperOrientationViewer command to view the 3D pose of my IMU sensor which is possible via this example because when i try to do that it just gives error:
Undefined function or variable ‘HelperOrientationViewer’.
Error in matlab_mpu9250 (line 72)
viewer = HelperOrientationViewer(‘Title’,{‘AHRS Filter’});
Please do help me i really need Viewer for proper visualization of my robot’s orientation. mpu9250, sensor fusion, toolbox, error opening example, helper orientation viewer, matlab2019a, imu MATLAB Answers — New Questions
How to read shape file in matlab?
I am using following matlab code to read shape file. I am attaching the shape file also as zip file.
% pickup the shape files
d = uigetdir(pwd, ‘Select a folder’);
shapefiles = dir(fullfile(d, ‘*.shp’));
for n = 1:length(shapefiles)
shapefile = shapefiles(n);
disp(shapefile.name);
S = shaperead(shapefile.name);
polygon = polyshape([S.X], [S.Y]);
% Create a logical mask
logical_mask = inpolygon(lon, lat, polygon.Vertices(:, 1), polygon.Vertices(:, 2));
end
This is giving the following errors;
>> testrnAchi Khurd.shp
Error using openShapeFiles>checkSHP (line 82)
Unable to open file ‘Achi Khurd.shp’. Check the path and filename or file permissions.
Error in openShapeFiles (line 19)
[basename, ext] = checkSHP(basename,shapeExtensionProvided);
Error in shaperead (line 212)
= openShapeFiles(filename,’shaperead’);
Error
in test (line 9)
S = shaperead(shapefile.name);
>>
Please suggest me how to fix it? I would be highly obliged for kind help.
DaveI am using following matlab code to read shape file. I am attaching the shape file also as zip file.
% pickup the shape files
d = uigetdir(pwd, ‘Select a folder’);
shapefiles = dir(fullfile(d, ‘*.shp’));
for n = 1:length(shapefiles)
shapefile = shapefiles(n);
disp(shapefile.name);
S = shaperead(shapefile.name);
polygon = polyshape([S.X], [S.Y]);
% Create a logical mask
logical_mask = inpolygon(lon, lat, polygon.Vertices(:, 1), polygon.Vertices(:, 2));
end
This is giving the following errors;
>> testrnAchi Khurd.shp
Error using openShapeFiles>checkSHP (line 82)
Unable to open file ‘Achi Khurd.shp’. Check the path and filename or file permissions.
Error in openShapeFiles (line 19)
[basename, ext] = checkSHP(basename,shapeExtensionProvided);
Error in shaperead (line 212)
= openShapeFiles(filename,’shaperead’);
Error
in test (line 9)
S = shaperead(shapefile.name);
>>
Please suggest me how to fix it? I would be highly obliged for kind help.
Dave I am using following matlab code to read shape file. I am attaching the shape file also as zip file.
% pickup the shape files
d = uigetdir(pwd, ‘Select a folder’);
shapefiles = dir(fullfile(d, ‘*.shp’));
for n = 1:length(shapefiles)
shapefile = shapefiles(n);
disp(shapefile.name);
S = shaperead(shapefile.name);
polygon = polyshape([S.X], [S.Y]);
% Create a logical mask
logical_mask = inpolygon(lon, lat, polygon.Vertices(:, 1), polygon.Vertices(:, 2));
end
This is giving the following errors;
>> testrnAchi Khurd.shp
Error using openShapeFiles>checkSHP (line 82)
Unable to open file ‘Achi Khurd.shp’. Check the path and filename or file permissions.
Error in openShapeFiles (line 19)
[basename, ext] = checkSHP(basename,shapeExtensionProvided);
Error in shaperead (line 212)
= openShapeFiles(filename,’shaperead’);
Error
in test (line 9)
S = shaperead(shapefile.name);
>>
Please suggest me how to fix it? I would be highly obliged for kind help.
Dave how to read shape file in matlab? MATLAB Answers — New Questions
MATLAB code of intersection
Hello, i intersect two sets of lines from two different origins at a distance of 10 cm from 0 to 90 degrees with an angle difference of two degrees. A straight line is obtained from the intersection of lines of the same degree. From the collision of lines, twice the degree of curvature is obtained. I need a MATLAB code to draw this straight line and curves.Hello, i intersect two sets of lines from two different origins at a distance of 10 cm from 0 to 90 degrees with an angle difference of two degrees. A straight line is obtained from the intersection of lines of the same degree. From the collision of lines, twice the degree of curvature is obtained. I need a MATLAB code to draw this straight line and curves. Hello, i intersect two sets of lines from two different origins at a distance of 10 cm from 0 to 90 degrees with an angle difference of two degrees. A straight line is obtained from the intersection of lines of the same degree. From the collision of lines, twice the degree of curvature is obtained. I need a MATLAB code to draw this straight line and curves. matlab, line, intersection MATLAB Answers — New Questions
Similar image grouping in dataset
I want to group the images in a dataset according to the similarity ratio. When grouping, it can be based on certain objects(cars,trees,faces).After the images are determined, filing or a different dataset can be created. How can I find the similarity and how can i grouping?
Thank you.I want to group the images in a dataset according to the similarity ratio. When grouping, it can be based on certain objects(cars,trees,faces).After the images are determined, filing or a different dataset can be created. How can I find the similarity and how can i grouping?
Thank you. I want to group the images in a dataset according to the similarity ratio. When grouping, it can be based on certain objects(cars,trees,faces).After the images are determined, filing or a different dataset can be created. How can I find the similarity and how can i grouping?
Thank you. image, image analysis, image segmentation, image processing MATLAB Answers — New Questions
Hi, i try to solve equation c in terms of other variables, and its appear the messages and the answers is not as expected. Is supposed to be beta/p^(1/sigma)? is it?
Post Content Post Content solving equations MATLAB Answers — New Questions
Powergui FFT Analysis Tool doesn’t work!
When I use the Powergui FFT Analysis Tool (in the matlab 2019a), I find it can’work. In the module of "Available signals","Name" and "Input" are always "Empty", though I have selected “Log data to workspace” and "structure with time".Are there any other parameters to set?When I use the Powergui FFT Analysis Tool (in the matlab 2019a), I find it can’work. In the module of "Available signals","Name" and "Input" are always "Empty", though I have selected “Log data to workspace” and "structure with time".Are there any other parameters to set? When I use the Powergui FFT Analysis Tool (in the matlab 2019a), I find it can’work. In the module of "Available signals","Name" and "Input" are always "Empty", though I have selected “Log data to workspace” and "structure with time".Are there any other parameters to set? powergui, fft MATLAB Answers — New Questions