Answered
Writing string and numerical values to same line in .txt file
secs=1; % define as variables; hardly worth the effort as fixed strings... modl=200; ... fprintf(fid,'%10s=%5d\n'...

10 years ago | 0

| accepted

Answered
Hello, I have so problem with this code segment? When I try to run this program, I receive a error warning "Too many input arguments". Help me to fix this problem! Thank in advance!
Too much code; too little information. Give us _only_ the actual error in context cut 'n pasted from the screen and the defin...

10 years ago | 0

| accepted

Answered
HELP with for loop plots and changing symbol styles
for ii = 1:N; for k=1:length(col); plot(X(ii,:), col{k}); end end You're plotting the same data over a...

10 years ago | 0

| accepted

Answered
Undefined operator '*' for input arguments of type 'struct'.
While not your problem, a stylistic note-- for i = 1:7 y(i)=[x(i+6)]; end should be written in Matlab as y=...

10 years ago | 0

Answered
Define a matrix elementwise
Q=1./abs(A).*(B~=0); % 1/abs(A) and zero B locations Q(isnan(Q))==0; % fixup 0 locations from A (logical*Inf-->Na...

10 years ago | 0

| accepted

Answered
sir i have two conditions with if true i have to take response as 1 else 0 and store the values in an array
Assuming you really did mean to have both conditions increment the same counter variable, Matlab doesn't need any loops nor even...

10 years ago | 0

Answered
How to change axes linewidth?
See <http://www.mathworks.com/help/matlab/ref/axes-properties.html <axes-properties>> _'linewidth'_

10 years ago | 0

Answered
How can I scan a text file in order to read a specific number in a line?
Don't try to read from a file each time; read the data into memory and use lookup... >> M=0:0.5:5; >> P=[1,.8,.5,.3,.1,....

10 years ago | 0

Answered
How do I read in a binary file that has a very unique data structure?
There's no facility in *memmapfile* to handle arbitrary bit-lengths; you'll have to map the 12-byte type to an array of 3-x-uint...

10 years ago | 0

Answered
Using output from a nested function in parent function?
_"Functions that return output arguments have variables for the outputs in their workspace. However, parent functions only have...

10 years ago | 0

Answered
Replace certain matrix values with zeroes (more complex than other similar questions)?
Does seem bizzaro, indeed, but presuming there's a need there's a way... >> mm=repmat(m,sum(s),1); >> mm(1:2*size(m,1),1:s...

10 years ago | 1

Answered
how to fix fread error ?
In function *MNISTParser* fp = fopen(filename,'r'); magic_number = fread(fp,1,'uint32',0,'b'); you didn't test the re...

10 years ago | 0

| accepted

Answered
RMS error and Mean absolute error from text files
... % Creating 30% of sample as -9999.0 nr=round(n*0.3); TE=Tmp(randperm(n,nr)); good_temp = find(TE); ... I...

10 years ago | 1

| accepted

Answered
Preallocating for speed, what kind of variable is this?
_Box_ is just a 2D array of type whatever is nBox.BoundingBox (which would appear to be a floating point type given the *round* ...

10 years ago | 1

| accepted

Answered
Error using sub2ind out of range subscript
_Ugleee code to the extreme..._ :( Format your code; don't use run-on continuation lines wildly. One way to build the init...

10 years ago | 0

Answered
Constant number is changing value, why?
... for ind=1:1920 ... xOvito(ind)=xOvito(ind)+magFact*displ(1); yOvito(ind)=yOvito(ind)+magFact*displ(2)...

10 years ago | 0

Answered
How do I make a function that shows the minimum value and index of that original minimum value without the "min()" function?
[minx,idx]=mynotverycleverhomeworkminfunction(x) [s,is]=sort(x); minx=s(1); idx=is(1); More to the point, wh...

10 years ago | 1

| accepted

Answered
Can I assign a value from textscan to anything other than a cell array?
The insistence of *textscan* to return only cell array is annoying often, indeed. Only way around what you're doing I'm aware o...

10 years ago | 1

| accepted

Answered
How to store vectors with different size in a loop ?
Use cell array instead; the curly brackets... M{k} = found_roots;

10 years ago | 4

| accepted

Answered
Generating random ones and zeros controllably
doc randperm % note the second optional input... Will leave as "exercise for the student" the actual application but is st...

10 years ago | 0

Answered
How to select the particular value and store ias a variable?
abs(0.65-0.675) = 0.025 abs(0.75-0.675) = 0.075 so it's not clear how you want 8 as the result instead of 10 as it is th...

10 years ago | 0

Answered
how to find nearest value to zeros?
If the signal crosses zero, look at doc fzero Otherwise, if is all positive the point nearest zero is simply [ymin,...

10 years ago | 0

Answered
How to set YTickLabel in double y-axis plot?
Isn't it annoying that *plot* isn't intelligent-enough to use a consistent numeric format for tick labels??? I've complained ab...

10 years ago | 0

| accepted

Answered
Extract two closest rows of a matrix
d=pdist(M(:,2)); % find the pairwise differences ix=find(min(d(1:end-1)); % shortest distance excluding wraparoun...

10 years ago | 1

| accepted

Answered
Read a .txt except one column
Looks like an extra count for _'headerlines'_, maybe? 'Pends on whether the above line is the 30th or the previous 30 were some...

10 years ago | 0

Answered
How to draw the below type of graph in MATLAB
Simplest approximation is doc histfit % use optional specified distribution option for Weibull add the annotation with ...

10 years ago | 0

Answered
Finding a value on a plot using code?
Inverse interpolation... >> Vout = [1, 0.95, 0.92, 0.89, 0.82]; >> Time = 1:5; >> T90=interp1(Vout,Time,0.90) T90 ...

10 years ago | 0

Answered
How can I extract the contents of a numbered list within an array?
>> c={'1. h4 e5 2. c3 g5 3. b3 Nh6 4. g4 d5 5. Ba3 Qd6'}; >> textscan(char(c),'%*s%s%s','collectoutput',1) ans = {5x...

10 years ago | 1

| accepted

Answered
Why my .exe doesn't write in the .xls file that I provide?
Probably the working directory isn't the same in the .exe as it is when you're running inside Matlab so you're creating a new fi...

10 years ago | 0

Load more