Tag Archives: matlab
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
Importing Mf4 file
Hello Dear Matlab community,
I need to import the mf4 files using mdf. it works fine for .dat file and .mdf files with mdfimport, but when it comes to .mf4 it asks to add the one of the toolbox Powertrain Blockset or Vehicle Network Toolbox , is it the only way to import the file , i mean i do really need one of those toolbox ?
Thnaks in advanceHello Dear Matlab community,
I need to import the mf4 files using mdf. it works fine for .dat file and .mdf files with mdfimport, but when it comes to .mf4 it asks to add the one of the toolbox Powertrain Blockset or Vehicle Network Toolbox , is it the only way to import the file , i mean i do really need one of those toolbox ?
Thnaks in advance Hello Dear Matlab community,
I need to import the mf4 files using mdf. it works fine for .dat file and .mdf files with mdfimport, but when it comes to .mf4 it asks to add the one of the toolbox Powertrain Blockset or Vehicle Network Toolbox , is it the only way to import the file , i mean i do really need one of those toolbox ?
Thnaks in advance import mdf MATLAB Answers — New Questions
Partitioning data for Time Series TCN model Training, Validation, and Testing
Hello there, I am trying to build a TCN model to predict a continuous variable. I have time series data in which I am using 3 input features (accelrometer measuments in x,y,z directions) to estimate/predict a continuous variable. I have acceleromter data from 10 different trials stored in a 10×1 cell and each cell has the three accelerometer measurments over time stored in a 500×3 table for that trial. The target continous varable I am trying to predict is simialrly stored in a 10×1 cell array with each cell contaning a the a 500×1 table which is the true value of the predicted variable over time named "Taget". If I am trying to build a TCN model with this data what is the best way to partition the data for training, testing (10%), and validation (10%)? I think I need to use the tspartition function but am not sure how to use it for this type of data. Do I need to combine the data from all 10 trials into one large table and then partition? Or should I partition each trial seprately, train the model on a singluar trial, and then retrain the model on the next trial and so on. Any help would be greatly appreciated!Hello there, I am trying to build a TCN model to predict a continuous variable. I have time series data in which I am using 3 input features (accelrometer measuments in x,y,z directions) to estimate/predict a continuous variable. I have acceleromter data from 10 different trials stored in a 10×1 cell and each cell has the three accelerometer measurments over time stored in a 500×3 table for that trial. The target continous varable I am trying to predict is simialrly stored in a 10×1 cell array with each cell contaning a the a 500×1 table which is the true value of the predicted variable over time named "Taget". If I am trying to build a TCN model with this data what is the best way to partition the data for training, testing (10%), and validation (10%)? I think I need to use the tspartition function but am not sure how to use it for this type of data. Do I need to combine the data from all 10 trials into one large table and then partition? Or should I partition each trial seprately, train the model on a singluar trial, and then retrain the model on the next trial and so on. Any help would be greatly appreciated! Hello there, I am trying to build a TCN model to predict a continuous variable. I have time series data in which I am using 3 input features (accelrometer measuments in x,y,z directions) to estimate/predict a continuous variable. I have acceleromter data from 10 different trials stored in a 10×1 cell and each cell has the three accelerometer measurments over time stored in a 500×3 table for that trial. The target continous varable I am trying to predict is simialrly stored in a 10×1 cell array with each cell contaning a the a 500×1 table which is the true value of the predicted variable over time named "Taget". If I am trying to build a TCN model with this data what is the best way to partition the data for training, testing (10%), and validation (10%)? I think I need to use the tspartition function but am not sure how to use it for this type of data. Do I need to combine the data from all 10 trials into one large table and then partition? Or should I partition each trial seprately, train the model on a singluar trial, and then retrain the model on the next trial and so on. Any help would be greatly appreciated! model, machine learning MATLAB Answers — New Questions
selected workspace variables in Matlab
Is it possible to only display a selected group of variables in the workspace window instead of all of them?Is it possible to only display a selected group of variables in the workspace window instead of all of them? Is it possible to only display a selected group of variables in the workspace window instead of all of them? matlab selected workspace variables MATLAB Answers — New Questions
Replace NaN with Blanks
Hi guys I have a double matrix as shown in the attached picture that I am trying to replace all NaN values with Empty spaces so that the over all matrix dimension will be maintained. However, when I looked through the function and suggested solutions non of them is actully working what possible code can be used.
Thanks in advanceHi guys I have a double matrix as shown in the attached picture that I am trying to replace all NaN values with Empty spaces so that the over all matrix dimension will be maintained. However, when I looked through the function and suggested solutions non of them is actully working what possible code can be used.
Thanks in advance Hi guys I have a double matrix as shown in the attached picture that I am trying to replace all NaN values with Empty spaces so that the over all matrix dimension will be maintained. However, when I looked through the function and suggested solutions non of them is actully working what possible code can be used.
Thanks in advance nan, blank, empty, matrix MATLAB Answers — New Questions
Why are the descriptive names of my boxchart categories not visible in my figure?
Hi all, I am trying to visualise ply thicknesses (in multiple composite samples) using boxchart(). I manage to show the boxes according to the ply numbers. However, I would like to mention the fibre orientation with the ply numbers as well. The (adapted, for readability) code I used so far is shown below. I also included the result I obtained.
My problem is that the y-axis do not show both the number and the orientation of the plies. I tried to follow the "Create Multiple Box Charts Using Positional Grouping Variable" example in the boxchart documentation, because this example shows the replacement of numbered axis-ticklabels to a descriptive label (just like I want my axis to be). It tells me to use categorical() to "replace" the plain ply numbers, after which I need to use boxchart. Although I think I applied this example correctly to my case and all intermediate steps look like they were executed as desired, the figure does not turn out as intended. Why are the descriptive names on the y-axis not visible in the figure?
table = array2table([nr t]; % A table containing the ply numbers (pnr) and their corresponding thicknesses (t). This outputs a table with many rows (the amount of samples with n plies) by 2 columns (pnr and t)
for i = 1:nplies
p_ors_str = string(sprintf(‘%02i: %i%c’,nply(i),layup_weld(i),char(0176)))); % Describing the ply number with the corresponding orientation
end % Results in a nplies*1 string containing element similar to "01: 45°".
p_ors_cat = categorical(table.nr,1:nplies,p_ors_str); % Converting the ply numbers to a descriptive string in a categorical array
figure(1), clf(1), hold on
subplot(2,1,1), hold on % This method corresponds to the "boxchart(earthquakes.Month,earthquakes.EarthquakeMagnitude)"-command in the example
boxchart(table.pnr,table.t,’Orientation’,’Horizontal’) % The boxes visualise the several measurements for every ply, showing ply numbers
ylabel(‘Ply number’)
subplot(2,1,2), hold on % This method corresponds to the "boxchart(namedMonths,earthquakes.EarthquakeMagnitude)"-command in the example
boxchart(p_ors_str,table.t,’Orientation’,’Horizontal’) % The boxes should visualise the same as before, but describing the ply number with their orientation
ylabel(‘Ply number and orientation’)Hi all, I am trying to visualise ply thicknesses (in multiple composite samples) using boxchart(). I manage to show the boxes according to the ply numbers. However, I would like to mention the fibre orientation with the ply numbers as well. The (adapted, for readability) code I used so far is shown below. I also included the result I obtained.
My problem is that the y-axis do not show both the number and the orientation of the plies. I tried to follow the "Create Multiple Box Charts Using Positional Grouping Variable" example in the boxchart documentation, because this example shows the replacement of numbered axis-ticklabels to a descriptive label (just like I want my axis to be). It tells me to use categorical() to "replace" the plain ply numbers, after which I need to use boxchart. Although I think I applied this example correctly to my case and all intermediate steps look like they were executed as desired, the figure does not turn out as intended. Why are the descriptive names on the y-axis not visible in the figure?
table = array2table([nr t]; % A table containing the ply numbers (pnr) and their corresponding thicknesses (t). This outputs a table with many rows (the amount of samples with n plies) by 2 columns (pnr and t)
for i = 1:nplies
p_ors_str = string(sprintf(‘%02i: %i%c’,nply(i),layup_weld(i),char(0176)))); % Describing the ply number with the corresponding orientation
end % Results in a nplies*1 string containing element similar to "01: 45°".
p_ors_cat = categorical(table.nr,1:nplies,p_ors_str); % Converting the ply numbers to a descriptive string in a categorical array
figure(1), clf(1), hold on
subplot(2,1,1), hold on % This method corresponds to the "boxchart(earthquakes.Month,earthquakes.EarthquakeMagnitude)"-command in the example
boxchart(table.pnr,table.t,’Orientation’,’Horizontal’) % The boxes visualise the several measurements for every ply, showing ply numbers
ylabel(‘Ply number’)
subplot(2,1,2), hold on % This method corresponds to the "boxchart(namedMonths,earthquakes.EarthquakeMagnitude)"-command in the example
boxchart(p_ors_str,table.t,’Orientation’,’Horizontal’) % The boxes should visualise the same as before, but describing the ply number with their orientation
ylabel(‘Ply number and orientation’) Hi all, I am trying to visualise ply thicknesses (in multiple composite samples) using boxchart(). I manage to show the boxes according to the ply numbers. However, I would like to mention the fibre orientation with the ply numbers as well. The (adapted, for readability) code I used so far is shown below. I also included the result I obtained.
My problem is that the y-axis do not show both the number and the orientation of the plies. I tried to follow the "Create Multiple Box Charts Using Positional Grouping Variable" example in the boxchart documentation, because this example shows the replacement of numbered axis-ticklabels to a descriptive label (just like I want my axis to be). It tells me to use categorical() to "replace" the plain ply numbers, after which I need to use boxchart. Although I think I applied this example correctly to my case and all intermediate steps look like they were executed as desired, the figure does not turn out as intended. Why are the descriptive names on the y-axis not visible in the figure?
table = array2table([nr t]; % A table containing the ply numbers (pnr) and their corresponding thicknesses (t). This outputs a table with many rows (the amount of samples with n plies) by 2 columns (pnr and t)
for i = 1:nplies
p_ors_str = string(sprintf(‘%02i: %i%c’,nply(i),layup_weld(i),char(0176)))); % Describing the ply number with the corresponding orientation
end % Results in a nplies*1 string containing element similar to "01: 45°".
p_ors_cat = categorical(table.nr,1:nplies,p_ors_str); % Converting the ply numbers to a descriptive string in a categorical array
figure(1), clf(1), hold on
subplot(2,1,1), hold on % This method corresponds to the "boxchart(earthquakes.Month,earthquakes.EarthquakeMagnitude)"-command in the example
boxchart(table.pnr,table.t,’Orientation’,’Horizontal’) % The boxes visualise the several measurements for every ply, showing ply numbers
ylabel(‘Ply number’)
subplot(2,1,2), hold on % This method corresponds to the "boxchart(namedMonths,earthquakes.EarthquakeMagnitude)"-command in the example
boxchart(p_ors_str,table.t,’Orientation’,’Horizontal’) % The boxes should visualise the same as before, but describing the ply number with their orientation
ylabel(‘Ply number and orientation’) boxchart, plotting, boxplot, yticklabels, ticklabels, xticklabels, composites MATLAB Answers — New Questions