Category: Matlab
Category Archives: Matlab
Pie chart label overlapping
Hey guys so I have a pie chart with labels like 1%,2% <1% and because there are 100 values it overlaps quite a lot.
I am able to remove all labels with delete(findobj(p,’Type’,’Text’))
Is there any way to remove just the ones with <1% or somehow group the labels together?Hey guys so I have a pie chart with labels like 1%,2% <1% and because there are 100 values it overlaps quite a lot.
I am able to remove all labels with delete(findobj(p,’Type’,’Text’))
Is there any way to remove just the ones with <1% or somehow group the labels together? Hey guys so I have a pie chart with labels like 1%,2% <1% and because there are 100 values it overlaps quite a lot.
I am able to remove all labels with delete(findobj(p,’Type’,’Text’))
Is there any way to remove just the ones with <1% or somehow group the labels together? piechart, labels, grouping MATLAB Answers — New Questions
plotting a plane in three dimensions including data points
Hi,
I have a plane obtained via regression. Let’s say this is z = 2x + 3y + 4. I want to plot this plane AND the data points. How do I do this?Hi,
I have a plane obtained via regression. Let’s say this is z = 2x + 3y + 4. I want to plot this plane AND the data points. How do I do this? Hi,
I have a plane obtained via regression. Let’s say this is z = 2x + 3y + 4. I want to plot this plane AND the data points. How do I do this? 3 dimensions, plane, plot, plot3 MATLAB Answers — New Questions
how to draw a plane?
Hai,
I am working on optics. I have plotted a lens in matlab. The rays of light emerging out of the lens, after undergoing refraction in the lens, needs to be projected on a square plane in front of the lens. How is it possible to draw a plane in matlab? Looking forward to hearing from you soon.
BSDHai,
I am working on optics. I have plotted a lens in matlab. The rays of light emerging out of the lens, after undergoing refraction in the lens, needs to be projected on a square plane in front of the lens. How is it possible to draw a plane in matlab? Looking forward to hearing from you soon.
BSD Hai,
I am working on optics. I have plotted a lens in matlab. The rays of light emerging out of the lens, after undergoing refraction in the lens, needs to be projected on a square plane in front of the lens. How is it possible to draw a plane in matlab? Looking forward to hearing from you soon.
BSD plane MATLAB Answers — New Questions
Remove the bottom x-axis line of a plot
Hi,
Please how can I remove the bottom line of X-axis of a plot and leave the top x-axis line
ThanksHi,
Please how can I remove the bottom line of X-axis of a plot and leave the top x-axis line
Thanks Hi,
Please how can I remove the bottom line of X-axis of a plot and leave the top x-axis line
Thanks ploting MATLAB Answers — New Questions
MEX level2 S-function “sfunc_basic” must be called with at least 4 right hand arguments
Can any one please explain me what does this error mean. I tried to google it but could not find anything relevant. I get this while running the Simulink(mexing the file does not throw any error).Can any one please explain me what does this error mean. I tried to google it but could not find anything relevant. I get this while running the Simulink(mexing the file does not throw any error). Can any one please explain me what does this error mean. I tried to google it but could not find anything relevant. I get this while running the Simulink(mexing the file does not throw any error). mex level2 s-function MATLAB Answers — New Questions
How can I make the labels of components in appdesigner use the latex interpreter?
Hi,
Is there a way to make the label of a numeric box in a GUI generated by appdesigner to use latex as an interpreter?
Currently, if I want to say label the numeric text box it displays e.g. y_2(0). How can I make it display $y_2(0)$ i.e. in latex mode, please?
Thank you!Hi,
Is there a way to make the label of a numeric box in a GUI generated by appdesigner to use latex as an interpreter?
Currently, if I want to say label the numeric text box it displays e.g. y_2(0). How can I make it display $y_2(0)$ i.e. in latex mode, please?
Thank you! Hi,
Is there a way to make the label of a numeric box in a GUI generated by appdesigner to use latex as an interpreter?
Currently, if I want to say label the numeric text box it displays e.g. y_2(0). How can I make it display $y_2(0)$ i.e. in latex mode, please?
Thank you! appdesigner, gui, latex MATLAB Answers — New Questions
Why do the load flow results from the powergui block in my IEEE 34 model only appear for buses before the voltage regulator, and how can I fix this?
While working on an IEEE 34 model and using the load flow analyzer from the powergui block, I noticed that the load flow results only appear for the buses before the voltage regulator (VR). Could anyone provide guidance on how to resolve this issue? ( VR is connected between bus 814 and bus 816)
Note :when i remove the voltage regulator every bus is calculatedWhile working on an IEEE 34 model and using the load flow analyzer from the powergui block, I noticed that the load flow results only appear for the buses before the voltage regulator (VR). Could anyone provide guidance on how to resolve this issue? ( VR is connected between bus 814 and bus 816)
Note :when i remove the voltage regulator every bus is calculated While working on an IEEE 34 model and using the load flow analyzer from the powergui block, I noticed that the load flow results only appear for the buses before the voltage regulator (VR). Could anyone provide guidance on how to resolve this issue? ( VR is connected between bus 814 and bus 816)
Note :when i remove the voltage regulator every bus is calculated ieee 34, load flow, powergui, voltage regulator MATLAB Answers — New Questions
about poly2mask function
Could anyone please explain me this : I’m using poly2mask function to creat a mask of a polygon with an image the documentation of this image says "the function sets pixels that are inside the polygon to 1 and sets pixels outside the polygon to 0" if you could see here : https://ww2.mathworks.cn/help/images/ref/poly2mask.html#f6-465457 but here when I use it to create a mask of a polygon with my image
rx = [shape(i).X];
ry = [shape(i).Y];
cond1 = isnan(rx) | isnan(ry);
rx(cond1)=[];
ry(cond1)=[];
[X,Y] = meshgrid(x,y);
row=size(X,1);
col=size(X,2);
mask=poly2mask(rx,ry,row,col);
I did this to to test how many ones that I have sum(mask(:)) and the result is very small =9 which means that only 9 points inside the polygon which is impossible because row=1069 col=1363 X is 1069×1363 Y is 1069×1363 rx is 1×42708 ry is 1x42708Could anyone please explain me this : I’m using poly2mask function to creat a mask of a polygon with an image the documentation of this image says "the function sets pixels that are inside the polygon to 1 and sets pixels outside the polygon to 0" if you could see here : https://ww2.mathworks.cn/help/images/ref/poly2mask.html#f6-465457 but here when I use it to create a mask of a polygon with my image
rx = [shape(i).X];
ry = [shape(i).Y];
cond1 = isnan(rx) | isnan(ry);
rx(cond1)=[];
ry(cond1)=[];
[X,Y] = meshgrid(x,y);
row=size(X,1);
col=size(X,2);
mask=poly2mask(rx,ry,row,col);
I did this to to test how many ones that I have sum(mask(:)) and the result is very small =9 which means that only 9 points inside the polygon which is impossible because row=1069 col=1363 X is 1069×1363 Y is 1069×1363 rx is 1×42708 ry is 1×42708 Could anyone please explain me this : I’m using poly2mask function to creat a mask of a polygon with an image the documentation of this image says "the function sets pixels that are inside the polygon to 1 and sets pixels outside the polygon to 0" if you could see here : https://ww2.mathworks.cn/help/images/ref/poly2mask.html#f6-465457 but here when I use it to create a mask of a polygon with my image
rx = [shape(i).X];
ry = [shape(i).Y];
cond1 = isnan(rx) | isnan(ry);
rx(cond1)=[];
ry(cond1)=[];
[X,Y] = meshgrid(x,y);
row=size(X,1);
col=size(X,2);
mask=poly2mask(rx,ry,row,col);
I did this to to test how many ones that I have sum(mask(:)) and the result is very small =9 which means that only 9 points inside the polygon which is impossible because row=1069 col=1363 X is 1069×1363 Y is 1069×1363 rx is 1×42708 ry is 1×42708 mask, polygon, poly2mask MATLAB Answers — New Questions
compass axis labels
Hi,
Anyone know a way to change the default axis labels in a compass plot
from the default (0,30,60,90,120,150,180…) to user-defined ones (90,60,30,0,-30,-60,-90) respectively?
I can’t seem to figure out how to get at them!Hi,
Anyone know a way to change the default axis labels in a compass plot
from the default (0,30,60,90,120,150,180…) to user-defined ones (90,60,30,0,-30,-60,-90) respectively?
I can’t seem to figure out how to get at them! Hi,
Anyone know a way to change the default axis labels in a compass plot
from the default (0,30,60,90,120,150,180…) to user-defined ones (90,60,30,0,-30,-60,-90) respectively?
I can’t seem to figure out how to get at them! plotting, plot MATLAB Answers — New Questions
Is there a way to determine an equivalent circuit for Nyquist diagrams (I have the data set) using Matlab (or Simulink)?
I am working on gathering some Nyquist diagrams experimentally and facing some difficulties on simulating equivalent circuits for my data. What I have done so far is simply trying to come up with an idea of an equivalent circuit and seen if it fits the case. Well this is obscure and it is not always representative of what has been going on. So is it possible to use Matlab to construct/simulate equivalent circuits from experimental data?I am working on gathering some Nyquist diagrams experimentally and facing some difficulties on simulating equivalent circuits for my data. What I have done so far is simply trying to come up with an idea of an equivalent circuit and seen if it fits the case. Well this is obscure and it is not always representative of what has been going on. So is it possible to use Matlab to construct/simulate equivalent circuits from experimental data? I am working on gathering some Nyquist diagrams experimentally and facing some difficulties on simulating equivalent circuits for my data. What I have done so far is simply trying to come up with an idea of an equivalent circuit and seen if it fits the case. Well this is obscure and it is not always representative of what has been going on. So is it possible to use Matlab to construct/simulate equivalent circuits from experimental data? nyquist diagram, equivalent circuit, simulation, electrochemical circle fit, electrochemical impedance spectroscopy, eis MATLAB Answers — New Questions
beginner integration trouble.
CODE:
“`
syms x
f(x)= (x^(3/2)+3-x^2)^(1/2);
g(x)= -(x^(3/2)+3-x^2)^(1/2);
sol=double(solve(f==0));
sol=sol(sol==real(sol));
disp(sol)
Area=2*int(f,0,sol);
disp([‘Area under the curve f(x) is: ‘,char(Area)]);
vol=int(pi*(f)^2,x,a,sol);
disp([‘volume of solid of rotation formed by the curve f(x) and g(x) about x axis is: ‘,char(vol)]);
“`
sol=sol(sol==real(sol)), this part will remove any imaginary terms stored in sol.
output:
>> DA2_Q1_b
2.749289201023484
Area under the curve f(x) is: 2*int((x^(3/2) – x^2 + 3)^(1/2), x, 0, 3095424455315773/1125899906842624)
volume of solid of rotation formed by the curve f(x) and g(x) about x axis is: (3095424455315773*pi*(623191256382180861935616*3095424455315773^(1/2) + 9136014217435573277565931304275))/21408715390589398215874289541742427045741199360
as you can see the output for area is not what i wanted. Can anyone please help me to get a numeric or symbolic answer to area.CODE:
“`
syms x
f(x)= (x^(3/2)+3-x^2)^(1/2);
g(x)= -(x^(3/2)+3-x^2)^(1/2);
sol=double(solve(f==0));
sol=sol(sol==real(sol));
disp(sol)
Area=2*int(f,0,sol);
disp([‘Area under the curve f(x) is: ‘,char(Area)]);
vol=int(pi*(f)^2,x,a,sol);
disp([‘volume of solid of rotation formed by the curve f(x) and g(x) about x axis is: ‘,char(vol)]);
“`
sol=sol(sol==real(sol)), this part will remove any imaginary terms stored in sol.
output:
>> DA2_Q1_b
2.749289201023484
Area under the curve f(x) is: 2*int((x^(3/2) – x^2 + 3)^(1/2), x, 0, 3095424455315773/1125899906842624)
volume of solid of rotation formed by the curve f(x) and g(x) about x axis is: (3095424455315773*pi*(623191256382180861935616*3095424455315773^(1/2) + 9136014217435573277565931304275))/21408715390589398215874289541742427045741199360
as you can see the output for area is not what i wanted. Can anyone please help me to get a numeric or symbolic answer to area. CODE:
“`
syms x
f(x)= (x^(3/2)+3-x^2)^(1/2);
g(x)= -(x^(3/2)+3-x^2)^(1/2);
sol=double(solve(f==0));
sol=sol(sol==real(sol));
disp(sol)
Area=2*int(f,0,sol);
disp([‘Area under the curve f(x) is: ‘,char(Area)]);
vol=int(pi*(f)^2,x,a,sol);
disp([‘volume of solid of rotation formed by the curve f(x) and g(x) about x axis is: ‘,char(vol)]);
“`
sol=sol(sol==real(sol)), this part will remove any imaginary terms stored in sol.
output:
>> DA2_Q1_b
2.749289201023484
Area under the curve f(x) is: 2*int((x^(3/2) – x^2 + 3)^(1/2), x, 0, 3095424455315773/1125899906842624)
volume of solid of rotation formed by the curve f(x) and g(x) about x axis is: (3095424455315773*pi*(623191256382180861935616*3095424455315773^(1/2) + 9136014217435573277565931304275))/21408715390589398215874289541742427045741199360
as you can see the output for area is not what i wanted. Can anyone please help me to get a numeric or symbolic answer to area. integration, output MATLAB Answers — New Questions
Why am I getting sign inversion with s2rlgc?
Hi,
I am using the s2rlgc function to calculate attenuation and phase constants across a frequency range from a .s2p file I measured on a 50-ft coaxial cable from 2 to 30 MHz with a calibrated Network Analyzers . When I then apply the calculated attenuation and phase constants to determine s-parameters of a cable of a longer length, such as 142-ft, in the plots below I get a sign inversion on the s21 imaginary component around 9 and 28 MHz, as well as, a slope inversion on the s21 real component at the same frequencies. Which then cause a jump on the smith chart below.
Is this a known issue for s2rlgc? Or, does anyone have an explanation as to why this is occuring? Or, a way to fix it? Is the length of cable measured the issue? Should a shorter cable be measured?
Thanks for any help!Hi,
I am using the s2rlgc function to calculate attenuation and phase constants across a frequency range from a .s2p file I measured on a 50-ft coaxial cable from 2 to 30 MHz with a calibrated Network Analyzers . When I then apply the calculated attenuation and phase constants to determine s-parameters of a cable of a longer length, such as 142-ft, in the plots below I get a sign inversion on the s21 imaginary component around 9 and 28 MHz, as well as, a slope inversion on the s21 real component at the same frequencies. Which then cause a jump on the smith chart below.
Is this a known issue for s2rlgc? Or, does anyone have an explanation as to why this is occuring? Or, a way to fix it? Is the length of cable measured the issue? Should a shorter cable be measured?
Thanks for any help! Hi,
I am using the s2rlgc function to calculate attenuation and phase constants across a frequency range from a .s2p file I measured on a 50-ft coaxial cable from 2 to 30 MHz with a calibrated Network Analyzers . When I then apply the calculated attenuation and phase constants to determine s-parameters of a cable of a longer length, such as 142-ft, in the plots below I get a sign inversion on the s21 imaginary component around 9 and 28 MHz, as well as, a slope inversion on the s21 real component at the same frequencies. Which then cause a jump on the smith chart below.
Is this a known issue for s2rlgc? Or, does anyone have an explanation as to why this is occuring? Or, a way to fix it? Is the length of cable measured the issue? Should a shorter cable be measured?
Thanks for any help! s2rlgc, sign inversion MATLAB Answers — New Questions
How do you get a variable to recognized in function
Everytime I run this function it say D is not recognized
GetUserInput();
filename = [‘ENGR131_Lab4_CatMap_’, D];
load(filename, ‘-mat’);
PlotMap(C,D)
% B
function [C,D]=GetUserInput()
W = [‘A’, ‘B’];
X = [‘b’, ‘r’, ‘m’, ‘c’, ‘y’, ‘g’];
C = ”;
D = ”;
for i=1:2
switch i
case 1
%unable to get it too work without error W=options
prompt = ‘Enter head marker body color (b, r, m, c, y, g): ‘
case 2
%unable to get it too work without error X=options
prompt1 = ‘File (A,B): ‘
for I=1:2
if I == 1
while true
C = input(prompt, ‘s’);
if any(C == X)
break;
end
end
else I == 2
while true
D = input(prompt1, ‘s’);
if any(D == W)
break;
end
end
end
end
end
end
endEverytime I run this function it say D is not recognized
GetUserInput();
filename = [‘ENGR131_Lab4_CatMap_’, D];
load(filename, ‘-mat’);
PlotMap(C,D)
% B
function [C,D]=GetUserInput()
W = [‘A’, ‘B’];
X = [‘b’, ‘r’, ‘m’, ‘c’, ‘y’, ‘g’];
C = ”;
D = ”;
for i=1:2
switch i
case 1
%unable to get it too work without error W=options
prompt = ‘Enter head marker body color (b, r, m, c, y, g): ‘
case 2
%unable to get it too work without error X=options
prompt1 = ‘File (A,B): ‘
for I=1:2
if I == 1
while true
C = input(prompt, ‘s’);
if any(C == X)
break;
end
end
else I == 2
while true
D = input(prompt1, ‘s’);
if any(D == W)
break;
end
end
end
end
end
end
end Everytime I run this function it say D is not recognized
GetUserInput();
filename = [‘ENGR131_Lab4_CatMap_’, D];
load(filename, ‘-mat’);
PlotMap(C,D)
% B
function [C,D]=GetUserInput()
W = [‘A’, ‘B’];
X = [‘b’, ‘r’, ‘m’, ‘c’, ‘y’, ‘g’];
C = ”;
D = ”;
for i=1:2
switch i
case 1
%unable to get it too work without error W=options
prompt = ‘Enter head marker body color (b, r, m, c, y, g): ‘
case 2
%unable to get it too work without error X=options
prompt1 = ‘File (A,B): ‘
for I=1:2
if I == 1
while true
C = input(prompt, ‘s’);
if any(C == X)
break;
end
end
else I == 2
while true
D = input(prompt1, ‘s’);
if any(D == W)
break;
end
end
end
end
end
end
end loop, errorchecking, selection statement MATLAB Answers — New Questions
“Nominal Pressure Gain” for a Fixed-Displacement Pump that is pressurizing an accumulator
I am currently modeling a fixed-displacement hydraulic pump that pulls fluid from a reservoir (at atmospheric pressure) and fills a gas-charged accumulator from its initial nitrogen pressure of 1400 psi to a final pressure of 3200 psi.
How would I use the "Nominal Pressure Gain" field in the Fixed-Displacement Pump (IL) block? The pressure at port B is constantly increasing (from 1400 psi to 3200 psi) while the pressure at port A is constant (at atmospheric pressure). Would it be best to use a value of 2300 psi (half way between 1400 and 3200 psi)?I am currently modeling a fixed-displacement hydraulic pump that pulls fluid from a reservoir (at atmospheric pressure) and fills a gas-charged accumulator from its initial nitrogen pressure of 1400 psi to a final pressure of 3200 psi.
How would I use the "Nominal Pressure Gain" field in the Fixed-Displacement Pump (IL) block? The pressure at port B is constantly increasing (from 1400 psi to 3200 psi) while the pressure at port A is constant (at atmospheric pressure). Would it be best to use a value of 2300 psi (half way between 1400 and 3200 psi)? I am currently modeling a fixed-displacement hydraulic pump that pulls fluid from a reservoir (at atmospheric pressure) and fills a gas-charged accumulator from its initial nitrogen pressure of 1400 psi to a final pressure of 3200 psi.
How would I use the "Nominal Pressure Gain" field in the Fixed-Displacement Pump (IL) block? The pressure at port B is constantly increasing (from 1400 psi to 3200 psi) while the pressure at port A is constant (at atmospheric pressure). Would it be best to use a value of 2300 psi (half way between 1400 and 3200 psi)? hydraulic pump, accumulator MATLAB Answers — New Questions
crossFilt causing Matlab audio plugin pops
Audio plugin splits incoming audio into three bands and applies gain to center band and sums all back together. Debugging by only writing out one band, continuous pop noise still occurs. Is this because the crossover filter should be done with a different method in the App?
When I do this process offline in a normal m file there is no distortion.
classdef test_process < audioPlugin
properties
LowBand = 500;
HighBand = 5000;
fs = 48000;
gain = 0;
end
properties (Constant)
PluginInterface = audioPluginInterface( …
audioPluginParameter(‘LowBand’,’Label’,’Hz’,’Mapping’,{‘lin’,70,1000}),…
audioPluginParameter(‘HighBand’,’Label’,’Hz’,’Mapping’,{‘lin’,2000,10000}),…
audioPluginParameter(‘gain’,’Label’,’dB’,’Mapping’,{‘lin’,0,20}));
end
methods
function out = process(plugin,in)
%set up crossover filter
crossFilt = crossoverFilter( …
NumCrossovers=2, …
CrossoverFrequencies=[plugin.LowBand,plugin.HighBand], …
CrossoverSlopes=12, …
SampleRate=plugin.fs);
[m1,m2,m3] = crossFilt(in); % split into three bands
%normal operation commented out for debug
% midGain = m2*(db2mag(plugin.gain)); % apply gain to mid band
% out = m1+midGain+m3; % sum three bands
%Test without any sum
out = m2; % test just mid band
end
end
endAudio plugin splits incoming audio into three bands and applies gain to center band and sums all back together. Debugging by only writing out one band, continuous pop noise still occurs. Is this because the crossover filter should be done with a different method in the App?
When I do this process offline in a normal m file there is no distortion.
classdef test_process < audioPlugin
properties
LowBand = 500;
HighBand = 5000;
fs = 48000;
gain = 0;
end
properties (Constant)
PluginInterface = audioPluginInterface( …
audioPluginParameter(‘LowBand’,’Label’,’Hz’,’Mapping’,{‘lin’,70,1000}),…
audioPluginParameter(‘HighBand’,’Label’,’Hz’,’Mapping’,{‘lin’,2000,10000}),…
audioPluginParameter(‘gain’,’Label’,’dB’,’Mapping’,{‘lin’,0,20}));
end
methods
function out = process(plugin,in)
%set up crossover filter
crossFilt = crossoverFilter( …
NumCrossovers=2, …
CrossoverFrequencies=[plugin.LowBand,plugin.HighBand], …
CrossoverSlopes=12, …
SampleRate=plugin.fs);
[m1,m2,m3] = crossFilt(in); % split into three bands
%normal operation commented out for debug
% midGain = m2*(db2mag(plugin.gain)); % apply gain to mid band
% out = m1+midGain+m3; % sum three bands
%Test without any sum
out = m2; % test just mid band
end
end
end Audio plugin splits incoming audio into three bands and applies gain to center band and sums all back together. Debugging by only writing out one band, continuous pop noise still occurs. Is this because the crossover filter should be done with a different method in the App?
When I do this process offline in a normal m file there is no distortion.
classdef test_process < audioPlugin
properties
LowBand = 500;
HighBand = 5000;
fs = 48000;
gain = 0;
end
properties (Constant)
PluginInterface = audioPluginInterface( …
audioPluginParameter(‘LowBand’,’Label’,’Hz’,’Mapping’,{‘lin’,70,1000}),…
audioPluginParameter(‘HighBand’,’Label’,’Hz’,’Mapping’,{‘lin’,2000,10000}),…
audioPluginParameter(‘gain’,’Label’,’dB’,’Mapping’,{‘lin’,0,20}));
end
methods
function out = process(plugin,in)
%set up crossover filter
crossFilt = crossoverFilter( …
NumCrossovers=2, …
CrossoverFrequencies=[plugin.LowBand,plugin.HighBand], …
CrossoverSlopes=12, …
SampleRate=plugin.fs);
[m1,m2,m3] = crossFilt(in); % split into three bands
%normal operation commented out for debug
% midGain = m2*(db2mag(plugin.gain)); % apply gain to mid band
% out = m1+midGain+m3; % sum three bands
%Test without any sum
out = m2; % test just mid band
end
end
end audio plugin MATLAB Answers — New Questions
How can I run code just once, for multiple intervals of numbers?
Let’s say I want to calculate things for alpha ranging from 0 to 2pi.
I’ve written if / else-if statements to do this:
alpha = linspace(0, 2pi, 100)
if 0 <= alpha & alpha <= pi/2
calculate this;
elseif pi/2 < alpha & alpha < pi
calculate this;
end
Now, after I’ve finished debugging this code, I noticed I can only run the code for one, specific interval of alpha at a time.
So, I have to use
alpha = linspace(0, pi/2, 15),
then run code, plot data, press hold on, and then switch to
alpha = linspace(pi/2 + 1e-10, pi, 15),
then run code, plot data, press hold on, and then switch alpha intervals yet again.
This will be quite error prone, as my modeling work builds up in complexity.
So, how can I run code just once, to get all calculations, for all alpha?
If I try to run code just once, for all alpha, the code doesn’t run.
I have to go one interval of alpha at a time, for the code to run.
Thanks in advance!Let’s say I want to calculate things for alpha ranging from 0 to 2pi.
I’ve written if / else-if statements to do this:
alpha = linspace(0, 2pi, 100)
if 0 <= alpha & alpha <= pi/2
calculate this;
elseif pi/2 < alpha & alpha < pi
calculate this;
end
Now, after I’ve finished debugging this code, I noticed I can only run the code for one, specific interval of alpha at a time.
So, I have to use
alpha = linspace(0, pi/2, 15),
then run code, plot data, press hold on, and then switch to
alpha = linspace(pi/2 + 1e-10, pi, 15),
then run code, plot data, press hold on, and then switch alpha intervals yet again.
This will be quite error prone, as my modeling work builds up in complexity.
So, how can I run code just once, to get all calculations, for all alpha?
If I try to run code just once, for all alpha, the code doesn’t run.
I have to go one interval of alpha at a time, for the code to run.
Thanks in advance! Let’s say I want to calculate things for alpha ranging from 0 to 2pi.
I’ve written if / else-if statements to do this:
alpha = linspace(0, 2pi, 100)
if 0 <= alpha & alpha <= pi/2
calculate this;
elseif pi/2 < alpha & alpha < pi
calculate this;
end
Now, after I’ve finished debugging this code, I noticed I can only run the code for one, specific interval of alpha at a time.
So, I have to use
alpha = linspace(0, pi/2, 15),
then run code, plot data, press hold on, and then switch to
alpha = linspace(pi/2 + 1e-10, pi, 15),
then run code, plot data, press hold on, and then switch alpha intervals yet again.
This will be quite error prone, as my modeling work builds up in complexity.
So, how can I run code just once, to get all calculations, for all alpha?
If I try to run code just once, for all alpha, the code doesn’t run.
I have to go one interval of alpha at a time, for the code to run.
Thanks in advance! if statement, for loop MATLAB Answers — New Questions
Import .XML data into Matlab?
Hi guys,
I want to import an xml file and its data into matlab so that I can read the data.
I know you have to do something like: xDoc = xmlread(‘info.xml’);
But I don’t know much else after that. What code would I need to write to get the ‘Customer’ details from a .xml file with following content?
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<Shop Target="Something" Source="Something else">
<Customer ID="" LastName="Smith" FirstName="Joe" Birthday="1950/01/01" Gender="male">
<Purchase Type="Type 1" Time="2016/02/23 09:45" />
<Purchase Type="Type 2" Time="2016/02/24 09:45" />
</Customer>
</Shop>
Thank youHi guys,
I want to import an xml file and its data into matlab so that I can read the data.
I know you have to do something like: xDoc = xmlread(‘info.xml’);
But I don’t know much else after that. What code would I need to write to get the ‘Customer’ details from a .xml file with following content?
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<Shop Target="Something" Source="Something else">
<Customer ID="" LastName="Smith" FirstName="Joe" Birthday="1950/01/01" Gender="male">
<Purchase Type="Type 1" Time="2016/02/23 09:45" />
<Purchase Type="Type 2" Time="2016/02/24 09:45" />
</Customer>
</Shop>
Thank you Hi guys,
I want to import an xml file and its data into matlab so that I can read the data.
I know you have to do something like: xDoc = xmlread(‘info.xml’);
But I don’t know much else after that. What code would I need to write to get the ‘Customer’ details from a .xml file with following content?
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<Shop Target="Something" Source="Something else">
<Customer ID="" LastName="Smith" FirstName="Joe" Birthday="1950/01/01" Gender="male">
<Purchase Type="Type 1" Time="2016/02/23 09:45" />
<Purchase Type="Type 2" Time="2016/02/24 09:45" />
</Customer>
</Shop>
Thank you xml, gender MATLAB Answers — New Questions
Generating trapezoidal wave given plateau duration and total length of impulse train
Hello,
I want to plot a trapezoidal wave train knowing only the plateau times, meaning the duration of the "flat part" of the trapezoidal wave, and the total duration of the impulse train, depending on another data vector I have. I do not have the equation of the ascending or descending parts, even though I can calculate them. But I need an easy way to plot this in matlab.
The plateaus need to be 60 seconds long and total number of points needs to be equal to the length of a data vector A.
So far I only found the trapezoidal equation with some parameters:
a = 0.5 %Amplitude
m = 9.55 % Time Period
l = 3*pi/2 % phase
c = a/2 % offset
x = 0:.1:100 %Sample Points
Trapezoidal_Wave = a/pi*(asin(sin((pi/m)*x+l))+acos(cos((pi/m)*x+l)))-a/2+c;
plot(x, Trapezoidal_Wave)
However I cannot control the plateau duration (or I don’t understand how). Any help and any better way to do this would be greatly appreciated. Thank you!Hello,
I want to plot a trapezoidal wave train knowing only the plateau times, meaning the duration of the "flat part" of the trapezoidal wave, and the total duration of the impulse train, depending on another data vector I have. I do not have the equation of the ascending or descending parts, even though I can calculate them. But I need an easy way to plot this in matlab.
The plateaus need to be 60 seconds long and total number of points needs to be equal to the length of a data vector A.
So far I only found the trapezoidal equation with some parameters:
a = 0.5 %Amplitude
m = 9.55 % Time Period
l = 3*pi/2 % phase
c = a/2 % offset
x = 0:.1:100 %Sample Points
Trapezoidal_Wave = a/pi*(asin(sin((pi/m)*x+l))+acos(cos((pi/m)*x+l)))-a/2+c;
plot(x, Trapezoidal_Wave)
However I cannot control the plateau duration (or I don’t understand how). Any help and any better way to do this would be greatly appreciated. Thank you! Hello,
I want to plot a trapezoidal wave train knowing only the plateau times, meaning the duration of the "flat part" of the trapezoidal wave, and the total duration of the impulse train, depending on another data vector I have. I do not have the equation of the ascending or descending parts, even though I can calculate them. But I need an easy way to plot this in matlab.
The plateaus need to be 60 seconds long and total number of points needs to be equal to the length of a data vector A.
So far I only found the trapezoidal equation with some parameters:
a = 0.5 %Amplitude
m = 9.55 % Time Period
l = 3*pi/2 % phase
c = a/2 % offset
x = 0:.1:100 %Sample Points
Trapezoidal_Wave = a/pi*(asin(sin((pi/m)*x+l))+acos(cos((pi/m)*x+l)))-a/2+c;
plot(x, Trapezoidal_Wave)
However I cannot control the plateau duration (or I don’t understand how). Any help and any better way to do this would be greatly appreciated. Thank you! plotting, impulse, trapezoidal MATLAB Answers — New Questions
EDF writing – error when using cell array as signal DATA
Hello 🙂
I would like to do a edf file entering my signals from a cell array (bin of time x EEG channels). Into each cells I have a vector containting 1000 values (mV across time). See picture:
However, I do get a very surprising error :
Error using signal.internal.edf.write.validateSignalData
Expected input to be a vector.
Error in signal.internal.edf.write.getFileCreateOpts>checkSignals (line 223)
signal.internal.edf.write.validateSignalData(sigData, …
Error in signal.internal.edf.write.getFileCreateOpts>createHdr (line 96)
[reqhdr, sigData] = checkSignals(reqhdr, sigData, tNumSignals);
Error in signal.internal.edf.write.getFileCreateOpts>createAndValidateHeader (line 47)
[hdr, sigData, tsal] = createHdr(thdr, sigData, tsal, hdrPropertiesList, …
Error in signal.internal.edf.write.getFileCreateOpts (line 13)
[hdr, sigData, tsal] = createAndValidateHeader(hdr, sigData, tsal, …
Error in edfwrite/createFile (line 1620)
signal.internal.edf.write.getFileCreateOpts(hdr, signalData, …
Error in edfwrite (line 499)
[obj, fileInfo] = createFile(obj, filename, hdr,…
It comes from this function in Matlab "source" code (function : validateSignalData ligne: 15):
validateattributes(signalData, {‘cell’}, {‘vector’});
I did check several times : Inside of each cells, I have a vector.
If I write :
isvector(data_cell{1,1})
ans =
logical
1
Valide for all cells
But if I ask :
validateattributes(data_cell, {‘cell’}, {‘vector’})
Expected input to be a vector.
Am I missing something because I do not see why my cell array would not have a vector attribute inside ?
My code when creating data_cell:
data_cell = {};
for nb_sig = 1: hdr.NumSignals
for time = 1:floor(length(LFP(1,:))/srate) % in sec
startpoint = ((time-1)*srate+1);
stoppoint = ((time-1)*srate+1) + srate;
temp_vect = LFP(nb_sig,startpoint:stoppoint);
data_cell{time, nb_sig} = temp_vect’;
end
end
file_EDF_name = "R005_S1_V4.edf";
edfw = edfwrite(fullfile(pahtway_saving,file_EDF_name),hdr,data_cell);
Link for necessary variables :
https://seafile.unistra.fr/f/f102cbe386824199a6fe/?dl=1Hello 🙂
I would like to do a edf file entering my signals from a cell array (bin of time x EEG channels). Into each cells I have a vector containting 1000 values (mV across time). See picture:
However, I do get a very surprising error :
Error using signal.internal.edf.write.validateSignalData
Expected input to be a vector.
Error in signal.internal.edf.write.getFileCreateOpts>checkSignals (line 223)
signal.internal.edf.write.validateSignalData(sigData, …
Error in signal.internal.edf.write.getFileCreateOpts>createHdr (line 96)
[reqhdr, sigData] = checkSignals(reqhdr, sigData, tNumSignals);
Error in signal.internal.edf.write.getFileCreateOpts>createAndValidateHeader (line 47)
[hdr, sigData, tsal] = createHdr(thdr, sigData, tsal, hdrPropertiesList, …
Error in signal.internal.edf.write.getFileCreateOpts (line 13)
[hdr, sigData, tsal] = createAndValidateHeader(hdr, sigData, tsal, …
Error in edfwrite/createFile (line 1620)
signal.internal.edf.write.getFileCreateOpts(hdr, signalData, …
Error in edfwrite (line 499)
[obj, fileInfo] = createFile(obj, filename, hdr,…
It comes from this function in Matlab "source" code (function : validateSignalData ligne: 15):
validateattributes(signalData, {‘cell’}, {‘vector’});
I did check several times : Inside of each cells, I have a vector.
If I write :
isvector(data_cell{1,1})
ans =
logical
1
Valide for all cells
But if I ask :
validateattributes(data_cell, {‘cell’}, {‘vector’})
Expected input to be a vector.
Am I missing something because I do not see why my cell array would not have a vector attribute inside ?
My code when creating data_cell:
data_cell = {};
for nb_sig = 1: hdr.NumSignals
for time = 1:floor(length(LFP(1,:))/srate) % in sec
startpoint = ((time-1)*srate+1);
stoppoint = ((time-1)*srate+1) + srate;
temp_vect = LFP(nb_sig,startpoint:stoppoint);
data_cell{time, nb_sig} = temp_vect’;
end
end
file_EDF_name = "R005_S1_V4.edf";
edfw = edfwrite(fullfile(pahtway_saving,file_EDF_name),hdr,data_cell);
Link for necessary variables :
https://seafile.unistra.fr/f/f102cbe386824199a6fe/?dl=1 Hello 🙂
I would like to do a edf file entering my signals from a cell array (bin of time x EEG channels). Into each cells I have a vector containting 1000 values (mV across time). See picture:
However, I do get a very surprising error :
Error using signal.internal.edf.write.validateSignalData
Expected input to be a vector.
Error in signal.internal.edf.write.getFileCreateOpts>checkSignals (line 223)
signal.internal.edf.write.validateSignalData(sigData, …
Error in signal.internal.edf.write.getFileCreateOpts>createHdr (line 96)
[reqhdr, sigData] = checkSignals(reqhdr, sigData, tNumSignals);
Error in signal.internal.edf.write.getFileCreateOpts>createAndValidateHeader (line 47)
[hdr, sigData, tsal] = createHdr(thdr, sigData, tsal, hdrPropertiesList, …
Error in signal.internal.edf.write.getFileCreateOpts (line 13)
[hdr, sigData, tsal] = createAndValidateHeader(hdr, sigData, tsal, …
Error in edfwrite/createFile (line 1620)
signal.internal.edf.write.getFileCreateOpts(hdr, signalData, …
Error in edfwrite (line 499)
[obj, fileInfo] = createFile(obj, filename, hdr,…
It comes from this function in Matlab "source" code (function : validateSignalData ligne: 15):
validateattributes(signalData, {‘cell’}, {‘vector’});
I did check several times : Inside of each cells, I have a vector.
If I write :
isvector(data_cell{1,1})
ans =
logical
1
Valide for all cells
But if I ask :
validateattributes(data_cell, {‘cell’}, {‘vector’})
Expected input to be a vector.
Am I missing something because I do not see why my cell array would not have a vector attribute inside ?
My code when creating data_cell:
data_cell = {};
for nb_sig = 1: hdr.NumSignals
for time = 1:floor(length(LFP(1,:))/srate) % in sec
startpoint = ((time-1)*srate+1);
stoppoint = ((time-1)*srate+1) + srate;
temp_vect = LFP(nb_sig,startpoint:stoppoint);
data_cell{time, nb_sig} = temp_vect’;
end
end
file_EDF_name = "R005_S1_V4.edf";
edfw = edfwrite(fullfile(pahtway_saving,file_EDF_name),hdr,data_cell);
Link for necessary variables :
https://seafile.unistra.fr/f/f102cbe386824199a6fe/?dl=1 edf, edfwrite MATLAB Answers — New Questions
How to set the control algorithm’s execution frequency on the flight control board when using the UAV Toolbox Support Package for PX4 Autopilots?
When I am designing a control algorithm using the PX4 support package, I want to set the execution frequency of my control algorithm on the real flight board. I’m not sure if it’s set under "Model settings -> solver". Moreover, I don’t know how to verify whether my control algorithm is running with the step size I’ve set. Does anyone understand this issue? Please help me, thank you very much!When I am designing a control algorithm using the PX4 support package, I want to set the execution frequency of my control algorithm on the real flight board. I’m not sure if it’s set under "Model settings -> solver". Moreover, I don’t know how to verify whether my control algorithm is running with the step size I’ve set. Does anyone understand this issue? Please help me, thank you very much! When I am designing a control algorithm using the PX4 support package, I want to set the execution frequency of my control algorithm on the real flight board. I’m not sure if it’s set under "Model settings -> solver". Moreover, I don’t know how to verify whether my control algorithm is running with the step size I’ve set. Does anyone understand this issue? Please help me, thank you very much! simulink, uav toolbox support package for px4 autopilots MATLAB Answers — New Questions