Answered
loading from *.mat file directly into a structure
Copied from <https://www.mathworks.com/matlabcentral/answers/398961-advise-on-accessing-cell-array-containing-structures>: _"...

8 years ago | 1

| accepted

Answered
how to interchange the elements of a vector/matrix?
This works: for k = 1:4 % fake data: new = zeros(2,pow2(k-1)); new(:) = 10*k+(1:numel(new)); % ...

8 years ago | 1

| accepted

Answered
How to get a desired result using regexp in matlab
Why do you need regular expressions for this? Why not just |str(2:end-1)| ?: >> str = '(1,2,3)'; >> str(2:end-1) ans ...

8 years ago | 1

Answered
Error using fprintf Invalid file identifier. Use fopen to generate a valid file identifier.
Replace this line lpfid = fopen(lp_file,'w'); with these two lines: [lpfid,msg] = fopen(lp_file,'w'); assert(lpf...

8 years ago | 0

Answered
How can I take variable number of input strings in a function and return the concatenated output string?
function out = myjoin(varargin); out = sprintf(' %s',varargin{:}); out = out(2:end); end And tested: >> myjoi...

8 years ago | 0

| accepted

Answered
All negative number on bottom
>> A = [1,-3,4;-2,5,6;4,2,1] A = 1 -3 4 -2 5 6 4 2 1 >> S = size(A); >> [~,R] = sort(A<0,...

8 years ago | 0

| accepted

Answered
Why for loop just save the value of last iteration?
I = imread('vein2.jpg'); V = 0:0.005:0.1; N = numel(V); Z = zeros(N,1); for k = 1:N E = adapthisteq(I,'NumT...

8 years ago | 0

| accepted

Answered
how to use name of char file to call file of same name in matlab
Oh, this would by so easy if you |load|-ed that |.mat| file into a structure, like this: S = load('Full-load1.mat') Then...

8 years ago | 0

| accepted

Answered
Combination of Elements of Vectors
Download Jos's excellent FEX submission <https://www.mathworks.com/matlabcentral/fileexchange/10064-allcomb-varargin- |allcomb|>...

8 years ago | 0

| accepted

Answered
Merge vector and matrix with duplicated common values
One solution using <https://www.mathworks.com/help/matlab/ref/accumarray.html |accumarray|>: >> A = [1,1,2,3;1,2,3,5;1,3,4,...

8 years ago | 0

| accepted

Answered
What is the possibly easiest way to convert back and forth between a struct scalar and a struct array?
Use <https://www.mathworks.com/help/matlab/ref/struct2cell.html |struct2cell|>, <https://www.mathworks.com/help/matlab/ref/cell2...

8 years ago | 0

| accepted

Answered
Why does the if statement in this while loop not work
_"It should print that i is 20, however it prints that it is 0"_ Not in the world of floating point numbers. Never use _exact...

8 years ago | 0

| accepted

Answered
matrix of circulating vectors without loop
I think your concept is quite reasonable You could simplify the code a bit by using a cell array for the output, rather than kee...

8 years ago | 1

Answered
How can i achieve this "linspace" problem?
It is not possible to put multiple elements into one element of a numeric array. Use a cell array: vec = [8,10,12]; d = ...

8 years ago | 1

| accepted

Answered
Looping over inputs provided by structure
The basic problem is that you are confusing the _number of fields_ in a structure with the _size_ of the structure. However thes...

8 years ago | 0

| accepted

Answered
Convert a numerical variable in a table to string
As the MATLAB documentation explains, you need to use curly braces to access the _contents_ of a table: string(T{:,3}) ...

8 years ago | 3

Answered
how to convert hex array to decimal array ?
One char vector, fixed length hexadecimal, no spaces: >> sscanf('d1d2d4cf','%2x') ans = 209 210 212 ...

8 years ago | 2

| accepted

Answered
Determining the total value of the number in each position of a matrix that corresponds to another same length matrix
>> year = [2007;2009;2011;2018;2007;2007]; >> medals = [1;1;5;7;3;1]; >> [uni,~,idx] = unique(year); >> cnt = accumar...

8 years ago | 1

| accepted

Answered
Create a function which returns values into input variables in a single call.
This will work on one single string or char vector, or on a cell array of them: C = strcat(regexprep(C,'\\$',''),'\') Yo...

8 years ago | 0

Answered
replacing all numbers in a certain row
Where |M| is your matrix: M(any(M==-3,2),:) = -3 For example: >> M = randi(9,5); >> M(4,2) = -3 M = 5 ...

8 years ago | 1

| accepted

Answered
delete the first n elements of each cell
I doubt that there is a much faster way, because what you are doing resizes the arrays themselves. |cellfun| will likely be slow...

8 years ago | 0

| accepted

Answered
How to combine two arrays with different dimensions into one array in one column.
C = [A;B] Basic MATLAB concepts, such as how to make and concatenate arrays, are explained in the introductory tutorials (w...

8 years ago | 0

Answered
I don't know why it keeps saying illegal use of "case"
It looks like Python code, because all of the <https://www.mathworks.com/help/matlab/ref/if.html |if|> statements are missing th...

8 years ago | 2

Answered
Using importdata to import sorted files
Your code is a bit mixed up, because you are confusing two different paradigms for reading multiple files: reading the filename...

8 years ago | 0

| accepted

Answered
How to take first Character if name starts with specified string
One solution: C = {... 'STA.TH01E2RT00' 'STA.J01E2RT00R99' 'STA.TB01E2RT00' 'Deafult.TY04KT00' 'Cond.TH09K12...

8 years ago | 1

Answered
How do I search through a character array with another character that has optional words?
str = 'banana apple'; rgx = strrep(str,' ','|'); regexpi(...,rgx,'match') Or if there might be newlines, tabs, or mul...

8 years ago | 0

| accepted

Answered
Load function in script not saving to Workspace
_"However, when I click on the button, the network isnt showing up in the workspace"_ Yes it is. It will be loaded into the c...

8 years ago | 0

Answered
Can I use a for loop "elementwise" for a given vector?
The |for| operator operates over the columns of its input argument, so in your first example you provide it with one single colu...

8 years ago | 0

| accepted

Answered
Undefined function 'pdst' for input arguments of type 'struct'. Kindly help to resolve the error
The MATLAB documentation does not list any function named |pdst|. Possibly you meant to call the Statistics Toolbox' <https://ww...

8 years ago | 0

Load more