Easy MATLAB Graphics: Plot, Change Linewidth and Linestyle

  • Context: MATLAB 
  • Thread starter Thread starter Kontilera
  • Start date Start date
  • Tags Tags
    Graphics Matlab
Click For Summary
SUMMARY

The discussion focuses on creating a MATLAB program that allows users to plot graphs and modify their linewidth and linestyle. The user has implemented dialog windows and a loop for plotting functions but encounters issues when trying to update the linewidth of a specified figure. The provided code attempts to retrieve user input for the figure ID and desired linewidth but fails to update the graph due to incorrect variable usage in the set function.

PREREQUISITES
  • Familiarity with MATLAB programming and syntax
  • Understanding of MATLAB figure and graphics properties
  • Knowledge of user input handling in MATLAB
  • Experience with MATLAB functions and variable scoping
NEXT STEPS
  • Review MATLAB documentation on set function for updating graphics properties
  • Learn about variable handling and data types in MATLAB
  • Explore MATLAB's input function for better user input management
  • Investigate the use of gca or gcf for referencing current figures in MATLAB
USEFUL FOR

MATLAB developers, data analysts, and anyone interested in enhancing their skills in graphical programming and user interaction within MATLAB.

Kontilera
Messages
176
Reaction score
24
Hello! I'm trying to make an easy MATLAB programme in which you can plot your graphs, change the linewidth, and linestyle in the graphs you want etc.
I've managed to use to dialog windows in MATLAB and write a loop which plots a given function. Now I want the programme to ask the user for the figureid and the linewidth and then make the corresponding change.. Here I run into trouble.

My code for this specific m-file is:

Code:
function outt = changewidth(handles)  

Figureid = input('Which figure would you like to change: ');
Width = input('Which width would you like to have: ','s');

z = str2num('Figureid');
p = str2num('Width');


figure(Figureid);
set(z, 'Linewidth', p);

outt=[handles];
end

I don't get any error message but MATLAB won't update the graph that the user refers to..

Any advice?
 
Physics news on Phys.org
In my mainfile I just write:

Code:
[...]

case 2 

changewidth(handles)


case 3 
[...]


end
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 14 ·
Replies
14
Views
4K