Answered
Time axes (horizontal axes) range of Scope
By default, the Scope block has a limit of 5000 data points. Change the Scope parameters in the "Data History" tab to allow more...

14 years ago | 2

| accepted

Answered
Is it possible in Scope to plot 2 signals together and overhand?
Use the "Mux" block from the "Signal Routing" library to combine the two signal together into a vector signal and then feed it t...

14 years ago | 2

| accepted

Answered
fwrite do not write numbers 1-32
You are right, file ID 1 is the standard output. You are writing binary numbers but the standard output only shows the correspon...

14 years ago | 0

Answered
Simulink problem Vout/Vin
Use the <http://www.mathworks.com/help/toolbox/simulink/slref/xygraph.html XY Graph Block>. Feed Vin to X port and Vout to Y por...

14 years ago | 1

Answered
matrix addition
A=rand(3,4,5); B=sum(A,3); % sum at the third dimension.

14 years ago | 0

| accepted

Answered
Load----problem in using this commad
Try this first to see if it is the problem regarding your file name construction. for i=1:100 fnam=sprintf('F%03d.tx...

14 years ago | 2

Answered
matlab path
What is your function name? Do you have a conflict with other functions or variable names. Try to use which command. which ...

14 years ago | 0

Answered
adding elements in a loop into an array
Use x=[x;window_size]; or a better way, if num_windwows>0 x=zeros(num_windwows,1); else error('Invalid number of...

14 years ago | 0

| accepted

Answered
Change port numnber set_param('In1', 'Port', 8)
You need to use the full path of the block and set string format for the port number. Also, you might need to consider duplicate...

14 years ago | 1

Answered
Need a quick help on storing words according to lengths with struct
You have to use wordstruct.L4, wordstruct.L5, etc. as '4L','5L' etc. are not valid name. cellfun('islength',...) and then a for...

14 years ago | 0

| accepted

Answered
Problem compiling a GUI
What do you mean by "when I try open it"? If you've got an executable (*.exe file), you should run it in Windows Command Window,...

14 years ago | 0

Answered
Undefined function or variable "xa" error message
In the Simulink model, press Ctrl+F, search where the variable 'xa' is used. Then assign a proper value to 'xa' in MATLAB Comman...

14 years ago | 0

| accepted

Answered
how to access 5 values in an array at a time?
You can use reshape() and mean() to avoid the for-loops. %% A=magic(10); % if you want to do average of 5, row-wise B=A...

14 years ago | 0

| accepted

Answered
Vectorising setting values of array by reading from other array
x_arr=zeros(1000,1); arr=[45;56]; x_arr(arr)=1; You can't use 'x-arr' as it regards '-' as the minus operator.

14 years ago | 1

| accepted

Answered
avoiding same data in looping
For A=1:3 fprintf('The value of A is: %d\n',A); end

14 years ago | 0

| accepted

Answered
Simulink - Find computed index of multidimensional signal at specific time
I don't think you can do that. In the generated code, you will see there is a for-loop to do that vector summation. But it's not...

14 years ago | 0

| accepted

Answered
Reading from many columns of an excel sheet
Can you explain why you don't use xlsread() directly? A=rand(10); xlswrite('test.xls',A,'FirstSheet','B2'); B=xlsread('test.x...

14 years ago | 0

Answered
Labelling biograph figures
try title('This is my figure') Or maybe text(). Or you need to clarify your question. Providing an example to explain your que...

14 years ago | 1

Answered
How can we let Matlab to choose the decimal place?
Something like this? %% Value=pi; Err=0.00356; Str=sprintf('%1.0e',Err); Err=str2double(Str) D=str2double(Str(3:end...

14 years ago | 0

| accepted

Answered
Everytime I try to plot, I get a straight line, and not a sine wave:(
For the exact value y, you need to do y=exp(t/2).*sin(5*t) t is a vector, t(i) is the individual element depending on the ...

14 years ago | 0

| accepted

Answered
Initial Value of y(0)=0
Unlike C language, MATLAB uses 1-based index for vector and matrix. So if you define a 10x1 vector, a=rand(10,1), you refer it a...

14 years ago | 0

| accepted

Answered
fscanf in Simulink
Simulink doesn't support string data type. See <http://www.mathworks.com/help/toolbox/simulink/ug/f14-90479.html#f14-90488> Y...

14 years ago | 0

Answered
Create a function from user input string
>> str='x^2+2*x+3' str = x^2+2*x+3 >> f=inline(str) f = Inline function: f(x) = x^2+2*x+3 >> f(2) an...

14 years ago | 3

| accepted

Answered
assigning a probability to a loop
See this post. <http://www.mathworks.com/matlabcentral/answers/14585-random-number-generation-with-changing-probability random n...

14 years ago | 0

Answered
Make Error in Simulink – Division by Zero?
I assume you understand what is division by zero error. Every time you do a division, in C or in MATLAB, the safest way is to ch...

14 years ago | 0

Answered
histogram plotting issue
You need to learn to use vector or matrix, the essence of MATLAB. Pre-allocate you p as p=.1:.1:.9; p will be a 1x9 vector, y...

14 years ago | 0

| accepted

Answered
Displaying % error
%% t=1:10; y=1:10; str=cellstr(num2str(y.','%%%5.2f')); plot(t,y); text(t,y,str);

14 years ago | 0

| accepted

Answered
Calculating and Adding Percent Error to a Graph
Since you have the y and ystar, you can do percent_error=100*abs(y-ystar)./y; Notice "./" is the element-wise division....

14 years ago | 0

| accepted

Answered
Cutting down on space while generating code.
I assume you are using RTW. Follow the documentation Real-Time Workshop->User's Guide->Preparing Models for Code Generation->Con...

14 years ago | 0

| accepted

Answered
Using global variable to define a Simulink block parameter
In the InitFcn call, does it call a M-function or M-script? I suspect this is another case of function workspace and base worksp...

14 years ago | 1

| accepted

Load more