Answered
removal of doubles (both values)
This is one way to do it. %% a=[1 1 1 2 2 2 2 2 2 3 3 3 4 4 4 4 4 4]; [ua,indI,indJ]=unique(a,'rows'); ...

15 years ago | 0

Answered
If Statement
For that, I think taking the input as a string is better. %% t=input('Enter a positive octal number: ','s'); check=t>...

15 years ago | 0

Answered
MATLAB Function Simulink Block "Make Error"
It might be that you don't have a C compiler. Or you have not set up mex yet. try to run mex -setup

15 years ago | 0

Answered
Anonymous functions and conditional logic? (one line step function)
It can be done in a twisted way. I am not sure how much value it provides. step is a built-in function so avoid using it. h=@(t...

15 years ago | 1

| accepted

Answered
Automatic Iterative Varible Naming
FileName=num2str(i,'C%d.mat')

15 years ago | 0

| accepted

Answered
Matrices and vectors
%% Vmatrix=ones(20); f=[10 20 30 40]; d=mat2cell(Vmatrix,10*ones(1,2),10*ones(1,2)); for k=1:4 d{k}=d{k}*f(...

15 years ago | 0

| accepted

Answered
Index exceeds matrix dimensions problem
It happens when you try to do this for example. >> a=rand(2,3) a = 0.131973292606335 0.956134540229802 0.0597...

15 years ago | 0

Answered
switch case
The message is clear. The output of the "Switch Case" block can only be connected to one (and only one) "Switch Case Action Subs...

15 years ago | 0

| accepted

Answered
Matlab Compiler
Try to run "mex -setup" anyway. I thought if you don't have any C compiler, the default lcc will be used. That should be enough ...

15 years ago | 0

Answered
save text and data into ascii file
Use fprintf(). Assume the name of the structure is 'd'. fid=fopen('out.dat','wt'); fprintf('%s\n',d.textdata{1}); fpr...

15 years ago | 0

Answered
How to insert index table on XLS
I can think of two ways. First one is to write twice. The second one is to combine the Header and Data and then write once. See ...

15 years ago | 0

Answered
Datacursormode
What is "sub axes (grids)"? Do you mean subplot? Or did you actually plot the grid lines? I don't see problem in this example. ...

15 years ago | 0

Answered
NaN computing std
a=[1 2 inf 3 4 inf 5 6]; b=a(isfinite(a)) or b=a(~isinf(a))

15 years ago | 0

| accepted

Answered
difference between 2 matrices of different dimensions.
U_16=rand(16,16); index=1:2:16; % or index=2:2:16; U_8New=U_16(index,index);

15 years ago | 0

Answered
How to import matlab file variables in Simulink (By adding some block in Simulink Model)
That is probably a customized mask of a subsystem block. Assume the M-file you want to run is MyParam.m, you can drag an empty s...

15 years ago | 0

| accepted

Answered
Getting error inMatlab 2008 but code is fine in Matlab 2011
The use of ~ notation is only available in R2009b or later. You can replace ~ with a unwanted variable name such as temp, trash,...

15 years ago | 0

| accepted

Answered
How to separate rows from an array
If you matrix is numerical, it is actually easy. a=[1 5.00 2 10.00 3 1.50 ...

15 years ago | 0

Answered
Real quick one, passing through a matrix backwards or just flip it.
a=rand(8,9); b=a(5:end,5:end) "end" here is the length of that dimension. 1:end is the same as [1,2,3,...,end] end:-1:1 i...

15 years ago | 0

| accepted

Answered
Listing mat files in a directory and checking to see if they have a particular file.
Files=dir(fullfile('MyFolder','*.mat')) will give you a list of .mat files. Files=dir(fullfile('MyFolder','*.*')) will give y...

15 years ago | 6

| accepted

Answered
Error using Horzcat. Undefined function or variable 'opaque' for input arguements of type double.
Try to Ctrl+D (update) your model or run the simulation of your model by click the "Run" button, Simulink will report the error ...

15 years ago | 0

| accepted

Answered
Consistency in output between a 10 year simulation and two 5 year simulation runs of the same model
Do you have anything (inputs, parameters etc.) that is time dependent? When you run (b), you need to set the start time as 5, in...

15 years ago | 0

Answered
Basic Axes Handle question
h=gca; TitleHandle=get(h,'title') set(TitleHandle,'string','this is title text');

15 years ago | 0

| accepted

Answered
"Windows returned error message: Not enough storage is available to process this command."
Do a search on the error message. It sounds like a Windows error, rather than particularly related to MATLAB or Simulink.

15 years ago | 0

Answered
splitting a signal
You are half done. The other half is in (end/2:end)

15 years ago | 0

| accepted

Answered
Writing multiple arrays to the same excel sheet.
All you need to change is: b=[a(start:enda,2);a(start:enda,3)] or put them in two columns b=[a(start:enda,2),a(star...

15 years ago | 0

| accepted

Answered
plot scatter and line in same grid
x=[0:1:3]*10000 will solve your problem.

15 years ago | 1

| accepted

Answered
automatic creating of array
a=(1:n)' or a=cellstr(strcat('i',num2str((1:n)')))

15 years ago | 0

| accepted

Answered
Extract data from large file
Use the example below. Be careful about the Data(:,1)==37.1234 comparison though as it involves floating point. You may need to ...

15 years ago | 0

| accepted

Answered
Adding data to Matlab GUI Table from a listbox
It can be done as Amardeep suggested. But I think adding a push button is better as it avoids accidental operation when clicking...

15 years ago | 0

| accepted

Answered
why is this code not giving the output?
A is an anonymous function. You need to modify your B. %% A=@(x)[cos(x),-sin(x),0;sin(x),cos(x),0;0,0,1]; A(pi/2) ...

15 years ago | 0

Load more