Answered
output the ohms symbol
>> fprintf('The resistance for the given color bands is 26000 Ω\n') The resistance for the given color bands is 26000 Ω >> fpr...

7 years ago | 0

| accepted

Answered
Can we sum lastletter of string?
>> A = '111n22'; >> B = '444m11'; >> C = '777n55'; >> sum(str2double(regexp({A,B,C},'\d$','match','once'))) % single ans = ...

7 years ago | 0

| accepted

Answered
How can ı choose a defined valuable when ı use input function
vn = input('please enter the vehicle name ','s'); switch upper(vn) case 'A' val = 0.5; case 'B' val...

7 years ago | 1

| accepted

Answered
How can I store an Italic-font text in a file?
"How can I use fprintf to store a string in a file (( with ITALIC font ))?" You can't, because textfiles do NOT contain any for...

7 years ago | 0

Answered
question on indexing: How to extract rows from a matrix that crossponds to certain values in another vector?
Just call find with its optional 2nd and 3rd input arguments to specify that you only want one result returned: >> n = 3; >> p...

7 years ago | 0

Answered
Finding a scalar to make two arrays as equal as possible.
Use mldivide: c = A(:) \ B(:) For example: >> A = rand(2,3); >> B = A*0.23; >> c = A(:) \ B(:) c = 0.23000

7 years ago | 1

Answered
Matlab is skipping over my while loop.
"Matlab is skipping over my while loop and I do not know why." Because you told it to. Lets have a look at what values V and n...

7 years ago | 0

Answered
How to find the position of a row in an array
>> [~,Y] = ismember(S,R,'rows') Y = 3

7 years ago | 0

Answered
Transform char variable to matrix
Efficient solution: >> C = {'002,005';'002,003';'002,005'}; >> sscanf(sprintf('%s;',C{:}),'%f,%f;',[2,Inf]).' ans = 2 5...

7 years ago | 1

Answered
How to vectorize max / min number in row
>> max(A,[],2) ans = 2.0000 2.3333 2.6667 3.0000 3.5556 4.4444 5.3333 6.2222 7.1111 8.0...

7 years ago | 1

| accepted

Answered
Storing string of a loop
Your code has multiple bugs, in particular wrong indexing into the cell array, missing format specifier in the |sprintf| format ...

7 years ago | 2

| accepted

Answered
Sorting 256*2 cell
Although the question is not very clear, I suspect that you might like to download and try my FEX submission natsortrows, which ...

7 years ago | 0

| accepted

Answered
Combination of 2 columns
[Am,Bm] = ndgrid(A,B); M = [Am(:),Bm(:)]

7 years ago | 0

| accepted

Answered
Write a program that calculates the length of hypotenuse c for all (!) combinations of legs a and b and do so using a for loop!
The easiest way to get all combinations is to use two loops: a = [3;5;1;3;2]; b = [1;3;2;7;2]; for ii = 1:numel(a) for j...

7 years ago | 0

Answered
How can I get the full value of a variable with decimal point
"the actual answer is 0.0205 But my result is displayed as 0 For 0.5 it is displayed as 1" Those are the values, they are NOT j...

7 years ago | 2

| accepted

Answered
Image Saving to Variable in Workspace (NOT imwrite)
"In this case sp_possible_quadtree is a double. where the contents are either 0 for Black, or an integer 1, 2, 3, 4, ... n" LLL...

7 years ago | 0

Answered
Extracting string and number pairs from a mixed string
The two lines marked with %%% are used to convert substrings like '(Fe0.5Co0.5)58.5' into 'Fe29.25Co29.25', after which the desi...

7 years ago | 1

| accepted

Answered
How can I convert a number to time?
>> V = randi(58232,7,1) % fake data V = 7565 33124 27334 694 19632 9445 ...

7 years ago | 0

| accepted

Answered
how to Vectorize this for loop
Try doing something like this: [fid,msg] = fopen('CANDec(day_1_9).txt','rt'); assert(fid>=3,msg) % good practice to check the ...

7 years ago | 0

| accepted

Answered
scalar vs matrix vs vector vs array??
Just like in mathematics, the only difference is their size. MATLAB does not have special classes for scalars, vectors, matrice...

7 years ago | 3

| accepted

Answered
Reducing repeated elements in an array by a factor
>> V = [1,2,2,2,2,2,2,5,6]; >> N = 3; >> X = cumsum([1,diff(V)~=0]); >> F = @(v) {v(1:ceil(numel(v)/N))}; >> cell2mat(accuma...

7 years ago | 2

| accepted

Answered
Storing Function Handles in structure
>> fun = @(x,y,z) [x,y,z]; >> baz = @(n,v) v(n); % helper function >> a = @(n) @(x,y,z)baz(n,fun(x,y,z)); Testing: >> f = a(...

7 years ago | 1

| accepted

Answered
creating channels in an array
"What does this error mean?" You are trying to access array elements that do not exist! You defined h to have size 4x5(x1x1x1....

7 years ago | 0

| accepted

Answered
Problem using for loop
a = 1:10; n = numel(a); for kk = 1:n for ii = max(1,kk-2):min(n,kk+2) x = a(ii); end end

7 years ago | 0

| accepted

Answered
how to use interp1() function
The problem is that you are using the default x values, which for a vector input are defined as 1:numel(v) These default point...

7 years ago | 0

| accepted

Answered
Error using textscan Mismatch between file and format character vector. Trouble reading 'Numeric' field from file (row number 1, field number 3)
The second field is clearly not numeric, containing values like 020520t1xy10z12.tif 020520t1xy10z12.tif 020520t1xy10z12.tif ...

7 years ago | 1

Answered
Insert zero columns in matrices inside a cell array
Where C is your cell array: for k = 1:numel(C) C{k}(:,end+1:30) = 0; end

7 years ago | 0

| accepted

Answered
Delete values in one matrix that aren't contained in a second matrix
>> M1 = dlmread('coordiates_variable.dat'); >> M2 = dlmread('coordinates.txt'); >> idx = ismembertol(M1(:,1:3),M2, 0.0001, 'By...

7 years ago | 0

Answered
How to convert a 8760X30matrix to a 365X30 matrix?
>> inp = rand(8760,30); % fake data matrix >> out = mean(permute(reshape(inp,24,[],30),[2,3,1]),3); And checking: >> size(out...

7 years ago | 0

| accepted

Answered
for-loop over Structure Array
"Can anybody exlpain to me, why this happens" Because MATLAB is (as far the end-user is concerned) pass-by-value and not pass-b...

7 years ago | 0

| accepted

Load more