Answered
How to compare variable with a vector?
>> vec =[4160,13300,16800,30700,41000,63700,6050]; >> val = 13311; >> [~,idx] = min(abs(vec-val)); >> vec(idx) ans...

8 years ago | 0

Answered
Error: File: Expression or statement is incorrect--possibly unbalanced (, {, or [
fprintf(fid3,'%d \t %f \t %f \t %s \n', person, faceweight, fpweight,str1); or fprintf(fid3,'%d \t %f \t %f \t %s \n',...

8 years ago | 0

| accepted

Answered
Structs fields indexing issue
If all of the child structures have exactly the same fields then you would be much better off using a <https://www.mathworks.com...

8 years ago | 0

| accepted

Answered
How to set just RowNames in a Matrix
_"It creates a table 3x1, and not a table 3x3 that was my goal"_ So use the correct function to create it: <https://www.mathw...

8 years ago | 2

Answered
check the index of cell which were removed
Using logical indices: B_remove = cellfun('isempty',A) B_keep = ~B_remove If you really want the subscript indices th...

8 years ago | 0

| accepted

Answered
Automatic double to complex double ?
You can't. There is no way to only store imaginary values for _some_ elements of a floating point numeric array. You can test...

8 years ago | 0

| accepted

Answered
Replace values in matrix by first non-zero value in previous row
>> M = [3;0;0;4;0;5]; >> idx = M~=0; >> tmp = M(idx); >> tmp(cumsum(idx)) ans = 3 3 3 4 ...

8 years ago | 2

| accepted

Answered
Using 'whos' to get a list of variables that I can then analyse
Avoid this situation. You do not tell us _how_ you get these variables into your workspace, but believe me it is easy to avoi...

8 years ago | 2

Answered
Move all NaN to end of matrix columns.
Without sorting the other values: >> A(:,:,1) = [8 8; 9 9; 8 8; 9 9; NaN NaN; 1 1; 2 2; 3 3; 5 5; 7 7]; >> A(:,:,2) = [2...

8 years ago | 1

| accepted

Answered
How to shadow the built-in find function
I think it would be best to use a different name: * KISS: don't make this more complex than it needs to be: defining it as it...

8 years ago | 1

| accepted

Answered
how to find Place on non zero values in matrix?
>> A = [0,0,0,1,0,0,1,1,0;0,0,1,0,0,0,0,0,1;0,0,0,0,1,0,0,0,0]; >> [R,C] = find(A); >> X = accumarray(R,C,[],@(v){v.'});...

8 years ago | 0

| accepted

Answered
How can I call all element from cell class ?
unique([A{:}].','stable')

8 years ago | 0

| accepted

Answered
Averaging rows with same name
_" my question now is, that is better than a loop ? and if yes, why ?"_ Loops (with preallocated arrays) are a perfectly acce...

8 years ago | 1

Answered
how to store data in matrix form total up all the value of Z
Apart from |z| all of the other variables appear to be scalar, so you should be able to vectorize it: out = X*(log(2*z(1,:)...

8 years ago | 0

| accepted

Answered
remove cell array content with condition: length of element in cell smaller than specific value
A(cellfun('length',A)<3) = [] or if you want to leave the original variable unchanged: B = A(cellfun('length',A)>=3);

8 years ago | 0

| accepted

Answered
Low level IO: How to remove trailing new line at the very end?
Do these things: * use |fopen| with the text option, e.g. |'rt'|. * use |fgetl| isntead of |fgets|. * use |feof| instead of...

8 years ago | 1

| accepted

Answered
This is my question.
If the order of the other elements is not important then just use |sort|. If you want the rest of the elements to keep the same ...

8 years ago | 0

Answered
How can I save vector values that changes its size each iteration?
N = 10; B = nan(N,N); for k = 1:N B(k,1:k) = 1:k; end Or use a cell array.

8 years ago | 1

| accepted

Answered
I assigned 2 element vectors to a matrix but something is not working.
x = Nodes{1,1}(1) y = Nodes{1,1}(2) Although you would be better off putting your numeric data into one/two numeric arra...

8 years ago | 0

| accepted

Answered
what is the index variable
|k| is the loop index variable in the code that you showed. The loop index variable is always defined after |for|: for ??? ...

8 years ago | 0

Answered
how to plot points in a loop?
figure() hold on for ... ... plot(a,b,'*') end But I would not recommend doing this: the simpler MAT...

8 years ago | 0

Answered
i am having 11*5 cell array. each array with in the cell has size of [1 1500] .
Storing your data in one simple numeric array would make processing your data simpler, so that is the first step: M = vertc...

8 years ago | 0

| accepted

Answered
from cell array to number
str2double(C)

8 years ago | 1

| accepted

Answered
How can I find ALL the functions/scripts potentially used in a script?
<https://www.mathworks.com/help/matlab/matlab_prog/identify-dependencies.html> <https://www.mathworks.com/help/matlab/ref/mat...

8 years ago | 2

| accepted

Answered
Why imwrite doesn't work??
Your image has |double| values on range [0,255], so you need to scale the values to [0,1] or change the class: imwrite(uint...

8 years ago | 1

Answered
while using for loop in following function some blank cells are come into output matrix like [ ] [ ] [ ]. I dont understand where i wrong in for loop
You use the variable |p| as an index into both the training and test data cell arrays, so when you have incremented the training...

8 years ago | 1

| accepted

Answered
Import files in a folder containing certain extension
P = 'absolute/relative path to where the files are saved'; S = dir(fullfile(P,'*.5.csv')); S = natsortfiles(S); % optional, se...

9 years ago | 0

Answered
How do I print out a product of 2 requested numbers
function print_product() x = str2double(input('Give me a number: ', 's')); y = str2double(input('Give me another number...

9 years ago | 0

| accepted

Answered
Inserting zeroes where values of another matrix are missing
T = [1,2,3,1,2,3,1,2,3]; T1 = [1,2,1,2,3,2,3]; B1 = [2,4,3,1,2,6,7]; idx = bsxfun(@eq,T1(:).',T(:)); idy = false(...

9 years ago | 1

| accepted

Answered
How to write a sequence of dicom file ?
IMin0 = reshape(IMin0,512,512,234); for k = 1:size(IMin0,3) fnm = sprintf('file_%d.dcm',k); dicomwrite(IMin0(...

9 years ago | 0

| accepted

Load more