Answered

Textscan import string data from .txt file

Read the file as is and then clean it up instead... d=readcell('202103.txt','Delimiter',newline); % read a cellst...

Textscan import string data from .txt file

Read the file as is and then clean it up instead... d=readcell('202103.txt','Delimiter',newline); % read a cellst...

16 jours ago | 0

| accepted

Answered

Matlab - problem with snr function

The two inputs have to have the same orientation as well as same length. You've created a row vector above for the noise while ...

Matlab - problem with snr function

The two inputs have to have the same orientation as well as same length. You've created a row vector above for the noise while ...

16 jours ago | 0

| accepted

Answered

How to preserve nanosecond precision in datetime calculations (for large numbers)

>> t='1294871257.002060945'; % treat long value as string >> dsec=seconds(str2double(ext...

How to preserve nanosecond precision in datetime calculations (for large numbers)

>> t='1294871257.002060945'; % treat long value as string >> dsec=seconds(str2double(ext...

18 jours ago | 0

Answered

Is it possible to declare a char variable as global?

Seems to work just fine here -- although globals are fraught with danger, if you're cautious the above usage doesn't seem too eg...

Is it possible to declare a char variable as global?

Seems to work just fine here -- although globals are fraught with danger, if you're cautious the above usage doesn't seem too eg...

18 jours ago | 0

| accepted

Answered

Loop through folders to pick data file

You shouldn't be putting your data files under the MATLABROOT tree....that's fraught with difficulties when upgrade. MATLAB cre...

Loop through folders to pick data file

You shouldn't be putting your data files under the MATLABROOT tree....that's fraught with difficulties when upgrade. MATLAB cre...

18 jours ago | 0

Answered

I need to change n elements in an array chosen randomly

Not totally clear yet just what are valid locations to be changed -- the above code sets the diagonal elements to one anyways; i...

I need to change n elements in an array chosen randomly

Not totally clear yet just what are valid locations to be changed -- the above code sets the diagonal elements to one anyways; i...

18 jours ago | 0

Answered

How can I perform a set of calculations on multiple matrices located in a csv. file?

Those files have structure to deal with -- generically, one could read the header info and parse it to find out the content -- b...

How can I perform a set of calculations on multiple matrices located in a csv. file?

Those files have structure to deal with -- generically, one could read the header info and parse it to find out the content -- b...

19 jours ago | 0

Answered

How to save fig in a different folder

mydir='yourfullyqualifiedpath'; savefig(figure(1),fullfile(mydir,'results','h.fig'),'compact'); The above also has the hardcod...

How to save fig in a different folder

mydir='yourfullyqualifiedpath'; savefig(figure(1),fullfile(mydir,'results','h.fig'),'compact'); The above also has the hardcod...

19 jours ago | 0

| accepted

Answered

Create dir using greek symbol

Which OS/file system? Even if it is allowed by the above combination, I would strongly advise against doing so; it'll just lead...

Create dir using greek symbol

Which OS/file system? Even if it is allowed by the above combination, I would strongly advise against doing so; it'll just lead...

19 jours ago | 0

Answered

How do I import quarterly data from Excel

>> tQ=readtable('..\Answers\Data_QFE.xlsx'); >> tQ.Year=datetime(tQ.Year,'InputFormat','uuuuQQQ','Format','uuuuQQQ'); >> head(...

How do I import quarterly data from Excel

>> tQ=readtable('..\Answers\Data_QFE.xlsx'); >> tQ.Year=datetime(tQ.Year,'InputFormat','uuuuQQQ','Format','uuuuQQQ'); >> head(...

19 jours ago | 0

Answered

What is this peak's meaning?

Or, it's just random noise or other non-meaningful artifact; we don't know for sure... How was the frequency axis created to ge...

What is this peak's meaning?

Or, it's just random noise or other non-meaningful artifact; we don't know for sure... How was the frequency axis created to ge...

19 jours ago | 0

| accepted

Answered

Change scale of x-axis on plot

hAx=gca; hAx.XAxis.TickLabelFormat='%d'; hAx.XAxis.Exponent=0;

Change scale of x-axis on plot

hAx=gca; hAx.XAxis.TickLabelFormat='%d'; hAx.XAxis.Exponent=0;

20 jours ago | 0

Answered

Why do upsample and downsample commands give wrong results in start of sequence?

Don't know what the complaint is, precisely? upsample and downsample are working as documented -- >> upsample(1:4,3) ans = ...

Why do upsample and downsample commands give wrong results in start of sequence?

Don't know what the complaint is, precisely? upsample and downsample are working as documented -- >> upsample(1:4,3) ans = ...

20 jours ago | 0

Answered

Help trying to manually insert peaks after findpeaks through a radio or push button please!

I'll let you deal with coding the callback to a button, but %...your above code here... hAx=gca; ...

Help trying to manually insert peaks after findpeaks through a radio or push button please!

I'll let you deal with coding the callback to a button, but %...your above code here... hAx=gca; ...

21 jours ago | 1

| accepted

Answered

How exactly does MATLAB calculate a sum of array elements by its sum() function? Does it use any compensated summation algorithm such as Kahan?

TMW does not document publicly algorithms beyond anything provided in the documentation Description section or, occasionally an ...

How exactly does MATLAB calculate a sum of array elements by its sum() function? Does it use any compensated summation algorithm such as Kahan?

TMW does not document publicly algorithms beyond anything provided in the documentation Description section or, occasionally an ...

21 jours ago | 1

Answered

intersect between the second column of cell array A (for all rows) and the first column of cell array B (for all rows)

This may or may not be possible with simple syntax depending upon the content of the cell arrays...if it can work, [H,ih,ik]=i...

intersect between the second column of cell array A (for all rows) and the first column of cell array B (for all rows)

This may or may not be possible with simple syntax depending upon the content of the cell arrays...if it can work, [H,ih,ik]=i...

21 jours ago | 0

Answered

how to merge 2 variable of different size?

With what expected as result, pray tell? You can't have a 2-column matrix of 25-elements; you could keep the two as elements in...

how to merge 2 variable of different size?

With what expected as result, pray tell? You can't have a 2-column matrix of 25-elements; you could keep the two as elements in...

26 jours ago | 0

Answered

making the x-axis and y-axis fixed for all plots

If you use x/ylim before plotting and then use plot, the auto-scaling will still be in effect for the axis and plot as the high-...

making the x-axis and y-axis fixed for all plots

If you use x/ylim before plotting and then use plot, the auto-scaling will still be in effect for the axis and plot as the high-...

29 jours ago | 0

| accepted

Answered

I have a function "f" that returns a 1x2 vector, and I need to make a 3x2 matrix M by stacking the outputs f(x1), f(x2), f(x3) on top of each other, but Matlab won't parse it.

The first syntax will work if the function actually returns a vector -- >> x=rand(1,5); >> fnX=@(i)x(i:i+1); >> fnX(1) ans =...

I have a function "f" that returns a 1x2 vector, and I need to make a 3x2 matrix M by stacking the outputs f(x1), f(x2), f(x3) on top of each other, but Matlab won't parse it.

The first syntax will work if the function actually returns a vector -- >> x=rand(1,5); >> fnX=@(i)x(i:i+1); >> fnX(1) ans =...

29 jours ago | 0

| accepted

Answered

what does the "oldx =[x(n);oldx(1:256)]" in the following programm do?

It will (very inefficiently) append the first 255 elements of the (NEW and this is key) oldx vector onto the value of the read-i...

what does the "oldx =[x(n);oldx(1:256)]" in the following programm do?

It will (very inefficiently) append the first 255 elements of the (NEW and this is key) oldx vector onto the value of the read-i...

environ un mois ago | 0

Answered

Sorting cell for only dublicate values

Alternate approach to Jan's using features of categorical arrays (which the IDs logically are) % some dummy data of the same ty...

Sorting cell for only dublicate values

Alternate approach to Jan's using features of categorical arrays (which the IDs logically are) % some dummy data of the same ty...

environ un mois ago | 0

| accepted

Answered

I have a function (ex. adaptive) in a for loop which has two arrays as output. I want to save all the outputs in a single matrix. it can just save the last vector

You have to index the out arrays on the LHS of the assignment or MATLAB will, as you've observed, overwrite the whole variable o...

I have a function (ex. adaptive) in a for loop which has two arrays as output. I want to save all the outputs in a single matrix. it can just save the last vector

You have to index the out arrays on the LHS of the assignment or MATLAB will, as you've observed, overwrite the whole variable o...

environ un mois ago | 0

| accepted

Answered

How can I index a duration variable

Always much easier if you attach the actual code you've used to get to this point and a little bit, at least of the data array. ...

How can I index a duration variable

Always much easier if you attach the actual code you've used to get to this point and a little bit, at least of the data array. ...

environ un mois ago | 0

| accepted

Answered

How do I pull out from a table, the total mean of one item based on a particular condition (for several subjects), and then compute the difference in mean values?

tMEANS=rowfun(@mean,tData,'GroupingVariables'{'ConditionZ'},'InputVariables','ItemA','OutputVariableNames','GroupedMeans'); See...

How do I pull out from a table, the total mean of one item based on a particular condition (for several subjects), and then compute the difference in mean values?

tMEANS=rowfun(@mean,tData,'GroupingVariables'{'ConditionZ'},'InputVariables','ItemA','OutputVariableNames','GroupedMeans'); See...

environ un mois ago | 0

Answered

Help creating loop that converts text to numbers

>> A='Now is the time...'; >> format short >> disp(double(A)) 78 111 119 32 105 115 32 116 104 101 ...

Help creating loop that converts text to numbers

>> A='Now is the time...'; >> format short >> disp(double(A)) 78 111 119 32 105 115 32 116 104 101 ...

environ un mois ago | 0

Answered

Removing quotations from table display

It's more a sanity check for the user to make sure their values are correct for what they expect. And there's where the purpose...

Removing quotations from table display

It's more a sanity check for the user to make sure their values are correct for what they expect. And there's where the purpose...

environ un mois ago | 0

Answered

fwrite ascii output error

I see no such thing... >> fid=fopen('test2.dat'); fread(fid,'*int16') fid=fclose(fid); ans = 2×1 int16 column vector ...

fwrite ascii output error

I see no such thing... >> fid=fopen('test2.dat'); fread(fid,'*int16') fid=fclose(fid); ans = 2×1 int16 column vector ...

environ un mois ago | 0

Answered

How to reform cell into a vector of strings and text

Two of many ways to deal with the cellstr -- As string array >> S=string(split(C,',')); S=S(S~="") S = 6×1 string array ...

How to reform cell into a vector of strings and text

Two of many ways to deal with the cellstr -- As string array >> S=string(split(C,',')); S=S(S~="") S = 6×1 string array ...

environ un mois ago | 0

Answered

How do I swap 2 rows of a cell array?

One way... >> C=num2cell(randi(10,3,2)) C = 3×2 cell array {[5]} {[1]} {[9]} {[5]} {[6]} {[5]} >> ...

How do I swap 2 rows of a cell array?

One way... >> C=num2cell(randi(10,3,2)) C = 3×2 cell array {[5]} {[1]} {[9]} {[5]} {[6]} {[5]} >> ...

environ un mois ago | 0

| accepted