Answered
An efficient (quick) way of entering complex data into Matlab workspace.
What about avoiding the conversion from int16 to single by doing this on the fly: temp = fread(fileID, dataSize, 'int16=>singl...

7 years ago | 0

Answered
program a callback for a keypress
Click on the figure to set the focus on it. According the the documentation this command should set the focus also: figure(fig...

7 years ago | 1

Answered
getting extra zeor's when i convert 2d to 1d
A Matlab'ish solution: c_v = reshape(m.', [], 1) To find the problem in your code, use the debugger: Set a breakpoint in the c...

7 years ago | 0

Answered
how to plot two figures in one figure with different axes
Simply replace the line: date2 = datenum(year2, month2, day2, hour2, min2, sec2); by date2 = datenum(year1, month1, day1, hou...

7 years ago | 0

| accepted

Answered
Automatically writing a function does not update until manually opening said function
You forgot the fclose statements. In addition you do not need to open the file twice for appending. This should work: fid = fo...

7 years ago | 0

| accepted

Answered
randomly generated spheres in a volume in Matlab
function P = GetRandomSpheres(nWant, Width, Radius) % INPUT: % nWant: Number of spheres % Width: Dimension of 3d box as...

7 years ago | 8

| accepted

Answered
how to full fill the diagonal of a matrix by a vector
m = zeros(5,5); v = [1,2,3,4]; n = numel(v); index = 1:n; for i = 1:size(m,2) m(mod(i-1:i+n-2, 5)+1, i) = v; end

7 years ago | 1

Answered
I need a code for sorting two column with a condition.
A simple approach with a loop: % {X(i)-X(i+1)>0 and Y(i)-Y(i+1)>0} OR {X(i)-X(i+1)<0 and Y(i)-Y(i+1)<0} n = 10; X = rand(n, 1...

7 years ago | 1

| accepted

Answered
inter distance between point to be more than a certain number
I'm not sure if this helps. It finds nWant random points inside [XWidth, YWidth] with a minimum distance between all points. fu...

7 years ago | 0

Answered
ODE45 generates undesired matrix of NaN entries
Use the debugger to stop, when a NaN occurs: dbstop if naninf Type this in the command window. Now run the code again until it...

7 years ago | 1

Answered
How to alter Slider Colours?
No. The color of the sliders is determined in the operating system. With standard sliders, you cannot set the colors freely. Se...

7 years ago | 0

Answered
How to use column wise operations on nested cell arrays?
With 2 loops: for iStimuli = 1:23 aStimuli = stimuli{iStimuli}; for iData = 1:numel(aStimuli) Data = aSt...

7 years ago | 0

Answered
How can I load .psv file to MATLAB?
A small example would reveal, if this guess is correct: It is a pipe-separated text file. Then: readmatrix(filename, 'Delimiter...

7 years ago | 1

| accepted

Answered
Index in position 1 exceeds array bounds (must not exceed 1)
I guess you want: y = length(E2); l = length(Ent_dept); per_dev = zeros(x, l); % Pre-allocate for s=1:y for c=1:l ...

7 years ago | 0

Answered
How do I sum multiple vectors inside an array?
You can use the force between two bodies twice: f = zeros(n, n, 3); for i = 1:n for x = i+1:n f_ix = G * (p(x,...

7 years ago | 0

Answered
i need RC4 encryption code for text
A simple web search reveals: https://www.mathworks.com/matlabcentral/fileexchange/67242-rc4 (This is from the same author as th...

7 years ago | 0

| accepted

Answered
My documentation on Windows is broken
When I search in the net for the posted error message, I find: https://www.mathworks.com/matlabcentral/answers/423210-why-is-mat...

7 years ago | 0

| accepted

Answered
sir i tried one code for framing and windowing but the code showing error like this Error in lpcoefficient (line 21) wind(i,:)=fr_ws(i,:).*r(i,:); how i rectify the error
One hint: In for i=1:num_frames v=length(fr_ws); r=hamming(v); wind(i,:)=fr_ws(i,:).*r(i,:); end v and r are c...

7 years ago | 0

Answered
For Loop in Data
x = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 ]; y = cell(1, 4); for k = 1:4 y{k} = x(1-k:end) - x(1:end-k); end ...

7 years ago | 0

| accepted

Answered
Do you suffer from keyboard latency in this forum?
And a new update: Today the characters appear around 1 second after I've type them. During standard typing this is more or less ...

7 years ago | 0

Answered
Find function for cell array
Do all elemts of the cell have the same size and type? Then working with a numerical array is easier and faster: M = cat(1, myC...

7 years ago | 0

| accepted

Answered
App Designer: Display text before executing
This is a job for drawnow. Insert it after modifying the contents of the window to give Matlab the chance to update the display....

7 years ago | 1

Answered
Converting binary like table but using decimal values
With the fast C-Mex function https://www.mathworks.com/matlabcentral/fileexchange/26242-vchoosekro R = VChooseKRO(-2:2, 2) Or:...

7 years ago | 0

Answered
Generating all ordered samples with replacement
A fast C-mex: https://www.mathworks.com/matlabcentral/fileexchange/26242-vchoosekro If you do not have a C-compiler: function ...

7 years ago | 0

| accepted

Answered
xlswrite error in MATLAB R2018b
What about the hint given in the error message: To write to an Excel file, convert your data to a table and use writetable.

7 years ago | 0

Answered
How do I get TruRNG V3 results into excel as quickly as possible
If you mean TrueRNG, the web page suggests: https://www.mathworks.com/matlabcentral/fileexchange/46168-truerng-hardware-random-...

7 years ago | 0

Answered
World mystery!How can i stop all the sub-functions immediately?
"stop the process every time" is dangerous and rarely useful. If it happens during writing a file, the hard disk might be left i...

7 years ago | 2

Answered
Delete row when one cell is empty
Perhaps: C = {'a', 'b'; ... [], 'c'; ... 'd', 'q'} m = any(cellfun('isempty', C), 2); % Any cell in row is empty...

7 years ago | 0

| accepted

Answered
How to convert a code from C language to Matlab
Try this one - it is not debugged and written in the forum's interface: function main NUM_CHECK_POINTS = 100000; coeff ...

7 years ago | 0

| accepted

Answered
use workspace variables as input to generate multiple text file outputs
Data = load('INPUTFILE.mat'); DataName = fieldnames(Data); for k = 1:numel(DataName) ThisName = DataName{k}; Thi...

7 years ago | 1

| accepted

Load more