Questions tagged [disp]

25 questions
40
votes
7 answers

How can I flush the output of disp in Matlab or Octave?

I have a program in Octave that has a loop - running a function with various parameters, not something that I can turn into matrices. At the beginning of each iteration I print the current parameters using disp. The first times I ran it I had a…
Nathan Fellman
  • 122,701
  • 101
  • 260
  • 319
25
votes
6 answers

How to display (print) vector in Matlab?

I have a vector x = (1, 2, 3) and I want to display (print) it as Answer: (1, 2, 3). I have tried many approaches, including: disp('Answer: ') strtrim(sprintf('%f ', x)) But I still can't get it to print in format which I need. Could someone point…
Edward Ruchevits
  • 6,411
  • 12
  • 51
  • 86
18
votes
1 answer

Displaying information from MATLAB without a line feed

Is there any way to output/display information from a MATLAB program without an ending line feed? My MATLAB program outputs a number a bit now and then. Between outputting the number the program does a lot of other stuff. This is a construct mainly…
AnnaR
  • 3,166
  • 6
  • 35
  • 39
8
votes
2 answers

How to use tab in disp()?

disp(['counter ' num2str(blk) (here I need a tab!!!) 'adc ' num2str(adc_nr)])
kame
  • 20,848
  • 33
  • 104
  • 159
4
votes
2 answers

disp(fprintf()) prints the fprintf and the number of characters. Why?

By coincidence I discovered, that disp(fprintf()) prints the string of fprintf plus the number of characters that it has. I know, that the disp() is reduntant, but just out of pure curiosity I want to know, why it prints the number of characters,…
Max
  • 1,471
  • 15
  • 37
4
votes
2 answers

I am trying to display variable names and num2str representations of their values in matlab

I am trying to produce the following:The new values of x and y are -4 and 7, respectively, using the disp and num2str commands. I tried to do this disp('The new values of x and y are num2str(x) and num2str(y) respectively'), but it gave num2str…
cuabanana
  • 126
  • 1
  • 1
  • 7
2
votes
2 answers

Matlab - printing multiple variables

I am trying to print multiple variables to the command window with accompanying text. disp does not seem to want to work, nor does fprintf. Does anyone have any idea how i can do this. I am trying to print code to look like the following, inserting…
John Connor
  • 41
  • 1
  • 3
1
vote
1 answer

How to display the dates from a column separately?

I have a set of data such that column 1 shows the date (in MATLAB serial number form) and column 2 shows the rainfall, as shown like this: x = [ 22029 81 23040 90.2 26701 90.2 28223 188 36973 92 38386 99.8 …
Kat
  • 27
  • 6
1
vote
1 answer

Difference between disp and fprintf

In Matlab, it seems to me that disp and fprintf commands both are very similar in that they both show to display what you tell it to. What is the difference between these 2 commands?
Y-MinG
  • 41
  • 1
  • 1
  • 5
1
vote
2 answers

Using disp function to display values

Data.xlsx is an excel file containing the data for 156 students. From cell 4 of the excel file, the 1st Student Number is displayed and if you increment by 7, you have the 2nd Student Number and so on up until the last cell 1094. F =…
SB998
  • 13
  • 5
1
vote
1 answer

How do I suppress lines of code inside one function when that function is being called from within another function?

I have two functions, one is called from inside of another. I want certain parts of the first function to not execute when being called within the second function. function vvec = vecVelocity(varargin); %must be preceded with a 'syms var real'…
1
vote
1 answer

Stata macro and for loop when there are quotes and numbers

Suppose you have the macro global LabNames "3M" "ABBOTT" "MERCK SHARP DOHME" I am using the quotes so that the words are correctly grouped (MERCK SHARP DOHME is one company, not three different ones). I am trying to write a program that goes…
M. Otts
  • 11
  • 2
0
votes
0 answers

Return on a disp function

I'm trying to display text in matlab, but it's quite long and going off the side of the command window. Is there a way for me to return that and skip down a line part way through the text? In this specific example I am using the input function…
0
votes
1 answer

Print the value of a variable of unknown type without newline in Octave

I mean to print the value of a variable myvar of unknown type, concatenated with arbitrary text, without a newline. I know how to print without a newline: printf('My var = %, is it ok for you?', myvar), but this requires knowing…
0
votes
0 answers

How do I print values from a loop and see how they're being used in a function in matlab?

I have a main matlab file. The main file accesses several functions. There is a loop in one of the functions and I want to see each part of the loop even though those variables aren't being stored. I am new to matlab and I don't understand whether…
1
2