Correctly displaying result on Matlab

  • Thread starter alba_ei
  • Start date
  • Tags
    Matlab
In summary, the conversation is about sorting months in a calendar and the attempt at creating a solution using MATLAB. The code provided includes creating a character array of months and sorting them in alphabetical order. However, the final lines of code do not produce the desired output.
  • #1
alba_ei
39
1

Homework Statement


33ld01i.png


The Attempt at a Solution


Attempt 1
Code:
clc;    
clear;
Months=char('January','February','March','April','May','June','July','August','September','October','November','December');
CalSort=char(sortrows(Months));
Cell={CalSort};
disp([CalSort(:,1:6) CalSort(:,7:12)])

Executing CalSort=char(sortrows(Months))
Code:
CalSort =
April    
August   
December 
February 
January  
July     
June     
March    
May      
November 
October  
September

But the two last lines of codes doesn't give me the wanted result.
 
Physics news on Phys.org
  • #2
Attempt 2clc; clear;Months=char('January','February','March','April','May','June','July','August','September','October','November','December');CalSort=char(sortrows(Months));Cell={CalSort};disp({CalSort})Executing CalSort=char(sortrows(Months))CalSort =April August December February January July June March May November October SeptemberBut the two last lines of codes doesn't give me the wanted result.
 

Related to Correctly displaying result on Matlab

1. How can I display the result of my calculations in MATLAB?

To display the result of your calculations in MATLAB, you can use the disp function. This function will print the value of the expression or variable to the command window. For example, if you have a variable x with a value of 5, you can use disp(x) to display the value 5 in the command window.

2. Can I customize the way the result is displayed in MATLAB?

Yes, you can customize the way the result is displayed in MATLAB using formatting options. For example, you can specify the number of decimal places to display or use scientific notation. You can also add text or symbols to the result using the fprintf function.

3. How can I save the result of my calculations in MATLAB?

To save the result of your calculations in MATLAB, you can use the save function. This function allows you to save the value of a variable or expression to a file. You can also specify the format of the file, such as a text file or a MATLAB data file.

4. Can I plot the result of my calculations in MATLAB?

Yes, you can plot the result of your calculations in MATLAB using the plot function. This function allows you to create different types of plots, such as line plots, scatter plots, and histograms. You can also customize the appearance of the plot by adding labels, titles, and changing the color or style of the plot.

5. How can I display the result of my calculations in a graphical user interface (GUI) in MATLAB?

To display the result of your calculations in a GUI in MATLAB, you can use the uicontrol function. This function allows you to create different types of user interface elements, such as buttons, sliders, or text boxes. You can then use these elements to display the result of your calculations or allow the user to input values for the calculations.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
12
Views
3K
  • Art, Music, History, and Linguistics
2
Replies
44
Views
4K
  • Computing and Technology
Replies
2
Views
1K
  • General Discussion
Replies
29
Views
4K
  • General Math
Replies
7
Views
879
  • General Discussion
Replies
16
Views
2K
  • Programming and Computer Science
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
8K
Replies
3
Views
1K
Back
Top