Answered
Hi all , i am confuse about how to take a city name into a variable through "input" command . Here i want to take London city name .please correct this code .Error using input Undefined function or variable 'London'.
The great thing about MATLAB is the documentation. It means that we do not need to guess how to use MATLAB. You should read the ...

10 years ago | 0

| accepted

Answered
take part of cell depend on vector
As you were already told in your last question, this is not a good idea: naming variables dynamically will make your code slow, ...

10 years ago | 1

| accepted

Answered
proper way of reading data from text file
Here is one easy way to get all of that data into one matrix, using |fileread| and |sscanf|: >> str = fileread('data.tx...

10 years ago | 1

| accepted

Answered
workspace & LOOP FOR
_"Avez vous une idée ?"_ yes: *don't do this*. Read this to know why: <https://www.mathworks.com/matlabcentral/answers/304...

10 years ago | 1

| accepted

Answered
compare between vector and cell
A much simpler solution: >> a = {[1,9,79,3],[2,29,16,7,3],3,[4,74,3],[5,73,79,3],[6,56,3],[7,3]}; >> b = [79,3,74,10]; ...

10 years ago | 1

Answered
binary to decimal when binary with radix point
This is easy to do yourself: >> str = '11000101.101'; >> idx = str~='.'; >> vec = 1:sum(idx); >> pwr = sum(str(idx...

10 years ago | 0

Answered
find the most similar word from a set of words
You could use the <https://en.wikipedia.org/wiki/Edit_distance edit distance> as a measure of similarity: >> C = {'live','ev...

10 years ago | 4

Answered
How can I pad zeros to each column of a matrix?
Here are two easy ways to add zeros onto a matrix: >> mat = [1,2,3;4,5,6] mat = 1 2 3 4 5 6 >> [m...

10 years ago | 0

| accepted

Answered
Using regexp to extract labels
There is no need to be so specific about the format of the data field. It would be enough to identify the 'Label:' and anything ...

10 years ago | 0

| accepted

Answered
How can I create a not-equally-spaced sequence of numbers in MATLAB?
>> floor(24:32.5:511+1) ans = 24 56 89 121 154 186 219 251 284 316 349 381 414 446 479 5...

10 years ago | 2

Answered
How to continuously update an existing plot?
Use <https://www.mathworks.com/help/matlab/creating_plots/graphics-objects.html graphics handles>. Instead of creating lots o...

10 years ago | 1

| accepted

Answered
Inserting one character many times into a string
You can simply use <https://www.mathworks.com/help/matlab/ref/strrep.html |strrep|>: >> S = 'Apples,Oranges,January,Februar...

10 years ago | 0

| accepted

Answered
line doesnt appear on my graph
There is no point in the ugly loop when a fully <https://www.mathworks.com/help/matlab/matlab_prog/vectorization.html vectorized...

10 years ago | 0

Answered
Creatig a matrix from variables in workspace
The best solution is to _never use numbered variables_. As everyone with experience will tell you, <http://www.mathworks.com/...

10 years ago | 1

Answered
How to copy each row of a vector according to the number in another vector ?
In one line: >> B = [1,2;5,6;5,6;7,8;7,8]; >> Q = [1;0;2;2;0]; >> cell2mat(cellfun(@(b,q)repmat(b,q,1),num2cell(B,2),...

10 years ago | 1

Answered
Code lines of functions - ode45
Try it yourself: open ode45 If this command opens an Mfile with code then you can read that code (do NOT edit it and over...

10 years ago | 1

| accepted

Answered
How to identify array elements that occur more than once ?
>> U = unique(D); >> U(1<histc(D,unique(D))) ans = 3 7

10 years ago | 1

Answered
Finding Indices of Cells Containing Certain Text in Mixed Arrays (Both Numbers and Strings)
Untested, but something like this should work: [NUMx,STRx,RAWx]=xlsread('Inputfile.xlsx') find(cellfun(@(x)isnumeric(x)&&x...

10 years ago | 0

| accepted

Answered
how to remove (.) from strings in matlab
Use <https://www.mathworks.com/help/matlab/ref/strrep.html |strrep|>, which is designed to perform the task that you want: ...

10 years ago | 2

| accepted

Answered
How can I make a 3D plot with lines, not surfaces? (See image)
To plot lines use <https://www.mathworks.com/help/matlab/ref/plot3.html |plot3|>: >> X = [0,1,2;0,1,2;0,1,2;0,1,2]; >> Y...

10 years ago | 0

Answered
Error using cellfun: Input #3 expected to be a cell array, was char instead.
Spelling mistake: 'UniformOuput' should be 'UniformOutput' Read the error message again: it clearly states the the...

10 years ago | 1

Answered
Plot doesn't show in figure
The plot does not show anything because you are not actually plotting anything. You need to use indexing in the loop to store th...

10 years ago | 0

Answered
Extracting number from a string
Here are two very simple methods: >> str = 'M1'; >> sscanf(str,'M%d') ans = 1 >> str(2)-'0' ans = 1

10 years ago | 6

| accepted

Answered
Can't figure out this debugging error
Read the error message again. It tells you clearly that either all functions in the file need to use |end|, or none of them. You...

10 years ago | 0

| accepted

Answered
How do I transform this handle into a string?
You do not need to _"Get rid of the '@' symbol"_. That symbol creates a <https://www.mathworks.com/help/matlab/function-handles....

10 years ago | 0

| accepted

Answered
Printing cell arrays issue
*Do not use |path| as a variable name*. As you have already been told, this is the name of a very important inbuilt function <ht...

10 years ago | 1

| accepted

Answered
values of matrix change on each iteration
Just use <https://www.mathworks.com/help/matlab/ref/randi.html |randi|>: for k = 1:100 A = randi([1,3],7,3) end

10 years ago | 0

| accepted

Answered
Flip size of cells inside cell aray
for k = 1:numel(duration) duration{k} = duration{k}.'; end

10 years ago | 0

| accepted

Answered
I want to traverse an array in an 'inverse s' order and store in a single row array is there any matlab function or code for this?eg[1 2 3; 3 4 5; 4 5 1] becomes [1,2,3,5,4,3,4,5,1]
>> A = [1,2,3;3,4,5;4,5,1]; >> A(2:2:end,:) = A(2:2:end,end:-1:1); >> reshape(A',1,[]) ans = 1 2 3 5 4 ...

10 years ago | 0

| accepted

Answered
Subscript indices error, excel, textscan.
MATLAB indexing starts at one, not zero, but you have written this (watch the |x|): x=0; while j<1000 if idx(x) < ...

10 years ago | 0

| accepted

Load more