prompt = {'Enter the forces(kN): '};title = 'Environmental forces';answer = inputdlg(prompt,title);f = str2num(answer{:});for ii=1:numel(f) eval(sprintf('f%d = %f\n',ii,f(ii)))endprompt1 = {'Enter the respective angles: '};title1 = 'Angle w.r.t x-axis';answer1 = inputdlg(prompt1, title1);a = str2num(answer1{:});for jj=1:numel(a) eval(sprintf('a%d = %f\n',jj,a(jj)))endThe code above would read the forces and their respective angles and assign the variables automatically. I want to find the horizontal component. i.e. f*cos(a).. How do i do it?
MATLAB: How do i use the values read by the eval function in other formulas
evalnumel
Related Question
- Is it possible to take inputs as several sets
- Graph tiltle with multiple variables over 2 lines
- Cannot I fully run this code in exe
- How to return the solution of a vector of variables one time instead of indexing sol.x1, solx2..etc
- How to save inner loop data with outer loop data in one matfile
- How to read user input of multiple string separately in inputdlg
- Can array values be used in plot titles
Best Answer