Answered
Export to .csv with specific notation
[fid,msg] = fopen('name.csv','wt'); assert(fid>=3,msg) fprintf(fid,'{%.3f,%.3f},\n',A.'); fclose(fid); The file it...

8 years ago | 1

| accepted

Answered
The plot command isn't working for the MATLAB as it is showing it as an error with "Attempt to execute SCRIPT plot as a function".
You have some script shadowing the |plot| function. Find out what script: which plot -all

8 years ago | 1

| accepted

Answered
how to save an array of letters in matlab ?
_"but for some reason instead of getting an array of letters I get an array of numbers"_ Yes, because you specified |array| t...

8 years ago | 0

| accepted

Answered
Generic Anonymous Function Setup
Learn how to write <https://www.mathworks.com/help/matlab/matlab_prog/vectorization.html vectorized code>, then your task is eas...

8 years ago | 0

| accepted

Answered
convert a txt file to a structure
*Method one: <https://www.mathworks.com/help/matlab/ref/cell2struct.html |cell2struct|>:* cell2struct(num2cell(PVRead{2}),P...

8 years ago | 0

| accepted

Answered
How can I create a matrix of linestyles for plot to loop through?
You were almost there, you just need to use the right kind of <https://www.mathworks.com/help/matlab/matlab_prog/access-data-in-...

8 years ago | 0

| accepted

Answered
How to clear only a part of the plot
This will actually delete the line objects from the axes: ah = plot(...); hold on bh = plot(...); ch = plot(...); ...

8 years ago | 3

Answered
How can I export cell to double variable
Rather than magically creating the variables, a simple and efficient alternative is to create a structure from that cell array: ...

8 years ago | 1

Answered
read 1000's .csv files and concatenate them
N = 1760; C = cell(1,N); for k = 1:N F = sprintf('d0.%d.csv',k-1); C{k} = csvread(F,2); end and afte...

8 years ago | 0

| accepted

Answered
put a function inside loop and save as matrix and csv
Simpler and much more efficient than ugly dynamic variable names: S = dir('Bus_Data*.csv'); N = numel(S); R = cell(1,...

8 years ago | 0

| accepted

Answered
For Loop read different data from workspace
Do NOT use |ans| as a variable name. I use |S| in my code below: out = cell(1,10); for k = 1:10 fld = sprintf('My...

8 years ago | 0

Answered
Split array according to one column values
Your life would be much easier if you stored _numeric_ data in _numeric_ arrays: >> A = [10 1 1; 10 1 2; 10 1 1; 10 2 1; 10...

8 years ago | 2

Answered
Convert structure to a vector?
>> G = {'A','B'}; >> V = [1,2]; % or [A,B] >> [~,idx] = ismember(G,{'A','B'}); >> V(idx) ans = 1 2 Or u...

8 years ago | 0

Answered
Cell array strings storage
With older MATLAB versions the rule was very simple: all arrays were displayed _without_ the _outermost_ array brackets/parenthe...

8 years ago | 1

Answered
Sigma Multiple Matrix for Loop
_"is this right?"_ No. The formula is for basic matrix multiplication, so you can just use the inbuilt and very efficient ...

8 years ago | 0

| accepted

Answered
How to save structue generated in a loop?
Just use indexing: for k = ... S(k) = st end and you will get all of your data in one <https://www.mathworks.c...

8 years ago | 0

Answered
How can I map to each vector entry a number telling its occurence so far?
No third-party functions required, four lines of code: >> vec = 5+[1,2,3,4,2,5,2,3]; >> [uni,~,idx] = unique(vec); >>...

8 years ago | 1

| accepted

Answered
Error using frame2im Invalid movie: expected a structure
As its documentation clearly states, the <https://www.mathworks.com/help/matlab/ref/videoreader.readframe.html |readframe|> func...

8 years ago | 0

Answered
Subtraction of matrix rows
diff(A) diff(A,1,1)

8 years ago | 0

Answered
I use cell array of strings to populate popup menu but strings in the popup menu are returned as scientific notation!
It seems that |ListNoSG| contains numeric scalars. Convert them to character: tmp = cellfun(@int2str,ListNoSG,'uni',0); ...

8 years ago | 0

| accepted

Answered
How to save a row of cell array in structure?
Initialize a scalar structure like this: hi = struct(); The error is because you define |hi| as numeric, but then try to...

8 years ago | 0

Answered
Plot Using Variable Name From For Loop
Here is an outline of one simple way to do this: N = 20; db = cell(1,N); td = cell(1,N); for k = 0:N db{k} ...

8 years ago | 0

| accepted

Answered
What is M(I) where M is a real matrix and I is a matrix of indices.
_"The only thing I can think of is to convert to linear indices. Is that the only way?"_ Yes. Use |sub2ind|.

8 years ago | 0

| accepted

Answered
How do I select a file in one subfolder but save to another.
You could use a regular expression to get the filepath up to where you want: C = regexp(FilePath,'.*Sample1','once','match'...

8 years ago | 0

Answered
How to store input and output arguments in a matrix form so that it can be exported to EXCEL?
This is not valid MATLAB syntax: A(2,2) = '%.4f', R; You will need to use curly braces to allocate to the cell array, an...

8 years ago | 0

| accepted

Answered
How can i make this code snippet a function?
for k = 1:numel(full_val) plot(full_val(k).val(1,:)) hold on end You could also use a loop when |load|-ing...

8 years ago | 0

| accepted

Answered
Iterate over vector from result of a for loop
This is MATLAB so there is no need to rely on low-level loops. For MATLAB versions R2016b and later: capacity - 480*(1:5).'...

8 years ago | 3

| accepted

Answered
Difference Between ismember() and contains()
They are not the same at all, they do quite different things! * <https://www.mathworks.com/help/matlab/ref/ismember.html |ism...

8 years ago | 8

| accepted

Answered
How do I make a function which is not a GUI callback uninterruptible?
Here is an idea (untested, but it might work): define a simple GUI object (e.g. a |uicontrol| push button) that calls the uninte...

8 years ago | 0

Load more