Answered
find elements vector in a matrix
Simply use sub2ind like this: >> idx = sub2ind(size(psic_pos),1:size(psic_pos,1),loc); >> vec = psic_pos(idx) vec = 0....

7 years ago | 1

| accepted

Answered
find 4d matrix positions
"I tried with ind2sub but it was useless." It worked for me. First lets define some fake data: >> A = zeros(5,4,3,2); >> A(5,...

7 years ago | 0

| accepted

Answered
import data without header
opt = {'HeaderLines',20}; fmt = repmat('%f',1,4); str = fileread('temp0.txt'); C = textscan(strrep(str,',','.'),fmt,opt{:}); ...

7 years ago | 0

| accepted

Answered
Extract number from file name
>> C = {'K10_0.0.json', 'Mig_Thresh_2.0.json', 'K_5_6.5.json', 'WC_0.00051.json'}; >> [~,N] = cellfun(@fileparts,C,'uni',0); >...

7 years ago | 1

Answered
Switch function to output number of days in a month
Actually you need to use the optional 's' argument for input, otherwise your code will throw an error: n = input('Enter the mon...

7 years ago | 0

| accepted

Answered
How to solve Reference to non-existent field 'folder'.
The folder field (and recursive folder searching) was added in R2016b. As you are not using the recursive folder search you can...

7 years ago | 0

| accepted

Answered
Sort the dir loaded files
Download my FEX submission natsortfiles and follow the examples in its documentation: https://www.mathworks.com/matlabcentral/f...

7 years ago | 0

Answered
Changing the ASCII sort order format?
To sort filenames into the order that you want download my FEX submission natsortfiles: https://www.mathworks.com/matlabcentral...

7 years ago | 0

Answered
Duplicate Each Element in a Matrix without using Repelem or Repmat
>> A = [1,0;0,1] A = 1 0 0 1 >> V = ceil((1:6)/3); >> B = A(V,V) B = 1 1 1 0 0 0 1 1 1 0...

7 years ago | 3

Answered
Can anyone help? I cannot figure out how to use a for loop to check elements in part of a matrix.
"I can make the actual matrix, but after that I don't know what comes next." Your assignment tells you exactly what you need to...

7 years ago | 0

| accepted

Answered
Indexing into a type I don't recognize
Use indexing to get any elements you want from a structure array: ext_header(ii).value https://www.mathworks.com/help/matlab/m...

7 years ago | 0

| accepted

Answered
Dimensions of arrays being concatenated are not consistent
You included definitions for every variable except for the one that likely causes the problem, I0. Running your code gives an e...

7 years ago | 0

| accepted

Answered
Is there a command ( like "sort" for example ) arranges vector elements ascending ,max, descending (humped shap)?
>> V = randi(99,1,23) V = 93 68 76 74 39 65 17 70 4 28 5 10 82 69 32 95 ...

7 years ago | 0

| accepted

Answered
Delimiter problems with =
opt = {'Delimiter','='}; fmt = '%s%[^\n]'; [fid,msg] = fopen('ENTRADA.txt','rt'); assert(fid>=3,msg) C = textscan(fid,fmt,op...

7 years ago | 1

| accepted

Answered
Cant get my code to work
Note the spelling difference: Guass_t % function output arugment Gauss_t % variable defined in the function

7 years ago | 0

| accepted

Answered
how can i transfor these numbers into dates (dd / mm/ yyyy) in Matlab? 19300501 19300502 19300503 19300505
Using datetime: >> M = [19300501;19300502;19300503;19300505] M = 19300501 19300502 19300503 19300505 >> D...

7 years ago | 1

| accepted

Answered
X = [struct(jjj).name,' seed ', seedno]; disp(X) is not printing seedno
X = [struct(jjj).name,' seed ',num2str(seedno)]; disp(X) Or using low-level commands: fprintf('%s seed %d\n',struct(jjj).name...

7 years ago | 1

| accepted

Answered
How to replace strings in a cell array
>> C = {'A', 'B', 'C', 'D', 'QQQQ_01', 'E', 'QQQQ_02'} >> X = find(strncmp(C,'QQQQ',4)); >> C(X) = strcat('Q_',C(X-1)) C = ...

7 years ago | 0

| accepted

Answered
Writting a loop for calculating difference from previous result of first calculation
Initial_value = 50; minimum_value = 25; difference_value = 5; remaining_value = Initial_value; while remaining_valu...

7 years ago | 0

| accepted

Answered
How can I pass in variables into fsolve()?
"...can't seem to figure out how to pass in the known variables of A to this section of code:" The MATLAB documentation explain...

7 years ago | 0

| accepted

Answered
I have a matrix with one column in serial datenumber format, how do I select data from a certain time period?
Serial date numbers are, as their name implies, just numbers. So it is very easy to use logical comparisons, just like you would...

7 years ago | 0

| accepted

Answered
fixing an error for calling a variable in an array
I suspect that you want something like this: >> Y = [1,7;3,9;11,12;15,18;22,12;12,23;15,19;10,22;17,28;111,123] Y = 1 ...

7 years ago | 0

| accepted

Answered
How to pass arguments into a function handle that is then used in fsolve?
function out = transcendental(neff,w) % best to use same name as the file. % Do NOT define |w| here! c = 2.998e8; ns = 1.5; ...

7 years ago | 0

| accepted

Answered
how to select a set which has a highest value when compared with other sets
>> Z = {[23,45,67,89,36],[32,56,44,47,33,66],[12,45,76,99,50,76],[19,67,89,37,19,36]}; >> [~,X] = max(cellfun(@max,Z)); >> V =...

7 years ago | 0

Answered
How to check ismember in a cell in Matlab?
>> List = {[4,5,2],[27,19],[13,8],[17,14],[3,13],[21,20],[6,16],[4,30],[1,13],[20,2],[14,27,2];[5,2],[21,7],[29,6],[17,36],[35,1...

7 years ago | 0

| accepted

Answered
Extracting values from file names to array
>> D = 'path to the folder where the files are saved'; >> S = dir(fullfile(D,'file_*.txt')); Method one: regexp: >> V = str2d...

7 years ago | 2

| accepted

Answered
Cell array indexing in loop for subplot titles
You defined a variable named title: title={'# objects','centroid mean','centroid mode','FM','Q99'} which shadows the title fun...

7 years ago | 1

| accepted

Answered
Varargout - How to realize function call
Simpler: function [out1,out2,out3]=test(j,k) out1= nargin; out2 = j-k; out3 = []; ... if out2 == 10 out3 = 5; end e...

7 years ago | 0

| accepted

Answered
Uploading a value with a Matrix into MATLAB GUI
Clearly tempval is a cell array, which as the error message makes quite clear, sprintf cannot handle. But regardless, that is a ...

7 years ago | 1

| accepted

Answered
How do i assigning a color to a range of numbers in an image array?
A = [9899,9899,9899,9899,9899;9899,-90,0,70,9899;9899,9899,-20,30,9899;9899,9899,9899,9899,9899]; % backgnd; neg; zero; po...

7 years ago | 0

| accepted

Load more