Filter löschen
Filter löschen

"Work around" for using an index with decimal entries

11 Ansichten (letzte 30 Tage)
Jason
Jason am 1 Sep. 2013
I am writing a master code referencing several separate scripts and did not realize I can NOT use decimals in indices.
My code first asks for some user inputs:
prompt = 'What is the Nominal Depth (in) Parallel to the Flange? ';
C_Nom_D = input(prompt);
prompt = 'What is the Weight in Pounds Per Foot of Length? ';
C_sec = input(prompt);
An example of an entry in the index system I want to use is as follows:
C{10,15.30}=[10.00,2.6,0.24,0.436,4.49,67.4,2.28,0.634,0.796,15.300];
It then calls up the desired information as follows:
M_c = C{C_Nom_D,C_sec};
d = M_c(1);
fprintf('Depth = %.2f\n', d);
b_f = M_c(2);
fprintf('Flange Thickness (in) = %.2f\n', b_f);
This methodology worked when I was using whole numbers, but I now realize that decimals simply do not work.
Does anyone have any suggestions to work around the problem, or perhaps a different way to index my information?
Thanks for any help in advance.
-Jason

Antworten (2)

Roger Stafford
Roger Stafford am 1 Sep. 2013
If by "decimal" you mean fractions such as 15.30, then no, matlab uses only positive integers for its indices. That is an absolute requirement with indices on this system. There is no "work-around". The function you seemed to have in mind with your expression
C{10,15.30}=[10.00,2.6,0.24,0.436,4.49,67.4,2.28,0.634,0.796,15.300];
would be a 'find' operation in matlab: find the element which is equal to 15.30
  4 Kommentare
