Answered
remove nan from table with string and numeric type
C = { 'HRD_0085' [ 190.7900] 'HRD_0086' [ 11.6500] 'WAT_0087' [ NaN] }; C(~cellfu...

9 years ago | 0

| accepted

Answered
how to concat the cell matrix (containing text) to numeric array?
Perhaps simply merging the data into one cell array: >> A = [0.8; 1]; >> rr = {'True', 'False'}; >> C = num2cell(A); ...

9 years ago | 1

| accepted

Answered
How to 'stretch' a matrix using a loop?
R2015a or later: use <https://www.mathworks.com/help/matlab/ref/repelem.html |repelem|>: repelem(M,14,14) Earlier versio...

9 years ago | 1

| accepted

Answered
How do I extract data from a .dat file contain multiple tables?
This reads entire header into cell array |hdr|, all of the data tables into a cell array |out|, and the corresponding RPM into a...

9 years ago | 2

| accepted

Answered
How to make a sequential folder?
Making a few guesses here, but it appears that you are trying to do something like this (obviously untested): folder = 'C:\...

9 years ago | 0

Answered
I am trying to run the program below and i am getting the error "Index exceeds matrix dimensions" for the line power = (0.5 .* pi .* density .* R^2 .* u .* Cp(ind2)); Can some one please please help me.
When that line is evaluated the value of |ind2| is 1172, but there are only 1171 elements in |Cp|. You have a too high a value b...

9 years ago | 1

| accepted

Answered
Ques:Regardless of input, output the string 'yes'.
Your function does not actually _output_ anything: your function _prints_ some text to the command window, but _printing_ text u...

9 years ago | 0

Answered
How can I replace elements in a vector if a certain condition is true?
*Method one: indexing*. This brute-force method is easy to understand and implement, but it is not very generalized (changing it...

9 years ago | 1

Answered
Remove duplicates as well as the original values?
One easy way would be to use <https://www.mathworks.com/help/matlab/ref/histc.html |histc|>: >> [X,Y] = histc(M(:,1),unique...

9 years ago | 0

| accepted

Answered
How can I keep the first number in a series of positive numbers & replace all others with 0?
<https://www.mathworks.com/help/matlab/ref/diff.html |diff|> and some logical comparisons will solve this: >> V = [1,2,3,-1...

9 years ago | 1

| accepted

Answered
How do i print file names that exist in certain folder in matlab table with out file extension?
Use <https://www.mathworks.com/help/matlab/ref/fileparts.html |fileparts|> to get the filename without the extensions. Something...

9 years ago | 1

| accepted

Answered
I have a cell array containing file names with .mat extension. I want to create another cell array with the filenames only after dropping the extensions. kindly help.
The correct tool already exists: fileparts. Where C is your cell array, the names will be in N: [P,N,E] = cellfun(@fileparts,C,...

9 years ago | 2

| accepted

Answered
Display multiple output (integers and string) using fprintf
>> A = 23; >> B = 'Celsius'; >> C = 296.15; >> D = 'Kelvin'; >> str = sprintf('%.15g %s is equal to %.15g %s',A,B,...

9 years ago | 0

| accepted

Answered
Decrease precision of decimal no value saved for a variable.
You have overstepped the limits of what <https://www.mathworks.com/help/matlab/ref/double.html |double|> <https://www.mathworks....

9 years ago | 0

| accepted

Answered
Store a variable from prompt user input
I changed it so that there is a limit to how many attempts can be made, and also that the output is always defined: functio...

9 years ago | 1

| accepted

Answered
Extract email addresses from text
Take MATLAB's own Regular Expressions example: email = '[a-z_]+@[a-z]+\.(com|net)'; and adapt it to allow any domain, or whate...

9 years ago | 0

Answered
Using textscan to skip specific rows
Second attempt: this time we will first convert the awful file format into a standard CSV format with one header line, no empty ...

9 years ago | 0

| accepted

Answered
y = feval(symengine,'RGB::colorName','[1,0.7,0.33]') i want to pass rgb values to this function to get the name of the color.
A easy alternative would be to *download* my FEX submission |colornames|: <https://www.mathworks.com/matlabcentral/fileexchan...

9 years ago | 0

Answered
Extracting individual file data from uigetfile multiselect
To access the data in a cell array you need to use curly braces, not parentheses: filename{1} because this filename...

9 years ago | 1

| accepted

Answered
Using textscan to skip specific rows
One approach is to play with the |EndOfLine| character (a little hacky, I know): opt = {'MultipleDelimsAsOne',true, 'EndOfL...

9 years ago | 1

Answered
Using save() and -ascii format to limit output numbers to 2 decimals
*Method one: <https://www.mathworks.com/help/matlab/ref/fprintf.html |fprintf|>:* fnm = fullfile(PathName,filename); fid...

9 years ago | 0

| accepted

Answered
[Help me, please] How to find 3 point maximum matrix in matlab ?
>> Z = sortrows(A,-1); >> X = Z(1:3,1) X = 9 7 5 >> Y = Z(1:3,2) Y = 6 1 2

9 years ago | 1

Answered
How to select an array without element i
>> a = [1;4;7;11]; >> n = numel(a); >> M = reshape(a(1+mod(setdiff(1:n*n,1:n+1:n*n)-1,n)),n-1,n) M = 4 1 ...

9 years ago | 0

| accepted

Answered
Using horzcat for string and regular matrix?
>> A = {'ai','ba';'cr','dk'}; >> B = [1;2]; >> C = [num2cell(B),A]

9 years ago | 0

| accepted

Answered
Need Help in vectors combinations
Use <https://www.mathworks.com/help/matlab/ref/meshgrid.html |meshgrid|> and <https://www.mathworks.com/help/matlab/ref/vertcat....

9 years ago | 0

| accepted

Answered
How to get an X value between a specific set of Y values?
Assuming that X and Y are variables in their own right: max(Y(X>=6 & X<=16))

9 years ago | 1

| accepted

Answered
How to remove elements from a matrix?
Use <https://www.mathworks.com/help/matlab/ref/randperm.html |randperm|> (it has no repeats): nkeep = 4; str = 'thestrin...

9 years ago | 2

Answered
how to extrapolate with given data? (maybe very simple)
>> interp1(x,y,[6,7],'linear','extrap') ans = 13 14 And remember that extrapolated values are always to be <http...

9 years ago | 9

| accepted

Answered
How can I add values from a second column if the value in the first column is the same?
Use <https://www.mathworks.com/help/matlab/ref/accumarray.html |accumarray|>: >> accumarray(M(:,1),M(:,2),[],@sum) ans =...

9 years ago | 1

Answered
WHAT TO GRAPH USING ELEMENTWISE MULTIPLCATION
It works perfectly for me, exactly like <https://www.mathworks.com/matlabcentral/answers/343257-x-linspace-10-10-51-y-linspace-0...

9 years ago | 0

| accepted

Load more