Answered
Extract row values from text file to add
V1 = readmatrix('file1.txt') V2 = readmatrix('file2.txt') Z = cumsum(0.5*(V1(2:end)+V1(1:end-1)) .* diff(V2))

4 years ago | 0

| accepted

Answered
Perform calculations on matrices stored in cells
A = cat(3,C{:}); % join all matrices into one array A(1:3,1,128) - A(1:3,1,:) % difference 1st column A(1:3,2,128) - A(1:3,2,:...

4 years ago | 0

Answered
How do I use fprintf to print a cell in a cell array?
A = {'hi'}; fprintf('%s\n',A{:}); https://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-cell-array.html

4 years ago | 0

Answered
Problems with the diff function
syms x y M = 2 * y - 2 * x * y^3 + 4* x + 6 N = 2*x - 3*x^2*y^2 -1 cond = diff(M,y) - diff(N,x) Note: diff(M,y) diff(N,x)

4 years ago | 0

Answered
Fix out-of-gamut RGB colors
Simpler and much more efficient: rawRGB = max(0,min(1,rawRGB));

4 years ago | 0

| accepted

Answered
How to save 14*14 matrix in each iteration?
N = 128; C = cell(1,N); for k = 1:N .. your code C{k} = Vd; end https://www.mathworks.com/help/matlab/matlab_prog/...

4 years ago | 0

| accepted

Answered
Matlab: Convert [2x1 sym] to a numerical value
syms A B C D E = (89*50*sind(170))+(92.3*A*sind(C))+(83.3*B*sind(D))==0; F = (89*50*cosd(170))+(92.3*A*cosd(C))+(83.3*B*cosd(D...

4 years ago | 0

| accepted

Answered
Using xlsread with multiple delimiters
Without a sample XLSX file I had to create my own (attached). It is easy to read the first line using READCELL, it will correct...

4 years ago | 0

| accepted

Answered
Data Arrangement in Matrix form
S = load('matlab.mat') B = reshape(S.A,132,2911)

4 years ago | 0

| accepted

Answered
read csv file with a lot of columns.
A much better approach would use READTABLE to correctly import that numeric data (with decimal-commas in what is actually a semi...

4 years ago | 1

Answered
Read data from .txt with regexp
rgx = '^\s*->\s*(\w+)\s*\[[\w\s]+\]:\s*([^\r\n]+)'; str = fileread('ExampleTextFile.txt'); tkn = regexp(str,rgx,'tokens','line...

4 years ago | 2

| accepted

Answered
Reading files in a specified order
Download NATSORTFILES here: https://www.mathworks.com/matlabcentral/fileexchange/47434-natural-order-filename-sort and use it ...

4 years ago | 0

| accepted

Answered
If condition: "in each row of a matrix one element is zero and the other one is not zero"
A = [1,0;0,9;12,0;0,2;0,3] if any(A,2)&any(~A,2) disp('in each row one element is zero and the other one is not zero') en...

4 years ago | 1

Answered
Extracting strings in a cell array that contain certain characters
W = {'gamer';'macho';'mages';'grail'}; L = 'amg'; X = cellfun(@(w)all(ismember(L,w)),W); Z = W(X)

4 years ago | 0

Answered
char(2713) and fprintf('\x2713\n') don't show a checkmark in the command window
"According to https://en.wikipedia.org/wiki/Check_mark, the unicode for a checkmark is 2713." Sure, lets try it using both FPRI...

4 years ago | 3

| accepted

Answered
How to read this file in MATLAB?
"I guess I will need to convert the file and then read it, but how?" Why do you "guess" that? READTABLE has no problem importin...

4 years ago | 0

Answered
Is it possible to use two textscan statements in a row ?
"Is it possible to use two textscan statements in a row ?" Yes, you can call TEXTSCAN as many times as you want on one file, I ...

4 years ago | 0

| accepted

Answered
How to remove corresponding rows of a second array in the case of NaNs in the first array?
Where M is your matrix (do not use the name mean): idx = all(isnan(M),2); M(idx,:) = []; clst(idx,:) = []; Why do you want t...

4 years ago | 0

| accepted

Answered
Help with Matrix logic and indexing
cnt = nnz(m>= 40 & m<= 50)

4 years ago | 0

Answered
Converting string array to float array
S = ["[1,1]";"[2,1]";"[3,1]"] Method 1: M = sscanf(join(S,''),'[%f,%f]',[2,Inf]).' Method 2: M = cell2mat(arrayfun(@str2num,...

4 years ago | 1

| accepted

Answered
Read a file with textscan.
opt = {'Delimiter',',','Headerlines',6,'CollectOutput',true}; fmt = ['%{uuuuMMddHHmmss}D',repmat('%f',1,12)]; fid = fopen('new...

4 years ago | 0

Answered
Split and count unique string in cell array
A = {'B25';'A35';'L35 J23';'K32 I25';'B25'}; B = regexp(A,'\S+','match'); T = cell2table([B{:}].'); S = groupsummary(T,'Var1'...

4 years ago | 0

| accepted

Answered
Numbers from a csv are not being read as doubles, but as chars?
"...I was forced to edit the original csv..." That is the cause of your problem right there. Let me guess: you made the mistake...

4 years ago | 1

| accepted

Answered
Why is spline doing weird stuff with my data?
I don't see any "weird stuff": X = [119645.85786265088;146646.66450412222;202133.69044903992;278604.3016284374;352333.877275211...

4 years ago | 0

Answered
only use filepath if it is a log file
P = 'absolute or relative path to where the files are saved'; S = dir(fullfile(P,'*.log')); for k = 1:numel(S) F = fullfi...

4 years ago | 0

| accepted

Answered
Why is my coding stopping at the shotscore vector when using fprintf?
fprintf('%3.0f %6.2f %6.2f %6.3f %3.0\n',[numbers x y shot shotscore]') % ...

4 years ago | 0

Answered
Difference of elements of vector and matrix
A = [1,2,3,4;5,6,7,8] B = [1,3] [X,Y] = ismember(B(1,:),A(1,:)); C = A(:,Y(X))

4 years ago | 1

| accepted

Answered
reallocating matrix concatenated as string
Much better to use string arrays: M1 = [10,22,42;193.92,68.8,9.34;193.92,68.8,9.34] M2 = [10,22,42;8,7,1;8,7,1] S = M1+"-"+M2...

4 years ago | 0

| accepted

Answered
create a new variable based on excel sheet values
fnm = 'test.xlsx'; snm = sheetnames(fnm) dat = cell(size(snm)); for k = 1:numel(dat) dat{k} = readmatrix(fnm,'Sheet',snm...

4 years ago | 1

| accepted

Answered
I have a table with names of structures present in the workspace, I need to access each Structure by getting the name from the table and update the respective structure field
Put all of the tables into one cell array and then use basic indexing. Or use the fields of a structure, e.g.: https://www.math...

4 years ago | 0

Load more