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...

4 years 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...

4 years 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...

4 years 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...

4 years 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...

4 years 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...

4 years 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(...

4 years 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...

4 years ago | 0

| accepted

Answered
Add x=y line to the scatter plot
hold on plot(xlim,ylim,'-b')

4 years ago | 2

| accepted

Answered
Change scale of x-axis on plot
hAx=gca; hAx.XAxis.TickLabelFormat='%d'; hAx.XAxis.Exponent=0;

4 years 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 = ...

4 years 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; ...

4 years 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 ...

4 years 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...

4 years 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...

4 years 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-...

4 years 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 =...

4 years 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...

4 years 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...

4 years 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...

4 years 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. ...

4 years 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...

4 years 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 ...

4 years 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...

4 years 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 ...

4 years 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 ...

4 years 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]} >> ...

4 years ago | 0

| accepted

Answered
how to find the nearest value?
The builtin way in MATLAB is interp1 >> A=[1:6]; >> B=flip(A)+0.1; >> posn=[10:10:60]; >> C=posn(interp1(B,A,A,'nearest','ex...

4 years ago | 0

Answered
Problems with function num2str
Well, having a file helps (as always)... >> DatosInfo=ncinfo('..\Answers\DatosMarzoD1.nc') % see what's in the file... DatosIn...

4 years ago | 1

| accepted

Answered
How to put endpoint on Bar graph
Like maybe? There's a klunky example at the doc for bar, but it is far simpler than the multi-step illustration to write it ...

4 years ago | 0

Load more