Answered
Select part of a string
A string array treats each string as being atomic, whereas you need to be able to access each character as atomic. Use |cellstr|...

9 years ago | 1

| accepted

Answered
How to copy a line from multiple files
Assuming that that line is uniquely identified by the word 'total' and the line always has the same format, then you can use fil...

9 years ago | 0

| accepted

Answered
Could someone please explain...
If you are using R2013A or newer then use <https://www.mathworks.com/help/symbolic/atan2.html |atan2|> instead: >> syms x ...

9 years ago | 1

| accepted

Answered
How to format in a CSV file
Loops are not required. To create a comma-separated file do something like this: % fake data: NameofTypeMasonry = {'a...

9 years ago | 0

Answered
Can someone please help me know what's wrong with my code? because it doesn't show the right graph !
This function: function y = discontinuity(x,a,n) y = max(0,x-a).^n; end and this script: x = 0:0.5:360; y ...

9 years ago | 0

| accepted

Answered
How to count a specific string in a cell array?
>> c = {'car' , 'tree' , 'car' , 'bag' , 'horse' , 'car' , 'tree'}; >> nnz(strcmp(c,'water')) ans = 0 >> nnz(...

9 years ago | 10

Answered
Writing to a CSV file
Possibly you just need to use <https://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-cell-array.html cell array ind...

9 years ago | 0

| accepted

Answered
How to create an array which has an incremental value every 24 elements
With MATLAB 2015A or newer use <https://www.mathworks.com/help/matlab/ref/repelem.html |repelem|>: vec = repelem(1:365,24) ...

9 years ago | 0

| accepted

Answered
saving as of a figure with current folder name
Using <https://www.mathworks.com/help/matlab/ref/fileparts.html |fileparts|> makes this task very simple: >> str = pwd; ...

9 years ago | 2

Answered
How do I create a function without getting this Error: Function definitions are not permitted in this context?
Only <https://www.mathworks.com/help/matlab/matlab_prog/anonymous-functions.html anonymous functions> may be defined in the comm...

9 years ago | 0

| accepted

Answered
how to use anonymous function with equation without retype the all equation?
>> sol = @(x,y)x^2+3+y^3; >> sol(2,2) ans = 15 exactly as the documentation shows: <https://www.mathworks.com/h...

9 years ago | 1

Answered
How to "smear" a logical mask without looping
I have no idea how fast this is, but it is relatively compact: >> idx = cumsum(cumsum(a,1),1); >> out = 0<idx & idx<=n ...

9 years ago | 1

Answered
Help about 'calling a variable from workspace by using input command'
Do not access lots of variable names like that. It will make your code slow, complicated, and buggy: <https://www.mathworks.c...

9 years ago | 1

Answered
Given a vector containing N integers, write an M-flies to calculate how many elements in this vector are odd and how many are even. example if the given vector is :
>> input_v = [27;43;55;95;42;98;31]; >> fmt = 'The number of %s elements is %d\n'; >> fprintf(fmt,'odd',nnz(mod(input_v,...

9 years ago | 2

| accepted

Answered
how to create the function of following statement in matlab?
Use your favorite internet search engine. The very first result is this: <https://www.mathworks.com/matlabcentral/fileexchang...

9 years ago | 0

Answered
How can we find the non common strings from multiple columns
First lets find the strings that are common to all cell arrays: listA={'India','Iran','Ireland','Israel','Jordan','Kuwait',...

9 years ago | 0

| accepted

Answered
Why Do I Get This Error for This Non-scalar Structure?
<https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.html Comma separated lists> are really very simple. You...

9 years ago | 1

| accepted

Answered
Assigning multiple variables to inputdlg's output string
This is easy using a <https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.html comma-separated list>: p...

9 years ago | 1

Answered
why am I getting imaginary values?
Because you are taking the square root of negative numbers: >> (... (... M*(l*theta2 - gama*l + 2*k1*tan(theta2/2)^2*...

9 years ago | 0

Answered
wolfram alpha operation in matlab
>> fun = @(x)(1+x)/(1-x)-1.08393; >> fzero(fun,0) ans = 0.0402748652785842

9 years ago | 1

Answered
MATLAB 2x2 maximum fill
*Method One: <http://www.mathworks.com/help/images/ref/blockproc.html |blockproc|>:* >> ipt = [128,25,12,26;240,200,15,25;1...

9 years ago | 1

| accepted

Answered
How to Put an Arrays Elements in a Structure?
Here are three ways: A = [1; 1; 0; 0; 0; 0; 1]; C = {'w','b'}; B = struct('C1',C(1+A)); % if the structure does not e...

9 years ago | 0

| accepted

Answered
Error: Unexpected MATLAB expression.
The problem is not your function, but how you are calling it: you forgot the comma: eligible(88,88) ^ you need ...

9 years ago | 2

Answered
colormap using plot3
If you plotting those points as one line, then the answer is no: one line, one color. Some alternatives: * plot multiple l...

9 years ago | 0

Answered
How does 6.022140857*10^23 differ from 6.022140857e+23?
>> fprintf('%.0f\n',av) 602214085699999950000000 >> fprintf('%.0f\n',av_1) 602214085700000020000000 because *|X*B^...

9 years ago | 0

| accepted

Answered
How to calculate the average in structure?
The documentation explains some easy ways to access data in a <https://www.mathworks.com/help/matlab/matlab_prog/access-multiple...

9 years ago | 0

Answered
how to compare 2 or more cell arrays?
After removing the asterisks, space characters, and fixing the first element of C1, this seems to do the job: >> C1 = {'tcca...

9 years ago | 1

| accepted

Answered
How can I find the maximum values of several specific ranges of values in a column?
This is easy with <https://www.mathworks.com/help/matlab/ref/unique.html |unique|> and <https://www.mathworks.com/help/matlab/re...

9 years ago | 0

Answered
How do I add commas to numbers using fprintf?
fprintf cannot do that, but you will find several FEX submissions that can create a string with commas as thousands separators: ...

9 years ago | 3

| accepted

Answered
how to delete NA from specific rows without delete NA included in strings?
Try this instead: if isempty(regexp(l,'\sNA\s','once')) or perhaps (but less robust): if isempty(strfind(l,' NA ')) ...

9 years ago | 1

| accepted

Load more