Answered
Running external commands without going through a shell?
You can try a mex routine: https://www.mathworks.com/matlabcentral/fileexchange/341-spawn Maybe this works for you: runtime = ...

1 month ago | 1

| accepted

Answered
One/zero Matrix, merge subset of columns
x0 = [ 0, 0, 0, 1, 0, 0; ... 0, 1, 1, 1, 1, 1; ... 0, 1, 1, 0, 1, 1; ... 0, 0, 0, 0, 0, 0; ... 0, 0, 0, 0, 0, 0; ... ...

1 month ago | 0

| accepted

Answered
Input [Hex] String then convert to binary from Hex
I guess, you are using an older version of Matlab, which does not allow to write hex numbers in the code directly. Then: HexArr...

1 month ago | 0

Answered
How to find differences of 2 matrices which contain other matrices as elements?
The main problem is the choice of the data representation. Using an indexed field would allow to call setdiff(). Data.o1 = eye(...

1 month ago | 0

Answered
How do I write a sparse matrix in MATLAB
You want to convert a sparse matrix into a full one? Then use the command: full().

1 month ago | 2

Answered
How to convert a .txt file to any image format
The contents of the file does not contain enouh information to understand the format completely. The initial "2 2 1 1" might be ...

1 month ago | 0

Answered
Error with matrix multiplication?
This should work. Use the debugger to let Matlab stop when the error occurs - type this in the command window: dbstop if error ...

1 month ago | 0

Answered
define end of line (eol) as unix (\n) not Windows (\r\n) using writecell
What about writing directly? C = [{"Some string"}; {"Another string"}]; fid = fopen('testEOL.txt', 'w'); fprintf(fid, '%s\n...

1 month ago | 1

| accepted

Answered
My plot won't show any graph
I assume, this is an effect or drawing a line with just 1 point, which produces no line. Try plot(t, S(1,1), 'linewidth', 5,...

1 month ago | 0

Answered
Multiplication of very large matrix
How strange: The comments above have not been displayed on my other computer. So this answer was written 1 hour after MA's comme...

1 month ago | 0

| accepted

Answered
How to find differences of 2 matrices which contain other matrices as elements?
function [AA, AI] = CellDiff(A, B) nA = numel(A); nB = numel(B); M = false(1, nA); % Typo fixed, thanks Paul for iA = 1:n...

1 month ago | 0

Answered
Error using Conv in matlab and don't know where's the problem.
Check, if you are using the function you expect: which conv Do you get: C:\Program Files\MATLAB\R2018b\toolbox\matlab\datafun\...

1 month ago | 0

Answered
Writing ~ using fprintf
The tilde can be printed directly without escaping: fprintf('This is a tile: ~\n') And what is the problem with adding text? ...

1 month ago | 0

| accepted

Answered
Poor MEX performance when running filtfilt
Just a remark: With FiltFiltM (https://www.mathworks.com/matlabcentral/fileexchange/32261-filterm ) my Matlab 2018b needs 6.0 in...

1 month ago | 0

Answered
IF loop to select values superior of a threshold in a matrix
for k = 1:100 match = (A(k, 1:4) > 0.85); A(k, 5) = sum(A(k, match)) / sum(match); end This works faster without a...

1 month ago | 0

| accepted

Answered
Confusion about performance improvement by memory preallocation
Try to replace this part of the first solution: for z = 1:115 % 1-Hz variables from row 1 to row 115 temp = []; % ...

1 month ago | 0

| accepted

Answered
Error using readtable (line 245)
Your file is destroyed. Neither readtable, nor xlsread not Excel can open it successfully. Some of its parts are valid, as you c...

1 month ago | 0

| accepted

Answered
Using for loop within a for loop in MATLAB
Cleanup the strange nested loops over scalars: for i=1 T= 423.85; Tr(i)=T/Tc(i); ...

1 month ago | 0

Answered
Please Help me solve this loop!
You do not need a loop: S = cumsum(q - d);

1 month ago | 0

Answered
How to remove XTick labels without removing XTicks?
https://www.mathworks.com/matlabcentral/fileexchange/81858-subplots-subplotting-made-easy https://www.mathworks.com/matlabcentr...

1 month ago | 1

Answered
How to change sign of matrix
% Test data: X = rand(5, 10); S = 1 - 2 * (rand(5, 10) > 0.5); % Random matrix of 1 and -1 % The calculation: Result = X ...

1 month ago | 0

| accepted

Answered
Plot command inside a loop will not display all data unless drawnow is used
Missing plots can happen, if a timer or GUI callback changes the current figure. Instead of the instabkle method to set the curr...

2 months ago | 0

| accepted

Answered
How do I convert a 3d cell array of different size to matrix?
M = cat(3, ETT{:}); No, this cannot create a 1x10 matrix.

2 months ago | 0

| accepted

Answered
how can I appropriately get a for loop to extract wav files to sub folders(directories)??
List = dir('\\users\audio_stems\*.wav'); %folders for seperate instruments mkdir Basson mkdir Saxphone mkdir Clarinet mkdir...

2 months ago | 0

| accepted

Answered
Is it possible to vectorize this loop?
A = rand(1, 1000); B = rand(1, 1000); tic for k = 1:1000 w = 0; for i = 1:length(A) w = w + A(i).*B; end end...

2 months ago | 1

Answered
Using fprintf to repeat the statement multiple times
Almost working. n = input('Enter a integer: '); for k = 1:n fprintf('I love this stuff\n') end Ask for n before the loo...

2 months ago | 0

| accepted

Answered
I have two 3d points, A(1,0,0) and B(0,1,0). And I connect these two points as a line AB. How to divide this line into 10 equally segments and get their coordinates?
A = [1, 0, 0]; B = [0, 1, 0]; ab = B - A; v = linspace(0, 1, 10).'; C = A + v .* ab % >= R2016b, auto-expanding % ...

2 months ago | 0

Answered
how do i substract the first value from the last one on an array taking out zero values?
Get the corresponding indices: first = find(X, 1, 'first'); last = find(X, 1, 'last'); Result = X(last) - X(first)

2 months ago | 0

| accepted

Answered
how to solve this error: Error using ' TRANSPOSE does not support N-D arrays. Use PAGETRANSPOSE/PAGECTRANSPOSE to transpose pages or PERMUTE to reorder dimensions of N-D arrays
What is the size of u10 ? u10 = double(ncread(nc_windfile, 'u10')) ; size(u10) If it has more than 2 dimensions, u10' is not ...

2 months ago | 0

| accepted

Answered
How to calculate each result of f(x) in the nested for loop?
This is correct, but not useful: j = sqrt(-1); i and j are defined as imaginary units as default already. But you see the ambi...

2 months ago | 0

Load more