Answered
I want to use all the values present in two arrays but if I run for loops (ie) I used two for loops but only the last value of both the arrays are taken. What is the syntax so that I can use all my values of both arrays simultaneously.?
V1 = [60,78,132,12,26,10,150,156,172,168,159,174]; V2 = [61,150,16,24,25,8,155,164,173,160,171,169]; V3 = [0,1,2,3,4,5,6,7,8,9...

7 years ago | 0

| accepted

Answered
Assign values to a new variable via a function
"% Below line is the line that doesn't work" namesNew = namesOld; It doesn't work because you are trying to magically access v...

7 years ago | 0

| accepted

Answered
How to save/load cell data in/from matlab binary file with another extension?
>> A = 1; >> save('test.xyz','A','-mat') >> clear >> S = load('test.xyz','-mat'); >> S.A ans = 1

7 years ago | 1

| accepted

Answered
how to convert 5.5 hour to 05:30:00 HH:MM:SS format?
>> datestr(5.5/24,'HH:MM:SS') ans = 05:30:00

7 years ago | 1

| accepted

Answered
storing values from a for loop into a new variable
N = numel(row); C = cell(1,N); for k = 1:N C{k} = sol{k} end Or without a loop: C = sol(1:N)

7 years ago | 0

| accepted

Answered
How to concatenate structs with different fieldnames?
Just use some loops (this will be quite efficient): A(1).Stats.Var1 = 1; A(1).Stats.Var2 = 2; A(2).Stats.Var1 = 3; Z = repma...

7 years ago | 0

| accepted

Answered
How to read .csv file using textscan function ?
opt = {'Delimiter',',','CollectOutput',true,'TreatAsEmpty','""'}; fmt = repmat('%f',1,50); fmt = ['%q%q',fmt]; [fid,msg] = fo...

7 years ago | 1

| accepted

Answered
plot mean of vector v(1:i)
plot(v,cumsum(v)./(1:numel(v)))

7 years ago | 0

| accepted

Answered
How to sort 2 matching column only decending one of them?
Either put the data into one matric and sort by one column, e.g.: M = [T(:),H(:)]; % [period,height] M = sortrows(M,-2) % so...

7 years ago | 0

| accepted

Answered
Print the power of a vehicle with time array entries
>> m = 1500; >> g = 9.81; >> a = 0; >> p = 1.2; >> cd = 0.17; >> A = 0.66; >> mi = 0.54; >> htta = 0.45; >> ...

7 years ago | 0

| accepted

Answered
How to measure the euclidean difference between a vector and a matrix?
Without the statistics toolbox: >> f = [3,9;4,10;8,1]; >> m = [4,8]; >> sqrt(sum((m-f).^2,2)) ans = 1.4142 2.0000 ...

7 years ago | 1

| accepted

Answered
Which commands will I use to generate the following plot
Using simple numeric commands: >> X = -5:0.1:+5; >> Y = 1-X.^3; >> plot(X,Y)

7 years ago | 1

Answered
minmax does not work in matlab 2018b
https://www.mathworks.com/help/deeplearning/ref/minmax.html is simply equivalent to: [min(M,[],2),max(M,[],2)] for a matrix M...

7 years ago | 1

| accepted

Answered
How can I access the elements of one array with another array?
This is really very easy once you put those indices into a cell array: C = {ix,iy,...,iN,':'}; a(C{:}) = b https://www.mathwo...

7 years ago | 2

| accepted

Answered
What is the difference between Function and Function Handle?
A function is some code written in a file, starting with the function keyword. When you call that function then MATLAB will run ...

7 years ago | 3

| accepted

Answered
Reading multiple nc files in different subfolders within a directory
You should start again, because all of those cd calls are absolute chaos. Start with something like this: D = '/Users/Document...

7 years ago | 0

| accepted

Answered
how to rename files .tif in a folder ?
D = 'C:\Users\ASUS\Desktop\2'; S = dir(fullfile(D,'*.tif')); for k = 1:numel(S) [~,F] = fileparts(S(k).name); if ~is...

7 years ago | 0

| accepted

Answered
How do I make EXTRAPVAL a scalar?
Add str2double: a = str2double(input(prompt,'s')); ... b = str2double(input(prompt,'s')); This is more robust than calling i...

7 years ago | 0

Answered
Call a Matrix inside another Script
Actually all you need in your script is this: psm_q = [pi/3; pi/3; 0.1; pi/3; pi/3; pi/3];

7 years ago | 0

Answered
How to add scalar to empty matrix?
Where val is possibly empty, and the ouput should be a scalar: tmp = [val,0]; tmp(1) If the output could be non-scalar, then ...

7 years ago | 0

| accepted

Answered
How to transpose a cell array converted into a character arrray?
Converting to a horizontal character array is easy with a comma-separated list: >> C = {'Green','Blue','Red'}; % orientation is...

7 years ago | 0

Answered
series of consecutive numbers in a matrix
This is MATLAB, so get rid of the pointless loops: >> M = [2 3 5; 6 1 3; 4 5 6; 3 3 3; 9 8 7; 1 2 3] M = 2 3 5 6 ...

7 years ago | 0

Answered
Add a number every n values
>> B = reshape(A,3,[]); >> B(4,:) = 800; >> B = reshape(B,1,[]) B = 1 2 3 800 4 5 3 800 0 ...

7 years ago | 0

Answered
how can i find the numbers and their indices which are same
M = [1,3,4,36;3,2,2,5;5,5,6,8;3,4,1,23;3,12,6,34;1,5,3,1;11,17,12,9;17,19,26,26;16,1,1,27;18,10,18,15]; for k = 1:size(M,1) ...

7 years ago | 1

| accepted

Answered
How to fix error done by pressing 'Cancel' button using App Designer?
Try reading the uigetdir help, where it explains that "If the user clicks Cancel or the close button (X) on the title bar, then ...

7 years ago | 1

| accepted

Answered
Error using sortrows, too many input arguments
sortrows(srt,[-1,-2]) But your allocation does not make much sense: srti(j,3)=sortrows(srt,...) because you try to force two...

7 years ago | 1

| accepted

Answered
Put matrix in cell
Simpler: >> T = [3,6,1,12,7,10,6,0,0,22,0,15;2,4,4,3,2,4,5,0,0,20,0,4;0,1,0,2,0,2,0,0,0,17,0,16;0,5,0,6,0,7,0,0,0,6,0,0;0,0,0,0...

7 years ago | 0

| accepted

Answered
Can someone please help me answer this question, I have no idea what to do.
Consider what the difference between values actually is, and try some examples: >> diff([2,5]) ans = 3 >> diff([2,5,9]) ...

7 years ago | 1

| accepted

Answered
random vector (1,10)
ceil(a*rand(1,10)) Often beginners think of using round for something like this, but the usual algorithm they use has nasty end...

7 years ago | 1

Load more