loading variables from command window to a workspace

7 Ansichten (letzte 30 Tage)
busra gogen
busra gogen am 24 Jan. 2021
Kommentiert: busra gogen am 24 Jan. 2021
I have a closed region which is bounded by lattitudes and longitudes and i know that how many points inside in that region . When i run the program it gives 237(workspace windows shows 237 points) points and these points are coming from my 12094*3 matrix . However, i dont know third column values of 237 points, so i write a code to find third values like figure 1.
Figure 1.
Now i have two problems. First problem is that when i copy third values to excel to check whethet it is 237 or not, i realized that there are 241 values. How it is possible? Although 237 variables comes from 12094*3 matrix, there are 241 variables in command window. My another problem is that when i count it gives 1. How can i load values to workspace from command window. I tried Mw(count+1) but it didnt work.

Akzeptierte Antwort

KALYAN ACHARJYA
KALYAN ACHARJYA am 24 Jan. 2021
Bearbeitet: KALYAN ACHARJYA am 24 Jan. 2021
"loading variables from command window to a workspace"
Assign any variable name during execution, it's automaticacly load the variable in the workspace (without variable name, it may saved as "ans" variable name)
or
Use the array to save the result during iteration. please refer array.
Or
To save the multiple array or vectors, you may consider cell array.
  4 Kommentare
KALYAN ACHARJYA
KALYAN ACHARJYA am 24 Jan. 2021
Please attach the complete code.
busra gogen
busra gogen am 24 Jan. 2021
all=[Lat Long Earth]; % whole matrix 12094*3
xq=Lat;
yq=Long;
xv=input('write s_lat');
yv=input('write s_long');
in=inpolygon(xq,yq,xv,yv);
[in,on]= inpolygon(xq,yq,xv,yv);
numel(xq(in));
c=[xq(in) yq(in)]; %obtained matrix from all (237*2)
newc=[c,zeros(size(c, 1),size(all, 2)-size(c, 2));zeros(size(all, 1)-size(c, 1),size(all, 2))];
for j=1:size(newc)
for i=1:size(newc)
if ((all(i,1)==newc(j,1)) && (all(i,2)==newc(j,2)))
disp(all(i,3)); % i want third column of all corresponding to c
end
end
end
when i run the matlab, my command window will be like that:
4.6000
4.2000
4.4000
4.2000
5.3000
4.3000
4.2000
4.2000
4.1000
4.1000
4
4.2000
4.3000
4.7000
4.1000
4.1000
4.4000
4
4.1000
4.1000
4.5000
4.3000
4.2000
4
4
4.5000
4.6192
4.2000
4.5000
4.3000
4.6000
6.5000
4.5383
4.6192
4.6192
5.5907
4.7812
4.7002
4.6192
5.1050
4.6192
5.3000
5.2000
4.6192
4.7812
4.8621
4.2531
4.6192
4.2531
4.6192
4.6192
5.2000
4.5627
4.3563
4.5383
4.1499
4.7812
4.6659
4.7002
4.5383
4.7812
4.5208
4.5627
4.6659
4.1499
4.4595
5.2000
4.5627
4.5208
4.2531
4.2531
4.5208
4.6003
4.8000
4.1499
4.5383
4.4595
4.5627
4.6003
5.2000
5.7000
4.5208
4.6797
4.5208
4.4595
4.5383
4.1499
4.1499
5.0786
4.6192
4.5383
4.1499
4.5627
4.5383
4.5627
4.5383
4.7690
4.6659
4.5383
4.2531
4.6192
4.2531
4.2531
4.4595
4.3563
5.4000
4.4595
4.1499
4.9754
4.6659
4.2531
4.7690
5.4000
4.2531
4.4595
4.5383
4.2531
4.1499
4.7812
4.5383
5.2850
4.7002
4.8621
4.3563
4.2531
4.6659
4.9754
5.1818
4.5383
4.3563
4.3563
4.6192
4.7812
4.4595
4.6659
4.4595
4.6659
4.8722
4.5627
4.5383
4.7002
4.7812
5.4000
4.5383
4.5383
4.5627
4.5383
4.5383
4.2531
4.6192
4.8621
4.5383
4.6659
4.3563
4.6192
4.1499
4.1499
4.2531
4.2531
4.1499
4.6192
4.1499
4.5627
6.6000
4.4595
4.5383
4.3563
4.2531
4.6192
4.4595
4.1499
4.4595
4.8621
5.1818
4.3563
4.6659
4.3563
4.9754
4.8621
4.2531
4.4595
4.2531
4.6659
4.1499
4.1499
4.6659
4.1499
4.4595
4.3563
4.6659
4.3563
4.2531
4.3563
4.1499
5.4914
6.6000
4.3563
4.3563
4.3563
4.6659
4.5627
4.6659
5.6978
5.9666
4.9754
5.5275
4.6659
4.4595
4.4595
4.1499
4.1499
4.4595
4.5627
4.5383
4.7844
4.7844
4.8416
4.5627
4.4595
5.2850
5.3882
5.2850
5.1274
5.5275
5.0702
5.1845
5.3560
5.1845
5.3560
5.8854
5.1845
5.2417
5.0702
5.4132
5.2988
5.3560
5.0702
5.2988
5.3560
6.0479
7.1855
>>

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by