Jason
Jason am 2 Sep. 2013
Thanks again Roger,
I'll try and explain more generally. I have a function that asks for user inputs and based on the answers given will try to pull up specific information from other scripts. Based on the entry that the script pulls up, it evaluates an expression and outputs the result. The problem that I am having is that previous script files I created had entry titles such as A{1,2} or B{3,4}, but now I would like to title entries such as A{1.1,2.2} and B{3.3,4.4}. This is not based on preference, but the fact that I am working with specific sections of Steel.
From your response and what I have read in other help articles, MATLAB is not built to understand this method of titling. So I am hoping there is another way to achieve my desired result.
What I need perhaps is a different way to store data to be pulled up by my master function if that is possible. I am by no means a MATLAB expert so I was hoping there is a different way to do this.
Getting more specific...
An example of one of the scripts that works is as follows:
prompt = 'What is the Nominal Depth (in) Parallel to the Flange? ';
W_Nom_D = input(prompt);
prompt = 'What is the Weight in Pounds Per Foot of Length? ';
W_sec = input(prompt);
W2{36,300}=[36.74,16.66,0.95,1.68,88.3,20300,1300,64.2,300,1244,244];
W2{36,280}=[36.52,16.6,0.89,1.57,82.4,18900,1200,52.6,280,1157,226];
W2{36,260}=[36.26,16.55,0.84,1.44,76.5,17300,1090,41.5,260,1064,207];
W2{36,245}=[36.08,16.51,0.8,1.35,72.1,16100,1010,34.6,245,997,193];
W2{36,230}=[35.9,16.47,0.76,1.26,67.6,15000,940,28.6,230,931,179];
W2{36,210}=[36.69,12.18,0.83,1.36,61.8,13200,411,28,210,825,110];
W2{36,194}=[36.49,12.12,0.77,1.26,57,12100,375,22.2,194,758,101];
W2{36,182}=[36.33,12.08,0.73,1.18,53.6,11300,347,18.4,182,710,94];
W2{36,170}=[36.17,12.03,0.68,1.1,50,10500,320,15.1,170,660,87];
W2{36,160}=[36.01,12,0.65,1.02,47,9750,295,12.4,160,616,81];
W2{36,150}=[35.85,11.98,0.63,0.94,44.2,9040,270,10.1,150,573,74];
W2{36,135}=[35.55,11.95,0.6,0.79,39.7,7800,225,6.99,135,501,63];
W2{33,241}=[34.18,15.86,0.83,1.4,70.9,14200,932,35.8,241,932,185];
W2{33,221}=[33.93,15.81,0.78,1.28,65,12800,840,27.5,221,849,167];
W2{33,201}=[33.68,15.75,0.72,1.15,59.1,11500,749,20.5,201,765,150];
W2{33,152}=[33.49,11.57,0.64,1.06,44.7,8160,273,12.4,152,552,77];
W2{33,141}=[33.3,11.54,0.61,0.96,41.6,7450,246,9.7,141,507,70];
W2{33,130}=[33.09,11.51,0.58,0.86,38.3,6710,218,7.37,130,460,63];
W2{33,118}=[32.86,11.48,0.55,0.74,34.7,5900,187,5.3,118,408,55];
W2{30,211}=[30.94,15.11,0.78,1.32,62,10300,757,27.9,211,744,157];
W2{30,191}=[30.68,15.04,0.71,1.19,56.1,9170,673,20.6,191,668,141];
W2{30,173}=[30.44,14.99,0.66,1.07,50.8,8200,598,15.3,173,600,126];
W2{30,132}=[30.31,10.55,0.62,1,38.9,5770,196,9.72,132,432,61];
W2{30,124}=[30.17,10.52,0.59,0.93,36.5,5360,181,7.99,124,403,57];
W2{30,116}=[30.01,10.5,0.57,0.85,34.2,4930,164,6.43,116,373,52];
W2{30,108}=[29.83,10.48,0.55,0.76,31.7,4470,146,4.99,108,341,47];
W2{30,99}=[29.65,10.45,0.52,0.67,29.1,3990,128,3.77,99,307,41];
W2{27,178}=[27.81,14.09,0.73,1.19,52.3,6990,555,19.5,178,563,124];
W2{27,161}=[27.59,14.02,0.66,1.08,47.4,6280,497,14.7,161,508,112];
W2{27,146}=[27.38,13.97,0.61,0.98,42.9,5630,443,10.9,146,457,100];
W2{27,114}=[27.29,10.07,0.57,0.93,33.5,4090,159,7.33,114,339,52];
W2{27,102}=[27.09,10.02,0.52,0.83,30,3620,139,5.29,102,302,46];
W2{27,94}=[26.92,9.99,0.49,0.75,27.7,3270,124,4.03,94,274,41.3];
W2{27,84}=[26.71,9.96,0.46,0.64,24.8,2850,106,2.81,84,241,35.6];
W2{24,162}=[25,12.96,0.71,1.22,47.7,5170,443,18.5,162,466,108];
W2{24,146}=[24.74,12.9,0.65,1.09,43,4580,391,13.4,146,415,95.6];
W2{24,131}=[24.48,12.86,0.61,0.96,38.5,4020,340,9.5,131,367,83.9];
W2{24,117}=[24.26,12.8,0.55,0.85,34.4,3540,297,6.72,117,325,73.8];
W2{24,104}=[24.06,12.75,0.5,0.75,30.6,3100,259,4.72,104,287,64.7];
W2{24,94}=[24.31,9.07,0.52,0.88,27.7,2700,109,5.26,94,251,39.8];
W2{24,84}=[24.1,9.02,0.47,0.77,24.7,2370,94.4,3.7,84,222,34.9];
W2{24,76}=[23.92,8.99,0.44,0.68,22.4,2100,82.5,2.68,76,198,30.8];
W2{24,68}=[23.73,8.97,0.42,0.59,20.1,1830,70.4,1.87,68,174,26.6];
W2{24,62}=[23.74,7.04,0.43,0.59,18.2,1550,34.5,1.71,62,151,17.9];
W2{24,55}=[23.57,7.01,0.4,0.51,16.2,1350,29.1,1.18,55,132,15.4];
W2{21,147}=[22.06,12.51,0.72,1.15,43.2,3630,376,15.4,147,371,94.7];
W2{21,132}=[21.83,12.44,0.65,1.04,38.8,3220,333,11.3,132,331,84.4];
W2{21,122}=[21.68,12.39,0.6,0.96,35.9,2960,305,8.98,122,305,77.6];
W2{21,111}=[21.51,12.34,0.55,0.88,32.7,2670,274,6.83,111,276,70.2];
W2{21,101}=[21.36,12.29,0.5,0.8,29.8,2420,248,5.21,101,251,63.7];
W2{21,93}=[21.62,8.42,0.58,0.93,27.3,2070,92.9,6.03,93,219,36.8];
W2{21,83}=[21.43,8.36,0.52,0.84,24.3,1830,81.4,4.34,83,194,32.5];
W2{21,73}=[21.24,8.3,0.46,0.74,21.5,1600,70.6,3.02,73,170,28.5];
W2{21,68}=[21.13,8.27,0.43,0.69,20,1480,64.7,2.45,68,158,26.3];
W2{21,62}=[20.99,8.24,0.4,0.62,18.3,1330,57.5,1.83,62,142,23.5];
W2{21,57}=[21.06,6.56,0.41,0.65,16.7,1170,30.6,1.77,57,126,16.6];
W2{21,50}=[20.83,6.53,0.38,0.54,14.7,984,24.9,1.14,50,108,13.9];
W2{21,44}=[20.66,6.5,0.35,0.45,13,843,20.7,0.77,44,93.3,11.8];
W2{18,119}=[18.97,11.27,0.66,1.06,35.1,2190,253,10.6,119,260,70.9];
W2{18,106}=[18.73,11.2,0.59,0.94,31.1,1910,220,7.48,106,229,62.3];
W2{18,97}=[18.59,11.15,0.54,0.87,28.5,1750,201,5.86,97,210,57];
W2{18,86}=[18.39,11.09,0.48,0.77,25.3,1530,175,4.1,86,185,50];
W2{18,76}=[18.21,11.04,0.43,0.68,22.3,1330,152,2.83,76,162,43.8];
W2{18,71}=[18.47,7.64,0.5,0.81,20.8,1170,60.3,3.48,71,144,26.4];
W2{18,65}=[18.35,7.59,0.45,0.75,19.1,1070,54.8,2.73,65,132,24.1];
W2{18,60}=[18.24,7.56,0.42,0.7,17.6,984,50.1,2.17,60,122,22.2];
W2{18,55}=[18.11,7.53,0.39,0.63,16.2,890,44.9,1.66,55,111,20.1];
W2{18,50}=[17.99,7.5,0.36,0.57,14.7,800,40.1,1.24,50,100,18];
W2{18,46}=[18.06,6.06,0.36,0.61,13.5,712,22.5,1.22,46,89.5,13.1];
W2{18,40}=[17.9,6.02,0.32,0.53,11.8,612,19.1,0.81,40,77.2,11.3];
W2{18,35}=[17.7,6,0.3,0.43,10.3,510,15.3,0.51,35,65.3,9.34];
W2{16,100}=[16.97,10.43,0.59,0.99,29.4,1490,186,7.73,100,197,56.5];
W2{16,89}=[16.75,10.37,0.53,0.88,26.2,1300,163,5.45,89,174,49.6];
W2{16,77}=[16.52,10.3,0.46,0.76,22.6,1110,138,3.57,77,149,42.6];
W2{16,67}=[16.33,10.24,0.4,0.67,19.7,954,119,2.39,67,129,36.8];
W2{16,57}=[16.43,7.12,0.43,0.72,16.8,758,43.1,2.22,57,104,20.3];
W2{16,50}=[16.26,7.07,0.38,0.63,14.7,659,37.2,1.52,50,91,17.6];
W2{16,45}=[16.13,7.04,0.35,0.57,13.3,586,32.8,1.11,45,81.3,15.7];
W2{16,40}=[16.01,7,0.31,0.51,11.8,518,28.9,0.79,40,71.9,13.9];
W2{16,36}=[15.86,6.99,0.3,0.43,10.6,448,24.5,0.54,36,62.9,12];
W2{16,31}=[15.88,5.53,0.28,0.44,9.12,375,12.4,0.46,31,53,8.09];
W2{16,26}=[15.69,5.5,0.25,0.35,7.68,301,9.59,0.26,26,43.2,6.47];
W2{14,730}=[22.42,17.89,3.07,4.91,215,14300,4720,1450,730,1660,799];
W2{14,665}=[21.64,17.65,2.83,4.52,196,12400,4170,1120,665,1478,716];
W2{14,605}=[20.92,17.42,2.6,4.16,178,10800,3680,870,605,1317,642];
W2{14,550}=[20.24,17.2,2.38,3.82,162,9430,3250,670,550,1173,575];
W2{14,500}=[19.6,17.01,2.19,3.5,147,8210,2880,514,500,1045,516];
W2{14,455}=[19.02,16.84,2.02,3.21,134,7190,2560,395,455,934,463];
W2{14,426}=[18.67,16.7,1.88,3.04,125,6600,2360,331,426,867,431];
W2{14,398}=[18.29,16.59,1.77,2.85,117,6000,2170,273,398,799,399];
W2{14,370}=[17.92,16.48,1.66,2.66,109,5440,1990,222,370,734,368];
W2{14,342}=[17.54,16.36,1.54,2.47,101,4900,1810,178,342,670,337];
W2{14,311}=[17.12,16.23,1.41,2.26,91.4,4330,1610,136,311,601,304];
W2{14,283}=[16.74,16.11,1.29,2.07,83.3,3840,1440,104,283,540,274];
W2{14,257}=[16.38,16,1.18,1.89,75.6,3400,1290,79.1,257,485,247];
W2{14,233}=[16.04,15.89,1.07,1.72,68.5,3010,1150,59.5,233,434,222];
W2{14,211}=[15.72,15.8,0.98,1.56,62,2660,1030,44.6,211,388,199];
W2{14,193}=[15.48,15.71,0.89,1.44,56.8,2400,931,34.8,193,353,181];
W2{14,176}=[15.22,15.65,0.83,1.31,51.8,2140,838,26.5,176,318,164];
W2{14,159}=[14.98,15.57,0.75,1.19,46.7,1900,748,19.8,159,285,147];
W2{14,145}=[14.78,15.5,0.68,1.09,42.7,1710,677,15.2,145,258,134];
W2{14,132}=[14.66,14.73,0.65,1.03,38.8,1530,548,12.3,132,232,114];
W2{14,120}=[14.48,14.67,0.59,0.94,35.3,1380,495,9.37,120,210,104];
W2{14,109}=[14.32,14.61,0.53,0.86,32,1240,447,7.12,109,190,93.9];
W2{14,99}=[14.16,14.57,0.49,0.78,29.1,1110,402,5.37,99,171,84.8];
W2{14,90}=[14.02,14.52,0.44,0.71,26.5,999,362,4.06,90,155,76.7];
W2{14,82}=[14.31,10.13,0.51,0.86,24.1,882,148,5.08,82,137,46];
W2{14,74}=[14.17,10.07,0.45,0.79,21.8,796,134,3.88,74,124,41.7];
W2{14,68}=[14.04,10.04,0.42,0.72,20,723,121,3.02,68,113,38];
W2{14,61}=[13.89,10,0.38,0.65,17.9,640,107,2.2,61,100,33.8];
W2{14,53}=[13.92,8.06,0.37,0.66,15.6,541,57.7,1.94,53,85.2,23];
W2{14,48}=[13.79,8.03,0.34,0.6,14.1,485,51.4,1.46,48,76.5,20.6];
W2{14,43}=[13.66,8,0.31,0.53,12.6,428,45.2,1.05,43,67.7,18.2];
W2{14,38}=[14.1,6.77,0.31,0.52,11.2,385,26.7,0.8,38,60.6,13.2];
W2{14,34}=[13.98,6.75,0.29,0.46,10,340,23.3,0.57,34,53.7,11.6];
W2{14,30}=[13.84,6.73,0.27,0.39,8.85,291,19.6,0.38,30,46.4,9.9];
W2{14,26}=[13.91,5.03,0.26,0.42,7.69,245,8.91,0.36,26,39.4,6.41];
W2{14,22}=[13.74,5,0.23,0.34,6.49,199,7,0.21,22,32.3,5.19];
W2{12,336}=[16.82,13.39,1.78,2.96,98.8,4060,1190,243,336,601,271];
W2{12,305}=[16.32,13.24,1.63,2.71,89.6,3550,1050,185,305,536,243];
W2{12,279}=[15.85,13.14,1.53,2.47,81.9,3110,937,143,279,480,219];
W2{12,252}=[15.41,13.01,1.4,2.25,74.1,2720,828,108,252,427,195];
W2{12,230}=[15.05,12.9,1.29,2.07,67.7,2420,742,83.8,230,385,177];
W2{12,210}=[14.71,12.79,1.18,1.9,61.8,2140,664,64.7,210,346,160];
W2{12,190}=[14.38,12.67,1.06,1.74,55.8,1890,589,48.8,190,310,143];
W2{12,170}=[14.03,12.57,0.96,1.56,50,1650,517,35.6,170,273,127];
W2{12,152}=[13.71,12.48,0.87,1.4,44.7,1430,454,25.8,152,241,112];
W2{12,136}=[13.41,12.4,0.79,1.25,39.9,1240,398,18.5,136,212,99];
W2{12,120}=[13.12,12.32,0.71,1.11,35.3,1070,345,12.9,120,185,86.4];
W2{12,106}=[12.89,12.22,0.61,0.99,31.2,933,301,9.13,106,162,76.1];
W2{12,96}=[12.71,12.16,0.55,0.9,28.2,833,270,6.86,96,146,68.5];
W2{12,87}=[12.53,12.13,0.52,0.81,25.6,740,241,5.1,87,130,61.4];
W2{12,79}=[12.38,12.08,0.47,0.74,23.2,662,216,3.84,79,117,55.3];
W2{12,72}=[12.25,12.04,0.43,0.67,21.1,597,195,2.93,72,106,50.1];
W2{12,65}=[12.12,12,0.39,0.61,19.1,533,174,2.18,65,95.2,45];
W2{12,58}=[12.19,10.01,0.36,0.64,17,475,107,2.1,58,84.7,33.4];
W2{12,53}=[12.06,10,0.35,0.58,15.6,425,95.8,1.58,53,76.3,30];
W2{12,50}=[12.19,8.08,0.37,0.64,14.7,394,56.3,1.78,50,70.7,22.2];
W2{12,45}=[12.06,8.05,0.34,0.58,13.2,350,50,1.31,45,63.1,19.8];
W2{12,40}=[11.94,8.01,0.3,0.52,11.8,310,44.1,0.95,40,55.9,17.6];
W2{12,35}=[12.5,6.56,0.3,0.52,10.3,285,24.5,0.74,35,50.7,12.3];
W2{12,30}=[12.34,6.52,0.26,0.44,8.79,238,20.3,0.46,30,42.7,10.3];
W2{12,26}=[12.22,6.49,0.23,0.38,7.65,204,17.3,0.3,26,36.8,8.88];
W2{12,22}=[12.31,4.03,0.26,0.43,6.48,156,4.66,0.29,22,28.9,4.44];
W2{12,19}=[12.16,4.01,0.24,0.35,5.57,130,3.76,0.18,19,24.3,3.7];
W2{12,16}=[11.99,3.99,0.22,0.27,4.71,103,2.82,0.1,16,19.6,2.95];
W2{12,14}=[11.91,3.97,0.2,0.23,4.16,88.6,2.36,0.07,14,17,2.54];
W2{10,112}=[11.36,10.42,0.76,1.25,32.9,716,236,15.1,112,146,70];
W2{10,100}=[11.1,10.34,0.68,1.12,29.4,623,207,10.9,100,129,61.9];
W2{10,88}=[10.84,10.27,0.61,0.99,25.9,534,179,7.53,88,112,53.9];
W2{10,77}=[10.6,10.19,0.53,0.87,22.6,455,154,5.11,77,96.7,46.7];
W2{10,68}=[10.4,10.13,0.47,0.77,20,394,134,3.56,68,84.3,40.9];
W2{10,60}=[10.22,10.08,0.42,0.68,17.6,341,116,2.48,60,73.6,35.8];
W2{10,54}=[10.09,10.03,0.37,0.62,15.8,303,103,1.82,54,65.7,32];
W2{10,49}=[9.98,10,0.34,0.56,14.4,272,93.4,1.39,49,59.4,29];
W2{10,45}=[10.1,8.02,0.35,0.62,13.3,248,53.4,1.51,45,54,21];
W2{10,39}=[9.92,7.99,0.32,0.53,11.5,209,45,0.98,39,45.9,17.8];
W2{10,33}=[9.73,7.96,0.29,0.44,9.71,170,36.6,0.58,33,37.9,14.6];
W2{10,30}=[10.47,5.81,0.3,0.51,8.84,170,16.7,0.62,30,36.2,9.55];
W2{10,26}=[10.33,5.77,0.26,0.44,7.61,144,14.1,0.4,26,30.9,8.14];
W2{10,22}=[10.17,5.75,0.24,0.36,6.49,118,11.4,0.24,22,25.7,6.71];
W2{10,19}=[10.24,4.02,0.25,0.4,5.62,96.3,4.29,0.23,19,21.2,3.98];
W2{10,17}=[10.11,4.01,0.24,0.33,4.99,81.9,3.56,0.16,17,18.3,3.41];
W2{10,15}=[9.99,4,0.23,0.27,4.41,68.9,2.89,0.1,15,15.6,2.88];
W2{10,12}=[9.87,3.96,0.19,0.21,3.54,53.8,2.18,0.06,12,12.3,2.25];
W2{8,67}=[9,8.28,0.57,0.94,19.7,272,88.6,5.06,67,69.7,33.4];
W2{8,58}=[8.75,8.22,0.51,0.81,17.1,228,75.1,3.34,58,59.3,28.6];
W2{8,48}=[8.5,8.11,0.4,0.69,14.1,184,60.9,1.96,48,48.5,23.5];
W2{8,40}=[8.25,8.07,0.36,0.56,11.7,146,49.1,1.12,40,39.3,19.1];
W2{8,35}=[8.12,8.02,0.31,0.5,10.3,127,42.6,0.77,35,34.2,16.7];
W2{8,31}=[8,8,0.29,0.44,9.13,110,37.1,0.54,31,29.9,14.6];
W2{8,28}=[8.06,6.54,0.29,0.47,8.25,98,21.7,0.54,28,26.7,10.6];
W2{8,24}=[7.93,6.5,0.25,0.4,7.08,82.8,18.3,0.35,24,22.7,9.02];
W2{8,21}=[8.28,5.27,0.25,0.4,6.16,75.3,9.77,0.28,21,20.1,6.18];
W2{8,18}=[8.14,5.25,0.23,0.33,5.26,61.9,7.97,0.17,18,16.7,5.12];
W2{8,15}=[8.11,4.02,0.25,0.32,4.44,48,3.41,0.14,15,13.3,3.15];
W2{8,13}=[7.99,4,0.23,0.26,3.84,39.6,2.73,0.09,13,11.1,2.61];
W2{8,10}=[7.89,3.94,0.17,0.21,2.96,30.8,2.09,0.04,10,8.59,2.02];
W2{6,25}=[6.38,6.08,0.32,0.46,7.34,53.4,17.1,0.46,25,18.8,8.99];
W2{6,20}=[6.2,6.02,0.26,0.37,5.87,41.4,13.3,0.24,20,14.8,7.09];
W2{6,15}=[5.99,5.99,0.23,0.26,4.43,29.1,9.32,0.1,15,10.6,5.08];
W2{6,16}=[6.28,4.03,0.26,0.41,4.74,32.1,4.43,0.22,16,11.5,3.76];
W2{6,12}=[6.03,4,0.23,0.28,3.55,22.1,2.99,0.09,12,8.16,2.66];
W2{6,9}=[5.9,3.94,0.17,0.22,2.68,16.4,2.19,0.04,9,6.09,1.98];
W2{5,19}=[5.15,5.03,0.27,0.43,5.54,26.2,9.13,0.31,19,11.5,5.83];
W2{5,16}=[5.01,5,0.24,0.36,4.68,21.3,7.51,0.19,16,9.47,4.84];
W2{4,13}=[4.16,4.06,0.28,0.35,3.83,11.3,3.86,0.15,13,6.19,3.17];
M_a = W2{W_Nom_D,W_sec};
d = M_a(1);
fprintf('Flange Depth = %.2f\n', d);
b_f = M_a(2);
fprintf('Web Width (in) = %.2f\n', b_f);
t_w = M_a(3);
fprintf('Flange Thickness (in) = %.2f\n', t_w);
t_f = M_a(4);
fprintf('Thickness (in) = %.2f\n', t_f);
A = M_a(5);
fprintf('Area (in^2) = %.2f\n', A);
II_xx = M_a(6);
fprintf('Ixx = %.2f\n', II_xx);
II_yy = M_a(7);
fprintf('Iyy = %.2f\n', II_yy);
J = M_a(8);
fprintf('J = %.2f\n', J);
weight = M_a(9);
fprintf('Weight (lb) = %.2f\n', weight);
plas_m = M_a(10);
fprintf('Plastic Modulus = %.2f\n', plas_m);
So based on user inputs my code goes to the above script and pulls, for example, entry W2{14,500} and uses the values [19.6,17.01,2.19,3.5,147,8210,2880,514,500,1045,516] to evaluate an expression.
Now, however, since I am using fractions I receive a message such as this:
What is the Nominal Depth (in) Parallel to the Flange? 4
What is the Weight in Pounds Per Foot of Length? (Use two decimals) 7.25
Subscript indices must either be real positive integers or logicals.
Error in Untitled3 (line 13)
C{15,33.90}=[15.00,3.4,0.4,0.65,9.96,315,8.13,0.787,0.896,33.900];
I hope that is more clear, thank you for the help.
-Jason
Jason
Jason am 2 Sep. 2013
Roger,
It's a simple fix, but I just added a line to multiply the user input by 100 and multiplied all the entry titles by 100 to make everything positive integers.
I would still be interested if there is a way to program along the lines I described, but for now I found a way around it
Thank you for your responses.
-Jason

Melden Sie sich an, um zu kommentieren.


Iain
Iain am 2 Sep. 2013
Ok, looks like you have two "good" options.
#1 Store the indices in an array of their own, of the same size as the data.
indices = [0 0.1 0.2 0.3 0.4 0.5 0.6 ... etc];
data = [5 5.2 5.2 5.3 5.5 5.9 6.7 ... etc];
dataarr = [5 5.2 5.2 5.3 5.5 5.9 6.7 ... etc;
9 9.4 8.5 7.2 5.1 4.3 2.1 ... ];
And then use the "indices" to find the right element(s), eg.
data(indices == 0.1) %indices exactly equal to 0.1
data(indices - 0.1 < 0.2) % indices within 0.2 of 0.1
dataarr(1:2,indices ==0.1)
#2 Store the indices in an array of its own, of the same size as the data
And then:
data_access = @(x)(interp1(indices, data, x));
data_access(0.1) % interpolates for the value at 0.1
dataarr_access = @(x,r)(interp1(indices, data_arr(r,:), x));
dataarr_access(0.5,1) % interpolates for the value at 0.1

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by