Answered
How do I load data files starting wih strings?
>> str = fileread('temp.txt'); >> str = regexprep(str,'\s+',''); >> mat = reshape(sscanf(str,'x%fy%f'),2,[]).' mat = 0 ...

7 years ago | 1

Answered
how to sum of each row according to values values in given function
Simpler: >> X = [1,0,1,0,0,1;1,0,0,1,0,1;1,0,0,0,1,1;1,0,0,1,1,1;0,1,1,0,0,1] X = 1 0 1 0 0 1 1 0 0 ...

7 years ago | 2

Answered
get file name from other directory
The problem is on this line: fullFileName= fullfile(folder,fullFileName.name) % ^^^^^^^^^^^^^^^^^ ...

7 years ago | 0

| accepted

Answered
Replace a block of strings in a text file with another string
One way is to use a regular expression, which even lets you keep the EOL characters exactly the same: rgx = 'ADDRESS(\s+)[^/]+/...

7 years ago | 0

Answered
Help with making a function.
function y = myfun(x) y = sqrt(x); if y~=fix(y) y = floor(x/3); end end

7 years ago | 0

Answered
how to round off a number to the nearest multiple of 25?
>> a = 254; >> 25*ceil(a/25) ans = 275

7 years ago | 1

Answered
Given an element of a matrix, How to print all the arrays containing that element?
This should get you started, adjust as required: >> A = magic(4) A = 16 2 3 13 5 11 10 8 9 7 ...

7 years ago | 0

Answered
Reading in text file using textscan.
textscan imports file data into one cell array, the contents of which are one or more arrays (numeric, cell, datetime, etc), whe...

7 years ago | 0

| accepted

Answered
How to plot a function, instead of just values?
>> X = linspace(-8,8,500); >> Y = fresnelS(@(x) sin(x.^2), X, 50); >> plot(X,Y)

7 years ago | 0

| accepted

Answered
Append values from textscan into cell array literately in a loop
>> str = fileread('test.txt'); >> reshape(sscanf(str,'%*[^=]=%f'),3,[]).' ans = 20 120 65 21 121 63 1...

7 years ago | 0

| accepted

Answered
moving files from one folder to an other
All files: A = '/media/my_name/data/*.mat' B = '/media/my_name/moved_files' movefile(A,B) Tenth file: A = '/media/my_name/d...

7 years ago | 1

| accepted

Answered
Replace some elements in a Matrices with brief code.
>> a = [5,6,7,9,1,2,5,6,3,8,9,0]; >> x = [1,3,6,2;2,4,1,9;2,3,5,6]; >> b = a(x); >> y = b>=6; >> b(y) = x(y) b = 5 3 ...

7 years ago | 1

| accepted

Answered
Colormap for plot function
"I found out that colormap is not originally supported for plot function." The axes/figure colormap is used for patches and ima...

7 years ago | 1

| accepted

Answered
Simultaneously display image on two monitors
Try: imh(1) = imshow(...., 'Visible','off'); imh(2) = imshow(...., 'Visible','off'); then later: set(imh, 'Visible','on') E...

7 years ago | 0

Answered
summing element is a cell
sum(cat(3,c{:}),3)

7 years ago | 0

Answered
How can I get matlab to execute one or both parts of a code depending on whether a variable exists?
Avoid checking if variables exist or not (such introspective programming is a path to slow, complex, spaghetti code which is dif...

7 years ago | 0

| accepted

Answered
index of an array multiple same element
>> a = [7,8,8,2,5,6,6,2,6,8]; >> U = unique(a) % the order is the same as C. U = 2 5 6 7 8 >> [R,C] = find(U(:)==...

7 years ago | 1

Answered
Reorganizing cell array according to column
>> data data = [1x33 char] [ 0] [11.7701] [17.9263] [2] [2] [1x33 char] [ 5.5659] [ 0...

7 years ago | 0

| accepted

Answered
Convert a text file to a matrix
fun = @(s)regexp(s,'\t','split'); [fid,msg] = fopen('DML001_Carotid_Pressure_6.txt','rt'); assert(fid>=3,msg) hdr = fun(fgetl...

7 years ago | 0

| accepted

Answered
Contributors metainfo: reputation and more
Congratulations to John D'Errico for reaching 10,000! And with only 1520 accepted answers too... impressive.

7 years ago | 6

Answered
Trying to understand pixel value.
"What am I missing here?" You have ignored the fact that RGB images have three color channels, which in order to generate your ...

7 years ago | 0

| accepted

Answered
Uitable data converison for user precision
Your data is numeric, not a cell array. You already answered your own question when you wrote "I have a uitable with double val...

7 years ago | 0

| accepted

Answered
Creating possible addition of a number
Download John D'Errico's excellent partitions: https://www.mathworks.com/matlabcentral/fileexchange/12009-partitions-of-an-inte...

7 years ago | 2

Answered
Fixing a plot with error message: "Function behaves unexpectedly on array inputs...properly vectorize your function"
"Can someone please explain to me what this error message means? " It means that your function returns a differently-sized outp...

7 years ago | 8

| accepted

Answered
How to set slider's minimum value other than zero in GUI?
Read the error message: Warning: 'slider' control cannot have a 'Value' outside of 'Min'-'Max' range So you just need to also ...

7 years ago | 0

Answered
Plotting In Matlab with three columns?
M = csvread('Query_version.csv',1,0); U = unique(M(:,1)); N = numel(U); C = cell(2,N); for k = 1:numel(U) X = M(:,1)==U...

7 years ago | 1

| accepted

Answered
Single representation of same values in a Matrix
>> M = [5,5,3,3,4,4;5,5,3,3,4,4;2,2,1,1,5,5] M = 5 5 3 3 4 4 5 5 3 3 4 4 ...

7 years ago | 0

| accepted

Answered
generating sequence of given numbers
>> A = [0,1,2]; >> M = perms(A) M = 2 1 0 2 0 1 1 2 0 1 0 2 0 ...

7 years ago | 1

| accepted

Answered
how to write metadata information to a jpg file
https://www.mathworks.com/matlabcentral/answers/152559-writing-exif-data-to-jpg https://www.mathworks.com/matlabcentral/fileexc...

7 years ago | 1

| accepted

Answered
How to pick numbers in text file in matrix format
Simple and efficient: opt = {'HeaderLines',1, 'CollectOutput',true, 'EndOfLine','>', 'WhiteSpace',' \n\r\t'}; fmt = [repmat('%...

7 years ago | 0

| accepted

Load more