Answered
Saving .png images in directory
The counterpart to imread is imwrite, not save. save as you've used it saves all the workspace variable in a mat file (irrespect...

7 years ago | 0

| accepted

Answered
choose a number from a matrix based on probability parameter
Either are overly complicated: if rand > 0.8 do_ProcedureA; else do_ProcedureB; end

7 years ago | 0

| accepted

Answered
Write metadata to jpg file
Yes, you can embed metada in jpeg files. Typically it's encoded as exif. However, there's no function in matlab to do that. ma...

7 years ago | 1

| accepted

Answered
How can i assign a matrix to another matrix with different number of rows and columns
You're asking for the kronecker tensor product, obtained with kron in matlab: >> kron([1 0 0; 0 0 1; 0 1 0], [2 3; 2 2]) ans =...

7 years ago | 0

Answered
Merging specific Excel files according to a string in the filename
folder = '\\fscbeng\Project\Lab_Measurements\Results\20190424-1'; filelist = dir(fullfile(folder, '*.csv')); filedata = cell...

7 years ago | 0

| accepted

Answered
Erosion/Dilation of images with Alpha channel
The image processing toolbox does not have any notion of transparency, so the answer is simple: alpha has no impact on any morph...

7 years ago | 1

Answered
I'm trying to fill a cell array with different conditions.
It's unclear what form your data is in. If it's in excel use readtable to import it into matlab. demodata = table([1; 1; 1; 2; ...

7 years ago | 0

Answered
Replace Nan by a number in a cell array
Your question is not very unclear. You show a loop filling (part) of a cell array with ... something unspecified. Presumably, th...

7 years ago | 0

| accepted

Answered
append new rows in the middle of an excel file's sheet
Probably the easiest way to find out the code you need to use is to record a macro in excel while you do the insertion and fix t...

7 years ago | 1

| accepted

Answered
How to find breakup length?
I assume you know the scale of your image otherwise the whole exercise is a bit pointless... The nozzle orifice is not visible ...

7 years ago | 1

| accepted

Answered
'Out of memory' error for element-wise vector product '.*'
Prior to R2016b, matlab worked the way you expected. The shape of the vectors did not matter. In R2016b, mathworks changed the b...

7 years ago | 0

| accepted

Answered
Is there a way to record the usage of functions in a matlab program?
Bearing in mind that as Adam says matlab has no concept of a user and also bearing in mind that collecting user names may fall u...

7 years ago | 1

Answered
Logicals with empty double column vectors
c=find(cellfun(@isempty,a)); a(c,:)=[]; The second line implies that a is 2D. Yet, find as used will return linear indices, so...

7 years ago | 0

| accepted

Answered
Can a string be converted into a function call inside a GUI?
"This does not" str2func(fname) Yes, because str2func doesn't invoke the function, it just returns a handle to the function. Y...

7 years ago | 2

Answered
How to select a random number from a matrix
Use randi to select an index at random: A(randi(numel(A)))

7 years ago | 4

Answered
sizing microgrid using for and if statement
It sounds like you have several problems. The first one being the data generation which you currently do with some form of digit...

7 years ago | 1

| accepted

Answered
how to find all possible path between 2 nodes
Here is the code I posted as a comment to Walter's answer, it requires this function from my answer to another question: %g: a ...

7 years ago | 2

| accepted

Answered
Filling missing values of selected columns of a table with previous values
Star's answer works (please don't delete it!) or you can use: Data(:, {'English', 'Science'}) = fillmissing(Data(:, {'English',...

7 years ago | 2

Answered
Problem with logical indexing
freezing is the name of the function. So when you write freezing inside the function, you're telling it to call itself. Of cours...

7 years ago | 2

| accepted

Answered
Check common elements in two vectors and remove them from both the vectors leaving any duplicate. (Example Inside)
"Thank you, intersect did it" intersect on its own will not do it since all set membership functions (setdiff, setxor, union, i...

7 years ago | 0

Answered
Reading data from csv files
%your original code, slightly modified csvfiles = dir('*.csv'); filescontent = cell(numel(csvfiles), 1); for i = 1:numel(csv...

7 years ago | 0

| accepted

Answered
How can i change the values of entire rows or columns using values of other rows or columns in a 3D matrix with for loops;
This works with your example: c = cat(3, [2 0 3 0 1; 0 0 0 0 0; 1 0 3 0 2], [3 0 1 0 2; 0 0 0 0 0; 5 0 3 0 8], [1 0 5 0 9;0 0 0...

7 years ago | 0

Answered
Calculate minimum distance between points in a mesh
Here is one way: points = rand(20, 2); %demo data distance = hypot(points(:, 1) - points(:, 1).', points(:, 2) - points(:,...

7 years ago | 0

Answered
How to export a struct to flat file?
fnames = fieldnames(MCI1); c = struct2cell(MCI1)'; heights = cellfun(@numel, c(:, 4)); t = [cell2table(repelem(c(:, [1 2]), h...

7 years ago | 1

| accepted

Answered
i need to convert a folder of 200 .jpg images to .mat (to create 200 separate .mat files). i know there should be an easy matlab for loop to do this but I need help (newbie). thanks!
folder = 'C:\somewhere\somefolder'; filelist = dir(fullfile(folder, '*.jpg')); %get list of all jpg files in the folder matna...

7 years ago | 2

Answered
function variable undefined. How to declare it ? Says Totalcost not defined
What you have written is a script (name unknown) with a local function called Budgetcompare. A function (local or normal) never ...

7 years ago | 0

Answered
Extract column data based on date
Most likely (for lack of a sample file to test code with): wavedata = readtimetable('C:\somewhere\somefile.csv'); %requires R2...

7 years ago | 0

Answered
Conversion of multidimensional cell into string
Taking a guess here, since you're still not using matlab syntax for your example: C = {2, [0,1,0]; 73, [0,1,1,1]; ...

7 years ago | 0

Answered
How to order a matrix?
how can i do that? Use uniquetol instead of unique. Note that the 'rows' option of unique is 'ByRows', true with uniquetol [~,...

7 years ago | 0

Answered
Correct error in logical indexing
You use length on a matrix. If your matrix happens to only have one row, your code will error since length will return the numbe...

7 years ago | 3

Load more